class.js
1.1 KB
"use strict";const e=require("../../common/vendor.js"),u=require("../../api/index.js");require("../../utils/request.js");const f={__name:"class",setup(_){let t=e.reactive({cur:0,firstClass:[],titleList:[]});e.onLoad(()=>{c()}),e.onHide(()=>{console.log(11222),e.index.removeStorage({key:"classId"})});const o=(s,n)=>{t.cur=s.id,t.titleList=s.two},c=async()=>{try{const s=await u.getTwoClassification();console.log(s,"三级分类"),t.cur=e.index.getStorageSync("classId")||0,t.firstClass=s,t.cur===0?(t.cur=s[0].id,t.titleList=s[0].two):t.titleList=s.find(n=>n.id===t.cur).two,console.log("getClassification",s)}catch(s){e.index.showToast({title:s,icon:"none"}),console.log("getClassification",s)}},r=s=>e.index.navigateTo({url:`/pages/class/classList?pid=${s}`});return(s,n)=>({a:e.f(e.unref(t).firstClass,(i,l,d)=>({a:e.t(i.name),b:e.n(e.unref(t).cur==i.id?"check":""),c:i.id,d:e.o(a=>o(i),i.id)})),b:e.f(e.unref(t).titleList,(i,l,d)=>({a:e.t(i.name),b:e.f(i.three,(a,x,h)=>({a:a.image_text,b:e.t(a.name),c:a.id,d:e.o(p=>r(a.id),a.id)}))}))})}},g=e._export_sfc(f,[["__file","D:/vue/大健康商城/healthMall/pages/class/class.vue"]]);wx.createPage(g);