| | |
| | | // pages/bookServices/assort/index.js |
| | | import { |
| | | getPublicImage |
| | | } from "../../../assets/js/middleGround/tool"; |
| | | const app = getApp(); |
| | | Page({ |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | barHeight: "", |
| | | navBarHeight: "", |
| | | placeholderstyle: "font-size:28rpx", |
| | | assortList: [], |
| | | assortCheck: { |
| | | name: '', |
| | | code: '', |
| | | name: "", |
| | | code: "", |
| | | }, |
| | | startList: [], |
| | | startCheck: '', |
| | | |
| | | startCheck: { |
| | | id: "", |
| | | code: "", |
| | | }, |
| | | bookList: [], |
| | | loading: false, |
| | | listLoding: false, |
| | | stairListLoading: false, |
| | | rowCol: [{ |
| | | width: '50%', |
| | | }, |
| | | { |
| | | width: '100%' |
| | | }, |
| | | { |
| | | width: '80%' |
| | | }, |
| | | { |
| | | width: '100%' |
| | | }, { |
| | | width: '100%' |
| | | }, |
| | | { |
| | | width: '100%' |
| | | }, |
| | | { |
| | | width: '50%' |
| | | }, |
| | | { |
| | | width: '100%' |
| | | }, |
| | | { |
| | | width: '80%' |
| | | }, |
| | | { |
| | | width: '100%' |
| | | }, |
| | | ], |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | // this.getAssortList() |
| | | console.log(options); |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = |
| | | (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | this.setData({ |
| | | barHeight: systInfo.statusBarHeight, |
| | | navBarHeight: navBarHeight, |
| | | }); |
| | | this.getAssortList(); |
| | | }, |
| | | |
| | | /** |
| | |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | this.getAssortList(); |
| | | if (typeof this.getTabBar === "function" && this.getTabBar()) { |
| | | this.getTabBar().setData({ |
| | | active: 1, |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | /** |
| | |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() {}, |
| | | |
| | | onShareTimeline() {}, |
| | | // 获取侧边栏列表 |
| | | getAssortList() { |
| | | this.setData({ |
| | | loading: true, |
| | | listLoding: true, |
| | | }); |
| | | const query = { |
| | | path: '*', |
| | | filterList: [ |
| | | { |
| | | value: 'Normal', |
| | | field: 'state', |
| | | }, |
| | | ], |
| | | queryType: '\\', |
| | | path: "*", |
| | | filterList: [{ |
| | | value: "Normal", |
| | | field: "state", |
| | | }, ], |
| | | queryType: "\\", |
| | | searchList: [], |
| | | size: '30', |
| | | start: '0', |
| | | size: "30", |
| | | start: "0", |
| | | storeRefCode: app.config.goodsStore, |
| | | sort: { type: 'Asc', field: 'LinkOrder' }, |
| | | sort: { |
| | | type: "Asc", |
| | | field: "LinkOrder" |
| | | }, |
| | | }; |
| | | app.MG.store.getStoreChannelList(query).then((res) => { |
| | | const list = res.datas.filter((item) => item.refCode != 'jsek_homepageBookService'); |
| | | const list = res.datas.filter( |
| | | (item) => item.refCode != "jsek_homepageBookService" |
| | | ); |
| | | this.setData({ |
| | | assortList: list, |
| | | loading: false, |
| | | }); |
| | | this.setData({ |
| | | assortCheck: { |
| | |
| | | }); |
| | | }, |
| | | // 侧边栏切换 |
| | | changeAssort(data) { |
| | | changeAssort(e) { |
| | | this.setData({ |
| | | assortCheck: { |
| | | name: data.detail.label, |
| | | code: data.detail.value, |
| | | name: e.detail.label, |
| | | code: e.detail.value, |
| | | }, |
| | | }); |
| | | this.getStairList(data.detail.value); |
| | | this.getStairList(e.detail.value); |
| | | }, |
| | | // 获取一级分类 |
| | | getStairList(path) { |
| | | this.setData({ |
| | | listLoding: true, |
| | | stairListLoading: true, |
| | | startList: [] |
| | | }); |
| | | const query = { |
| | | path, |
| | | filterList: [], |
| | | queryType: '\\', |
| | | filterList: [{ |
| | | value: "Normal", |
| | | field: "state", |
| | | }, ], |
| | | queryType: "\\", |
| | | searchList: [], |
| | | size: '30', |
| | | start: '0', |
| | | size: "30", |
| | | start: "0", |
| | | storeRefCode: app.config.goodsStore, |
| | | sort: { type: 'Asc', field: 'LinkOrder' }, |
| | | sort: { |
| | | type: "Asc", |
| | | field: "LinkOrder" |
| | | }, |
| | | }; |
| | | app.MG.store.getStoreChannelList(query).then(async (res) => { |
| | | // 一级分类选中 |
| | | this.setData({ |
| | | startCheck: res.datas[0].refCode, |
| | | }); |
| | | // 获取二级分类 |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | const item = res.datas[index]; |
| | | item.icon ? |
| | | (item.icon = getPublicImage(item.icon, 150)) : |
| | | (item.icon = item.icon); |
| | | item.children = await this.getSecondList(item); |
| | | |
| | | } |
| | | // 一级分类赋值 |
| | | this.setData({ |
| | | startList: res.datas, |
| | | listLoding: false, |
| | | stairListLoading: false, |
| | | "startCheck.id": res.datas[0].id, |
| | | "startCheck..code": "", |
| | | }); |
| | | }); |
| | | this.setData({ |
| | | listLoding: false, |
| | | }); |
| | | }, |
| | | |
| | |
| | | let datas; |
| | | const query = { |
| | | path, |
| | | filterList: [], |
| | | queryType: '\\', |
| | | filterList: [{ |
| | | value: "Normal", |
| | | field: "state", |
| | | }, ], |
| | | coverSize: { |
| | | width: 500, |
| | | }, |
| | | queryType: "\\", |
| | | searchList: [], |
| | | size: '30', |
| | | start: '0', |
| | | size: "30", |
| | | start: "0", |
| | | storeRefCode: app.config.goodsStore, |
| | | sort: { type: 'Asc', field: 'LinkOrder' }, |
| | | sort: { |
| | | type: "Asc", |
| | | field: "LinkOrder" |
| | | }, |
| | | }; |
| | | await app.MG.store.getStoreChannelList(query).then((res) => { |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | const element = res.datas[index]; |
| | | if (element.icon) element.icon = getPublicImage(element.icon, 150); |
| | | } |
| | | datas = res.datas; |
| | | }); |
| | | return datas; |
| | | }, |
| | | tabClick(tabData) { |
| | | const data = tabData.currentTarget.dataset.tabdata; |
| | | tabClick(e) { |
| | | const data = e.currentTarget.dataset.tabdata; |
| | | this.setData({ |
| | | startCheck: data.refCode, |
| | | "startCheck.id": data.id, |
| | | "startCheck.code": data.refCode, |
| | | }); |
| | | }, |
| | | // 跳转列表页 |
| | | goPageList(item) { |
| | | const secondCode = `${item.currentTarget.dataset.staircode.pathLinks[0].linkPath}\\${item.currentTarget.dataset.staircode.id}`; |
| | | wx.navigateTo({ |
| | | url: `/pages/bookServices/list/index?assorName=${this.data.assortCheck.name}&assortCode=${this.data.assortCheck.code}&stairCode=${this.data.startCheck}&secondCode=${secondCode}`, |
| | | goPageList(e) { |
| | | const tab = e.currentTarget.dataset.tabdata; |
| | | const stair = e.currentTarget.dataset.stair; |
| | | this.setData({ |
| | | "startCheck.id": tab.id, |
| | | "startCheck.code": tab.refCode, |
| | | }); |
| | | if (stair) { |
| | | const secondCode = `${stair.pathLinks[0].linkPath}\\${stair.id}`; |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/list/index?assorName=${this.data.assortCheck.name}&assortCode=${this.data.assortCheck.code}&stairCode=${this.data.startCheck.code}&secondCode=${secondCode}`, |
| | | }); |
| | | } else { |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/list/index?assorName=${this.data.assortCheck.name}&assortCode=${this.data.assortCheck.code}`, |
| | | }); |
| | | } |
| | | }, |
| | | navToSearchPage(e) { |
| | | console.log(e.detail.value); |
| | | wx.navigateTo({ |
| | | url: `/pages/bookServices/list/index?assorName=${this.data.assortCheck.name}&assortCode=${this.data.assortCheck.code}&stairCode=${this.data.startCheck}&searchValue=${e.detail.value}`, |
| | | url: `/packageBookService/pages/bookServices/list/index?assorName=${this.data.assortCheck.name}&assortCode=${this.data.assortCheck.code}&stairCode=${this.data.startCheck.code}&searchValue=${e.detail.value}`, |
| | | }); |
| | | }, |
| | | }); |
| | | }); |