class.js
2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"use strict";
var common_vendor = require("../../common/vendor.js");
var api_index = require("../../api/index.js");
require("../../utils/request.js");
const _sfc_main = {
setup(__props) {
let data = common_vendor.reactive({
cur: 0,
firstClass: [],
titleList: []
});
common_vendor.onShow(() => {
getClassifications();
});
common_vendor.onHide(() => {
console.log(11222);
common_vendor.index.removeStorage({ key: "classId" });
data.cur = 0;
});
const bindToView = (item, index) => {
data.cur = item.id;
data.titleList = item.two;
};
const getClassifications = async () => {
try {
const res = await api_index.getTwoClassification();
console.log(res, "\u4E09\u7EA7\u5206\u7C7B");
data.cur = common_vendor.index.getStorageSync("classId") || 0;
data.firstClass = res;
if (data.cur === 0) {
data.cur = res[0].id;
data.titleList = res[0].two;
} else {
data.titleList = res.find((item) => item.id === data.cur).two;
}
console.log("getClassification", res);
} catch (err) {
common_vendor.index.showToast({ title: err, icon: "none" });
console.log("getClassification", err);
}
};
const toThreeClassHandler = (pid) => common_vendor.index.navigateTo({ url: `/pages/class/classList?pid=${pid}` });
return (_ctx, _cache) => {
return {
a: common_vendor.f(common_vendor.unref(data).firstClass, (item, index, i0) => {
return {
a: common_vendor.t(item.name),
b: common_vendor.n(common_vendor.unref(data).cur == item.id ? "check" : ""),
c: item.id,
d: common_vendor.o(($event) => bindToView(item), item.id)
};
}),
b: common_vendor.f(common_vendor.unref(data).titleList, (item, k0, i0) => {
return {
a: common_vendor.t(item.name),
b: common_vendor.f(item.three, (it, k1, i1) => {
return {
a: it.image_text,
b: common_vendor.t(it.name),
c: it.id,
d: common_vendor.o(($event) => toThreeClassHandler(it.id), it.id)
};
})
};
})
};
};
}
};
var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/vue/\u5927\u5065\u5EB7\u5546\u57CE/healthMall/pages/class/class.vue"]]);
wx.createPage(MiniProgramPage);