jiangchengfeiyi-xiaochengxu/unpackage/dist/dev/mp-weixin/pages/store-home/main/testMain.js
2025-01-02 11:18:59 +08:00

91 lines
2.7 KiB
JavaScript

"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 items = [null, null, null, null];
const items_1 = [null, null, null];
common_vendor.onMounted(async () => {
console.log("cookie--->", cookie);
await Getsort();
await changeTypes(sort.value[0], 0);
});
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;
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
});
}
};
return (_ctx, _cache) => {
return {
a: common_vendor.f(items, (item, index, i0) => {
return {
a: index
};
}),
b: common_vendor.f(items_1, (item, index, i0) => {
return {
a: index
};
})
};
};
}
};
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);