| | |
| | | const app = getApp(); |
| | | import { loginInfo } from "../../../../assets/js/login"; |
| | | Page({ |
| | | /** |
| | | * 页面的初始数据 |
| | |
| | | bookList: [], |
| | | stairList: { |
| | | value: "", |
| | | options: [ |
| | | { |
| | | value: "", |
| | | label: "一级", |
| | | }, |
| | | ], |
| | | options: [], |
| | | }, |
| | | secondList: { |
| | | value: [], |
| | |
| | | }, |
| | | sortList: { |
| | | value: "default", |
| | | options: [ |
| | | { |
| | | options: [{ |
| | | value: "default", |
| | | label: "默认排序", |
| | | }, |
| | |
| | | disabledNewForms: false, |
| | | triggered: false, |
| | | backTop: "", |
| | | isshowLoading: true |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | |
| | | if (options.secondCode) { |
| | | this.setData({ |
| | | secondCode: options.secondCode, |
| | | pathList: [ |
| | | { |
| | | Path: options.secondCode, |
| | | Type: "*", |
| | | StoreRefCode: app.config.goodsStore, |
| | | }, |
| | | ], |
| | | pathList: [{ |
| | | Path: options.secondCode, |
| | | Type: "*", |
| | | StoreRefCode: app.config.goodsStore, |
| | | }, ], |
| | | }); |
| | | } |
| | | // 获取二级分类 |
| | |
| | | triggered: true, |
| | | }); |
| | | this.setData({ |
| | | isshowLoading: false, |
| | | "pageCount.page": 1, |
| | | }); |
| | | this.getBookList(this.data.path); |
| | |
| | | this.setData({ |
| | | isMore: true, |
| | | "pageCount.page": this.data.pageCount.page + 1, |
| | | isshowLoading: false |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | } |
| | |
| | | }, |
| | | }; |
| | | app.MG.store.getStoreChannelList(query).then(async (res) => { |
| | | const options = [ |
| | | { |
| | | value: "", |
| | | label: "一级", |
| | | }, |
| | | ]; |
| | | const options = [{ |
| | | value: "", |
| | | label: "一级分类", |
| | | }, ]; |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | const item = res.datas[index]; |
| | | options.push({ |
| | |
| | | }); |
| | | }, |
| | | // 获取一级分类下二级分类 |
| | | getSecondList(path) { |
| | | async getSecondList(path) { |
| | | const options = []; |
| | | const query = { |
| | | path, |
| | |
| | | field: "LinkOrder", |
| | | }, |
| | | }; |
| | | app.MG.store.getStoreChannelList(query).then((res) => { |
| | | if (!res.datas.length) { |
| | | this.setData({ |
| | | disabledSecondList: true, |
| | | }); |
| | | } else { |
| | | this.setData({ |
| | | disabledSecondList: false, |
| | | }); |
| | | } |
| | | await app.MG.store.getStoreChannelList(query).then((res) => { |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | const item = res.datas[index]; |
| | | options.push({ |
| | |
| | | "secondList.options": options, |
| | | }); |
| | | const second = [this.data.secondCode]; |
| | | console.log(second); |
| | | this.setData({ |
| | | "secondList.value": second, |
| | | }); |
| | |
| | | return false; |
| | | } |
| | | this.setData({ |
| | | loading: true, |
| | | noData: false, |
| | | isRequesting: true, |
| | | disabledSecondList: false |
| | | }); |
| | | if (this.data.isshowLoading) { |
| | | this.setData({ |
| | | loading: true |
| | | }) |
| | | } |
| | | let sort; |
| | | let pathObj = {}; |
| | | if (this.data.pathList.length) { |
| | |
| | | "||author*": this.data.searchValue, |
| | | "||isbn*": this.data.searchValue, |
| | | "||seriesName*": this.data.searchValue, |
| | | "||projectLeader*": this.data.searchValue |
| | | }; |
| | | } |
| | | const query = { |
| | | ...pathObj, |
| | | filterList: [ |
| | | { |
| | | value: "Normal", |
| | | field: "state", |
| | | }, |
| | | ], |
| | | filterList: [{ |
| | | value: "Normal", |
| | | field: "state", |
| | | }, ], |
| | | sort, |
| | | coverSize: { |
| | | width: 180 |
| | | }, |
| | | paging: { |
| | | start: 0, |
| | | size: this.data.pageCount.page * 8, |
| | |
| | | "pageCount.total": res.total, |
| | | loading: false, |
| | | isRequesting: false, |
| | | isshowLoading: true |
| | | }); |
| | | if (!res.datas.length) { |
| | | this.setData({ |
| | | noData: true, |
| | | }); |
| | | } |
| | | // 二级禁用逻辑 |
| | | // 1.一级分类未选中,二级分类禁用 |
| | | if (!this.data.stairList.value) { |
| | | this.setData({ |
| | | disabledSecondList: true |
| | | }) |
| | | } else if (this.data.stairList.value && !this.data.secondList.options.length) { |
| | | // 2. 一级分类选中,无二级分类 |
| | | this.setData({ |
| | | disabledSecondList: true |
| | | }) |
| | | } |
| | | if (this.data.triggered) { |
| | | this.setData({ |
| | |
| | | }); |
| | | }, |
| | | // 一级分类切换 |
| | | onChangeStair(e) { |
| | | const path = e.detail.value.length |
| | | ? `${this.data.assortCheck.code}\\${e.detail.value}` |
| | | : this.data.assortCheck.code; |
| | | console.log(this.data.path); |
| | | |
| | | async onChangeStair(e) { |
| | | const path = e.detail.value.length ? |
| | | `${this.data.assortCheck.code}\\${e.detail.value}` : |
| | | this.data.assortCheck.code; |
| | | this.setData({ |
| | | backTop: "#assort-title", |
| | | pathList: [], |
| | |
| | | secondCode: "", |
| | | path: path, |
| | | "stairList.value": e.detail.value, |
| | | // disabledSecondList: false |
| | | }); |
| | | |
| | | if (e.detail.value == "") { |
| | | this.setData({ |
| | | disabledSecondList: true, |
| | | }); |
| | | } else { |
| | | this.getSecondList(path); |
| | | } |
| | | this.getBookList(path); |
| | | console.log(this.data.disabledSecondList); |
| | | // if (e.detail.value == "") { |
| | | // this.setData({ |
| | | // disabledSecondList: true, |
| | | // }); |
| | | // } else { |
| | | await this.getSecondList(path); |
| | | // } |
| | | await this.getBookList(path); |
| | | }, |
| | | // 二级分类切换 |
| | | onChangeSecond(e) { |
| | | // // 二级分类切换 |
| | | // onChangeSecond(e) { |
| | | // const pathList = []; |
| | | // for (let index = 0; index < e.detail.value.length; index++) { |
| | | // const element = e.detail.value[index]; |
| | | // pathList.push({ |
| | | // Path: element, |
| | | // Type: "*", |
| | | // StoreRefCode: app.config.goodsStore, |
| | | // }); |
| | | // } |
| | | // this.setData({ |
| | | // backTop: "#assort-title", |
| | | // pathList: pathList, |
| | | // "secondList.value": e.detail.value, |
| | | // }); |
| | | // }, |
| | | // 二级分类重置 |
| | | resetSecond() { |
| | | this.setData({ |
| | | backTop: "#assort-title", |
| | | pathList: [], |
| | | "secondList.value": [], |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | // 二级分类确定 |
| | | onConfirmSecond(e) { |
| | | const pathList = []; |
| | | for (let index = 0; index < e.detail.value.length; index++) { |
| | | const element = e.detail.value[index]; |
| | |
| | | pathList: pathList, |
| | | "secondList.value": e.detail.value, |
| | | }); |
| | | }, |
| | | // |
| | | onConfirmSecond() { |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | // 重点项目改变 |
| | |
| | | }, |
| | | // 跳转图书详情 |
| | | goDetail(e) { |
| | | const { book } = e.currentTarget.dataset; |
| | | const { |
| | | book |
| | | } = e.currentTarget.dataset; |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/detail/index?id=${book.id}&name=${book.name}`, |
| | | }); |
| | |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | openDropdown() { |
| | | console.log("展开哦"); |
| | | this.setData({ |
| | | showDropdown: true, |
| | | }); |
| | | }, |
| | | closeDropdown() { |
| | | console.log("关闭"); |
| | | this.setData({ |
| | | showDropdown: false, |
| | | }); |
| | | }, |
| | | }); |
| | | }); |