"use strict"; const common_vendor = require("../../../common/vendor.js"); const api_request = require("../../../api/request.js"); const _sfc_main = { __name: "testMain", setup(__props) { const currentColor = common_vendor.ref(0); const sort = common_vendor.ref([{}]); const headerList = common_vendor.ref([{}]); const productList = common_vendor.ref([{}]); const cookie = common_vendor.wx$1.getStorageSync("cookie"); const product_type = common_vendor.ref({ type: "材料包" }); common_vendor.onMounted(async () => { console.log("cookie--->", cookie); }); common_vendor.onLoad(async (options) => { await Getsort(); await changeTypes(sort.value[0], 0); await getFonts(); }); common_vendor.onPullDownRefresh(async () => { await Getsort(); await changeTypes(sort.value[0], 0); setTimeout(() => { common_vendor.index.stopPullDownRefresh(); }, 1e3); }); const Getsort = async () => { const res = await common_vendor.index.request({ url: api_request.baseUrl + "/category/list", method: "POST", header: { cookie } }); if (res.data.code === 1) { for (let key in res.data.data) { sort.value[key] = { //类别列表 name: res.data.data[key].typeName, imgurl: res.data.data[key].typeUrl, id: res.data.data[key].id }; headerList.value[key] = { name: res.data.data[key].typeName, typeIntro: res.data.data[key].typeIntro }; } } else { common_vendor.index.showToast({ //提示请求错误 title: "请求商品分类错误", icon: "none", duration: 2e3 }); } console.log("获取商品分类==>", res.data); }; const changeTypes = async (item, index) => { currentColor.value = index; product_type.value.type = item.name; const res = await common_vendor.index.request({ url: api_request.baseUrl + "/category/list/type", method: "POST", data: { id: item.id }, header: { cookie } }); if (res.data.code === 1) { productList.value = res.data.data[item.id]; } else { common_vendor.index.showToast({ //商品请求错误 title: "更改类别错误", icon: "none", duration: 2e3 }); } }; const FontsStyle = (index) => ({ color: currentColor.value === index ? "#C35C5D" : "#727272" }); const changeImgStyle = (index) => ({ filter: currentColor.value === index ? "drop-shadow(0rpx 7.5rpx 3.75rpx #acacac)" : "none" }); const goToProduct = (item) => { console.log("跳转商品详情的item--->", item); common_vendor.index.navigateTo({ url: "../../../pages/store-home/ProductDetails/ProductDetails?gid=" + JSON.stringify(item.id) }); }; const getFonts = () => { common_vendor.index.loadFontFace({ family: "FangZhengFonts", source: `url("https://carbon2.obs.cn-north-4.myhuaweicloud.com/fonts/FangZhengFonts.TTF")`, success: (res) => { console.log("success", res); }, fail: (err) => { console.log("err", err); } }); }; return (_ctx, _cache) => { return { a: common_vendor.f(sort.value, (item, index, i0) => { return { a: common_vendor.s(changeImgStyle(index)), b: item.imgurl, c: common_vendor.t(item.name), d: common_vendor.s(FontsStyle(index)), e: index, f: common_vendor.o(($event) => changeTypes(item, index), index) }; }), b: common_vendor.f(productList.value, (item, index, i0) => { return { a: item.goodImg.split(";")[0], b: common_vendor.t(item.name), c: common_vendor.t(item.intro), d: common_vendor.t(item.price), e: common_vendor.o(() => { }, index), f: index, g: common_vendor.o(($event) => goToProduct(item), index) }; }), c: common_vendor.t(product_type.value.type) }; }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5f36a414"], ["__file", "D:/微信小程序/课设整合/匠承非遗小程序端/jiangchengfeiyi-xiaochengxu/pages/store-home/main/testMain.vue"]]); wx.createPage(MiniProgramPage);