purchase-let/unpackage/dist/dev/mp-weixin/pages/index/index.js

261 lines
9.8 KiB
JavaScript
Raw Normal View History

2024-04-25 18:02:30 +08:00
"use strict";
const common_vendor = require("../../common/vendor.js");
2024-04-28 18:08:57 +08:00
const api_good = require("../../api/good.js");
const api_cart = require("../../api/cart.js");
require("../../utils/request.js");
require("../../config/app.js");
require("../../store/user.js");
2024-04-25 18:02:30 +08:00
if (!Array) {
const _easycom_up_search2 = common_vendor.resolveComponent("up-search");
const _easycom_up_navbar2 = common_vendor.resolveComponent("up-navbar");
2024-04-28 18:08:57 +08:00
const _easycom_up_image2 = common_vendor.resolveComponent("up-image");
2024-04-25 18:02:30 +08:00
const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
const _easycom_u__icon2 = common_vendor.resolveComponent("u--icon");
2024-04-28 18:08:57 +08:00
const _easycom_up_transition2 = common_vendor.resolveComponent("up-transition");
(_easycom_up_search2 + _easycom_up_navbar2 + _easycom_up_image2 + _easycom_up_icon2 + _easycom_u__icon2 + _easycom_up_transition2)();
2024-04-25 18:02:30 +08:00
}
const _easycom_up_search = () => "../../uni_modules/uview-plus/components/u-search/u-search.js";
const _easycom_up_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
2024-04-28 18:08:57 +08:00
const _easycom_up_image = () => "../../uni_modules/uview-plus/components/u-image/u-image.js";
2024-04-25 18:02:30 +08:00
const _easycom_up_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_u__icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js";
2024-04-28 18:08:57 +08:00
const _easycom_up_transition = () => "../../uni_modules/uview-plus/components/u-transition/u-transition.js";
2024-04-25 18:02:30 +08:00
if (!Math) {
2024-04-28 18:08:57 +08:00
(_easycom_up_search + _easycom_up_navbar + _easycom_up_image + _easycom_up_icon + viewPopup + _easycom_u__icon + _easycom_up_transition)();
2024-04-25 18:02:30 +08:00
}
2024-04-27 18:02:43 +08:00
const viewPopup = () => "../../components/viewPopup.js";
2024-04-25 18:02:30 +08:00
const _sfc_main = {
__name: "index",
setup(__props) {
2024-04-27 18:02:43 +08:00
const show = common_vendor.ref(0);
2024-04-25 18:02:30 +08:00
const topActive = common_vendor.ref(0);
2024-04-27 18:02:43 +08:00
const changeOne = (item, index) => {
2024-04-28 18:08:57 +08:00
var _a, _b, _c;
2024-04-27 18:02:43 +08:00
console.log("选择", item, index);
2024-04-28 18:08:57 +08:00
topActive.value = item.id;
2024-04-27 18:02:43 +08:00
show.value = 0;
2024-04-28 18:08:57 +08:00
goodClassTow.value = (item == null ? void 0 : item.children) || [];
goodClassThree.value = ((_a = goodClassTow.value[0]) == null ? void 0 : _a.children) || [];
leftActive.value = (_b = goodClassTow.value[0]) == null ? void 0 : _b.id;
rightActive.value = (_c = goodClassThree.value[0]) == null ? void 0 : _c.id;
2024-04-27 18:02:43 +08:00
};
2024-04-28 18:08:57 +08:00
const leftActive = common_vendor.ref(0);
2024-04-27 18:02:43 +08:00
const changeTwo = (item, index) => {
2024-04-28 18:08:57 +08:00
var _a;
2024-04-27 18:02:43 +08:00
console.log("选择", item, index);
2024-04-28 18:08:57 +08:00
leftActive.value = item.id;
2024-04-27 18:02:43 +08:00
show.value = 0;
2024-04-28 18:08:57 +08:00
goodClassThree.value = (item == null ? void 0 : item.children) || [];
rightActive.value = (_a = goodClassThree.value[0]) == null ? void 0 : _a.id;
2024-04-27 18:02:43 +08:00
};
2024-04-28 18:08:57 +08:00
const rightActive = common_vendor.ref(0);
2024-04-27 18:02:43 +08:00
const changeThree = (item, index) => {
console.log("选择", item, index);
2024-04-28 18:08:57 +08:00
rightActive.value = item.id;
2024-04-27 18:02:43 +08:00
show.value = 0;
};
2024-04-28 18:08:57 +08:00
const cartList = common_vendor.reactive(/* @__PURE__ */ new Map());
const addCart = (id) => {
api_cart.cartCreateApi({
cart_num: 1,
is_new: 0,
// 是否直接购买0否1是
goods_id: id
}).then((res) => {
console.log(res);
let now = cartList.get(id) || 0;
cartList.set(id, now + 1);
});
};
const removeCart = (id) => {
let num = cartList.get(id) || 0;
if (num == 0)
return;
api_cart.cartChangeApi({
goods_id: id,
cart_num: num--
}).then((res) => {
console.log(res);
cartList.set(id, num);
});
};
2024-04-25 18:02:30 +08:00
const keyword = common_vendor.ref("");
2024-04-27 18:02:43 +08:00
const searchKeyword = () => {
console.log("搜索", keyword.value);
where.value = keyword.value;
};
const changeOrder = (order) => {
console.log("排序", order);
where.value.order = order;
};
const where = common_vendor.ref({
page: 1,
2024-04-28 18:08:57 +08:00
pageSize: 25,
2024-04-27 18:02:43 +08:00
keyword: "",
order: ""
});
const loading = common_vendor.ref(true);
2024-04-28 18:08:57 +08:00
const goodList = common_vendor.ref([]);
2024-04-27 18:02:43 +08:00
const getGoodList = () => {
loading.value = true;
2024-04-28 18:08:57 +08:00
api_good.goodListApi(where.value).then((res) => {
goodList.value = [...goodList.value, ...res.data.lists];
});
};
const loadMoreGood = () => {
console.log("触底了");
};
const goodClassList = common_vendor.ref([]);
const goodClassTow = common_vendor.ref([]);
const goodClassThree = common_vendor.ref([]);
const getgoodClassList = () => {
api_good.goodClassListApi().then((res) => {
var _a, _b, _c, _d, _e, _f;
goodClassList.value = ((_a = res.data) == null ? void 0 : _a.lists) || [];
goodClassTow.value = ((_b = goodClassList.value[0]) == null ? void 0 : _b.children) || [];
goodClassThree.value = ((_c = goodClassTow.value[0]) == null ? void 0 : _c.children) || [];
topActive.value = (_d = goodClassList.value[0]) == null ? void 0 : _d.id;
leftActive.value = (_e = goodClassTow.value[0]) == null ? void 0 : _e.id;
rightActive.value = (_f = goodClassThree.value[0]) == null ? void 0 : _f.id;
});
2024-04-27 18:02:43 +08:00
};
common_vendor.onLoad(() => {
2024-04-28 18:08:57 +08:00
getgoodClassList();
2024-04-27 18:02:43 +08:00
getGoodList();
});
2024-04-25 18:02:30 +08:00
return (_ctx, _cache) => {
return common_vendor.e({
2024-04-27 18:02:43 +08:00
a: common_vendor.o(searchKeyword),
b: common_vendor.o(($event) => keyword.value = $event),
c: common_vendor.p({
2024-04-25 18:02:30 +08:00
placeholder: "请输入商品",
showAction: false,
modelValue: keyword.value
}),
2024-04-27 18:02:43 +08:00
d: common_vendor.p({
2024-04-25 18:02:30 +08:00
placeholder: true
}),
2024-04-28 18:08:57 +08:00
e: common_vendor.f(goodClassList.value, (item, index, i0) => {
2024-04-25 18:02:30 +08:00
return {
2024-04-28 18:08:57 +08:00
a: "1ba6254c-2-" + i0,
b: common_vendor.p({
height: "100rpx",
width: "100rpx",
src: item.pic
}),
c: common_vendor.t(item.name),
d: topActive.value == item.id ? 1 : "",
e: index,
f: common_vendor.o(($event) => changeOne(item, index), index)
2024-04-25 18:02:30 +08:00
};
}),
2024-04-27 18:02:43 +08:00
f: common_vendor.p({
2024-04-25 18:02:30 +08:00
name: "list"
}),
2024-04-27 18:02:43 +08:00
g: common_vendor.o(($event) => show.value = 1),
h: show.value === 1
2024-04-25 18:02:30 +08:00
}, show.value === 1 ? {
2024-04-28 18:08:57 +08:00
i: common_vendor.f(goodClassList.value, (item, index, i0) => {
2024-04-25 18:02:30 +08:00
return {
2024-04-28 18:08:57 +08:00
a: "1ba6254c-5-" + i0 + ",1ba6254c-4",
b: common_vendor.p({
height: "100rpx",
width: "100rpx",
src: item.pic
}),
c: common_vendor.t(item.name),
d: topActive.value == item.id ? 1 : "",
e: index,
f: common_vendor.o(($event) => changeOne(item, index), index)
2024-04-25 18:02:30 +08:00
};
}),
2024-04-27 18:02:43 +08:00
j: common_vendor.o(($event) => show.value = 0),
k: common_vendor.p({
2024-04-25 18:02:30 +08:00
nav: true
})
} : {}, {
2024-04-28 18:08:57 +08:00
l: common_vendor.f(goodClassTow.value, (item, index, i0) => {
2024-04-25 18:02:30 +08:00
return {
2024-04-28 18:08:57 +08:00
a: common_vendor.t(item.name),
b: leftActive.value == item.id ? 1 : "",
2024-04-27 18:02:43 +08:00
c: index,
d: common_vendor.o(($event) => changeTwo(item, index), index)
2024-04-25 18:02:30 +08:00
};
}),
2024-04-28 18:08:57 +08:00
m: common_vendor.f(goodClassThree.value, (item, index, i0) => {
2024-04-25 18:02:30 +08:00
return {
2024-04-28 18:08:57 +08:00
a: common_vendor.t(item.name),
b: rightActive.value == item.id ? 1 : "",
c: index,
d: common_vendor.o(($event) => changeThree(item, index), index)
2024-04-25 18:02:30 +08:00
};
}),
2024-04-27 18:02:43 +08:00
n: common_vendor.p({
2024-04-25 18:02:30 +08:00
name: "arrow-down"
}),
2024-04-27 18:02:43 +08:00
o: common_vendor.o(($event) => show.value = 2),
p: where.value.order == "" ? 1 : "",
q: common_vendor.o(($event) => changeOrder("")),
r: where.value.order == "desc" || where.value.order == "asc" ? 1 : "",
s: common_vendor.o(($event) => changeOrder(where.value.order == "asc" ? "desc" : "asc")),
t: where.value.order == "sales" ? 1 : "",
v: common_vendor.o(($event) => changeOrder("sales")),
w: show.value === 2
2024-04-25 18:02:30 +08:00
}, show.value === 2 ? {
2024-04-28 18:08:57 +08:00
x: common_vendor.f(goodClassThree.value, (item, index, i0) => {
2024-04-25 18:02:30 +08:00
return {
2024-04-28 18:08:57 +08:00
a: common_vendor.t(item.name),
b: rightActive.value == item.id ? 1 : "",
c: index,
d: common_vendor.o(($event) => changeThree(item, index), index)
2024-04-25 18:02:30 +08:00
};
}),
2024-04-27 18:02:43 +08:00
y: common_vendor.o(($event) => show.value = 0)
2024-04-25 18:02:30 +08:00
} : {}, {
2024-04-28 18:08:57 +08:00
z: common_vendor.f(goodList.value, (item, index, i0) => {
2024-04-25 18:02:30 +08:00
return {
2024-04-28 18:08:57 +08:00
a: "1ba6254c-8-" + i0,
b: common_vendor.p({
width: "160rpx",
height: "160rpx",
src: item.imgs
}),
c: common_vendor.t(item.name),
d: common_vendor.t(item.brand_name),
e: common_vendor.t(item.class_name),
f: common_vendor.t(item.unit_name),
g: common_vendor.t(item.sell),
h: common_vendor.o(($event) => removeCart(item.id), item.id),
i: "1ba6254c-10-" + i0 + "," + ("1ba6254c-9-" + i0),
j: "1ba6254c-9-" + i0,
k: common_vendor.p({
show: cartList.get(item.id) > 0
}),
l: common_vendor.t(cartList.get(item.id)),
m: "1ba6254c-11-" + i0,
n: common_vendor.p({
show: cartList.get(item.id) > 0
}),
o: common_vendor.o(($event) => addCart(item.id), item.id),
p: "1ba6254c-12-" + i0,
q: item.id
2024-04-25 18:02:30 +08:00
};
}),
2024-04-27 18:02:43 +08:00
A: common_vendor.p({
2024-04-25 18:02:30 +08:00
name: "minus-circle-fill",
size: "20",
color: "#20b128"
}),
2024-04-28 18:08:57 +08:00
B: common_vendor.p({
2024-04-25 18:02:30 +08:00
name: "plus-circle-fill",
size: "20",
color: "#20b128"
2024-04-28 18:08:57 +08:00
}),
C: common_vendor.o(loadMoreGood)
2024-04-25 18:02:30 +08:00
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/里海数字乡村/purchase-let/pages/index/index.vue"]]);
wx.createPage(MiniProgramPage);