| | |
| | | const app = getApp(); |
| | | import { |
| | | loginInfo |
| | | } from '../../../../assets/js/login'; |
| | | Page({ |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | barHeight: '', |
| | | navBarHeight: '', |
| | | searchValue: '', |
| | | path: '', |
| | | barHeight: "", |
| | | navBarHeight: "", |
| | | searchValue: "", |
| | | path: "", |
| | | pathList: [], |
| | | pageCount: { |
| | | page: 1, |
| | |
| | | }, |
| | | isMore: null, |
| | | assortCheck: { |
| | | name: '', |
| | | code: '', |
| | | name: "", |
| | | code: "", |
| | | }, |
| | | bookList: [], |
| | | stairList: { |
| | | value: '', |
| | | options: [{ |
| | | value: '', |
| | | label: '一级', |
| | | }, ], |
| | | value: "", |
| | | options: [], |
| | | }, |
| | | secondList: { |
| | | value: [], |
| | |
| | | options: [], |
| | | }, |
| | | sortList: { |
| | | value: 'default', |
| | | value: "default", |
| | | options: [{ |
| | | value: 'default', |
| | | label: '默认排序', |
| | | }, { |
| | | value: 'name-asc', |
| | | label: '名称正序' |
| | | value: "default", |
| | | label: "默认排序", |
| | | }, |
| | | { |
| | | value: 'name-desc', |
| | | label: '名称倒叙' |
| | | value: "name-asc", |
| | | label: "名称正序", |
| | | }, |
| | | { |
| | | value: 'time-asc', |
| | | label: '出版时间正序' |
| | | value: "name-desc", |
| | | label: "名称倒叙", |
| | | }, |
| | | { |
| | | value: 'time-desc', |
| | | label: '出版时间倒叙' |
| | | } |
| | | value: "time-asc", |
| | | label: "出版时间正序", |
| | | }, |
| | | { |
| | | value: "time-desc", |
| | | label: "出版时间倒叙", |
| | | }, |
| | | ], |
| | | }, |
| | | newTextBook: { |
| | | value: [], |
| | | options: [], |
| | | }, |
| | | stairCode: '', // 一级分类选中项 |
| | | secondCode: '', // 二级分类选中项 |
| | | sort: '', // 排序 |
| | | stairCode: "", // 一级分类选中项 |
| | | secondCode: "", // 二级分类选中项 |
| | | sort: "", // 排序 |
| | | enable: false, |
| | | loadingProps: { |
| | | size: '50rpx' |
| | | size: "50rpx", |
| | | }, |
| | | loading: false, |
| | | noData: false, |
| | |
| | | disabledProject: false, |
| | | disabledNewForms: false, |
| | | triggered: false, |
| | | backTop: "", |
| | | isshowLoading: true |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | |
| | | onLoad(options) { |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | const navBarHeight = |
| | | (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | this.setData({ |
| | | barHeight: systInfo.statusBarHeight, |
| | | navBarHeight: navBarHeight, |
| | |
| | | // 一级分类和path赋值 |
| | | if (options.stairCode) { |
| | | this.setData({ |
| | | 'stairList.value': options.stairCode, |
| | | "stairList.value": options.stairCode, |
| | | stairCode: options.stairCode, |
| | | path: `${options.assortCode}\\${options.stairCode}`, |
| | | }); |
| | |
| | | secondCode: options.secondCode, |
| | | pathList: [{ |
| | | Path: options.secondCode, |
| | | Type: '*', |
| | | Type: "*", |
| | | StoreRefCode: app.config.goodsStore, |
| | | }], |
| | | }) |
| | | }, ], |
| | | }); |
| | | } |
| | | // 获取二级分类 |
| | | this.getSecondList(`${options.assortCode}\\${options.stairCode}`); |
| | | this.getBookList(`${options.assortCode}\\${options.stairCode}`); |
| | | // 获取重点项目 |
| | | this.getProjectList('bookClassification'); |
| | | this.getProjectList('newFormsTextbooks'); |
| | | this.getProjectList("bookClassification"); |
| | | this.getProjectList("newFormsTextbooks"); |
| | | }, |
| | | |
| | | /** |
| | |
| | | */ |
| | | onPullDownRefresh() { |
| | | this.setData({ |
| | | triggered: true |
| | | }) |
| | | triggered: true, |
| | | }); |
| | | this.setData({ |
| | | 'pageCount.page': 1 |
| | | }) |
| | | isshowLoading: false, |
| | | "pageCount.page": 1, |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | |
| | |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom(e) { |
| | | const flag = this.data.bookList.length < this.data.pageCount.total |
| | | const flag = this.data.bookList.length < this.data.pageCount.total; |
| | | if (flag) { |
| | | if (!this.data.isRequesting) { |
| | | this.setData({ |
| | | isMore: true, |
| | | "pageCount.page": this.data.pageCount.page + 1 |
| | | }) |
| | | this.getBookList(this.data.path) |
| | | "pageCount.page": this.data.pageCount.page + 1, |
| | | isshowLoading: false |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | } |
| | | } else { |
| | | this.setData({ |
| | | isMore: true, |
| | | }) |
| | | }); |
| | | setTimeout(() => { |
| | | this.setData({ |
| | | isMore: false |
| | | }) |
| | | }, 100) |
| | | console.log('没有更多了'); |
| | | isMore: false, |
| | | }); |
| | | }, 100); |
| | | } |
| | | }, |
| | | |
| | |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() {}, |
| | | onShareTimeline() {}, |
| | | goBack() { |
| | | wx.navigateBack(); |
| | | }, |
| | | // 获取一级列表 |
| | | getStairList(path) { |
| | | this.setData({ |
| | | disabledStair: false |
| | | }) |
| | | disabledStair: false, |
| | | }); |
| | | const query = { |
| | | path, |
| | | filterList: [], |
| | | queryType: '\\', |
| | | queryType: "\\", |
| | | searchList: [], |
| | | size: '30', |
| | | start: '0', |
| | | size: "30", |
| | | start: "0", |
| | | storeRefCode: app.config.goodsStore, |
| | | sort: { |
| | | type: 'Asc', |
| | | field: 'LinkOrder' |
| | | type: "Asc", |
| | | field: "LinkOrder", |
| | | }, |
| | | }; |
| | | app.MG.store.getStoreChannelList(query).then(async (res) => { |
| | | const options = [{ |
| | | value: '', |
| | | label: '一级', |
| | | value: "", |
| | | label: "一级分类", |
| | | }, ]; |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | const item = res.datas[index]; |
| | |
| | | }); |
| | | } |
| | | this.setData({ |
| | | 'stairList.options': options, |
| | | 'stairList.value': this.data.stairCode, |
| | | "stairList.options": options, |
| | | "stairList.value": this.data.stairCode, |
| | | }); |
| | | if (!options.length) { |
| | | this.setData({ |
| | | disabledStair: true |
| | | }) |
| | | disabledStair: true, |
| | | }); |
| | | } |
| | | }); |
| | | }, |
| | | // 获取一级分类下二级分类 |
| | | getSecondList(path) { |
| | | async getSecondList(path) { |
| | | const options = []; |
| | | const query = { |
| | | path, |
| | | filterList: [], |
| | | queryType: '\\', |
| | | queryType: "\\", |
| | | searchList: [], |
| | | size: '30', |
| | | start: '0', |
| | | size: "30", |
| | | start: "0", |
| | | storeRefCode: app.config.goodsStore, |
| | | sort: { |
| | | type: 'Asc', |
| | | field: 'LinkOrder' |
| | | type: "Asc", |
| | | 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({ |
| | |
| | | }); |
| | | } |
| | | this.setData({ |
| | | 'secondList.options': options, |
| | | "secondList.options": options, |
| | | }); |
| | | const second = [this.data.secondCode] |
| | | const second = [this.data.secondCode]; |
| | | console.log(second); |
| | | this.setData({ |
| | | 'secondList.value': second |
| | | }) |
| | | "secondList.value": second, |
| | | }); |
| | | }); |
| | | }, |
| | | // 获取重点项目 |
| | | getProjectList(type) { |
| | | this.setData({ |
| | | disabledProject: false, |
| | | disabledNewForms: false |
| | | }) |
| | | disabledNewForms: false, |
| | | }); |
| | | const options = []; |
| | | const arr = []; |
| | | let array = []; |
| | |
| | | refCodes: [type], |
| | | }; |
| | | app.MG.store.getProductTypeField(query).then((res) => { |
| | | array = JSON.parse(res[0].config).option.filter(item => item.value == this.data.assortCheck.code); |
| | | array = JSON.parse(res[0].config).option.filter( |
| | | (item) => item.value == this.data.assortCheck.code |
| | | ); |
| | | for (let index = 0; index < array.length; index++) { |
| | | const element = array[index]; |
| | | if (element.child) { |
| | |
| | | } |
| | | } |
| | | } |
| | | if (type == 'bookClassification') { |
| | | if (type == "bookClassification") { |
| | | for (let index = 0; index < arr.length; index++) { |
| | | const element = arr[index]; |
| | | options.push({ |
| | |
| | | } |
| | | if (!options.length) { |
| | | this.setData({ |
| | | disabledProject: true |
| | | }) |
| | | disabledProject: true, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | 'majorProjectList.options': options, |
| | | "majorProjectList.options": options, |
| | | }); |
| | | } else if (type == 'newFormsTextbooks') { |
| | | } else if (type == "newFormsTextbooks") { |
| | | for (let index = 0; index < arr.length; index++) { |
| | | const element = arr[index]; |
| | | options.push({ |
| | |
| | | } |
| | | if (!options.length) { |
| | | this.setData({ |
| | | disabledNewForms: true |
| | | }) |
| | | disabledNewForms: true, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | 'newTextBook.options': options, |
| | | "newTextBook.options": options, |
| | | }); |
| | | console.log('重点项目', this.data.newTextBook); |
| | | console.log("重点项目", this.data.newTextBook); |
| | | } |
| | | }); |
| | | }, |
| | |
| | | return false; |
| | | } |
| | | this.setData({ |
| | | loading: true, |
| | | noData: false, |
| | | isRequesting: true |
| | | }) |
| | | isRequesting: true, |
| | | disabledSecondList: false |
| | | }); |
| | | if (this.data.isshowLoading) { |
| | | this.setData({ |
| | | loading: true |
| | | }) |
| | | } |
| | | let sort; |
| | | let pathObj = {}; |
| | | if (this.data.pathList.length) { |
| | |
| | | } else { |
| | | pathObj = { |
| | | path, |
| | | queryType: '*', |
| | | queryType: "*", |
| | | }; |
| | | } |
| | | if (this.data.sortList.value == 'name-asc') { |
| | | if (this.data.sortList.value == "name-asc") { |
| | | sort = { |
| | | Name: 'Asc', |
| | | BaseType: '' |
| | | } |
| | | } else if (this.data.sortList.value == 'name-desc') { |
| | | Name: "Asc", |
| | | BaseType: "", |
| | | }; |
| | | } else if (this.data.sortList.value == "name-desc") { |
| | | sort = { |
| | | Name: 'Desc', |
| | | BaseType: '' |
| | | } |
| | | } else if (this.data.sortList.value == 'time-asc') { |
| | | Name: "Desc", |
| | | BaseType: "", |
| | | }; |
| | | } else if (this.data.sortList.value == "time-asc") { |
| | | sort = { |
| | | PublicationDate: 'Asc', |
| | | BaseType: 'DateTime' |
| | | } |
| | | } else if (this.data.sortList.value == 'time-desc') { |
| | | PublicationDate: "Asc", |
| | | BaseType: "DateTime", |
| | | }; |
| | | } else if (this.data.sortList.value == "time-desc") { |
| | | sort = { |
| | | PublicationDate: 'Desc', |
| | | BaseType: 'DateTime' |
| | | } |
| | | } else if (this.data.sortList.value == 'default') { |
| | | PublicationDate: "Desc", |
| | | BaseType: "DateTime", |
| | | }; |
| | | } else if (this.data.sortList.value == "default") { |
| | | sort = { |
| | | field: 'order', |
| | | type: 'Desc' |
| | | } |
| | | field: "order", |
| | | type: "Desc", |
| | | }; |
| | | } |
| | | // if (this.data.sort) { |
| | | // sort = { |
| | |
| | | let searchObj = {}; |
| | | if (this.data.searchValue) { |
| | | searchObj = { |
| | | 'Name*': this.data.searchValue, |
| | | '||author*': this.data.searchValue, |
| | | '||isbn*': this.data.searchValue, |
| | | '||seriesName*': this.data.searchValue, |
| | | "Name*": this.data.searchValue, |
| | | "||author*": this.data.searchValue, |
| | | "||isbn*": this.data.searchValue, |
| | | "||seriesName*": this.data.searchValue, |
| | | "||projectLeader*": this.data.searchValue |
| | | }; |
| | | } |
| | | const query = { |
| | | ...pathObj, |
| | | filterList: [{ |
| | | value: 'Normal', |
| | | field: 'state', |
| | | value: "Normal", |
| | | field: "state", |
| | | }, ], |
| | | sort, |
| | | coverSize: { |
| | | width: 180 |
| | | }, |
| | | paging: { |
| | | start: 0, |
| | | size: this.data.pageCount.page * 8, |
| | |
| | | author: [], |
| | | publicationDate: [], |
| | | ...searchObj, |
| | | 'bookClassification*': this.data.majorProjectList.value, |
| | | 'newFormsTextbooks*': this.data.newTextBook.value, |
| | | "bookClassification*": this.data.majorProjectList.value, |
| | | "newFormsTextbooks*": this.data.newTextBook.value, |
| | | }, |
| | | }; |
| | | app.MG.store.getProductList(query).then((res) => { |
| | | this.setData({ |
| | | bookList: res.datas, |
| | | isMore: null, |
| | | enable: false, |
| | | "pageCount.total": res.total, |
| | | loading: false, |
| | | isRequesting: 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({ |
| | | triggered: false |
| | | }) |
| | | triggered: false, |
| | | }); |
| | | wx.showToast({ |
| | | title: '刷新成功', |
| | | }) |
| | | title: "刷新成功", |
| | | }); |
| | | } |
| | | }); |
| | | }, |
| | | // 一级分类切换 |
| | | onChangeStair(e) { |
| | | async onChangeStair(e) { |
| | | const path = e.detail.value.length ? |
| | | `${this.data.assortCheck.code}\\${e.detail.value}` : |
| | | this.data.assortCheck.code; |
| | | console.log(this.data.path); |
| | | |
| | | this.setData({ |
| | | backTop: "#assort-title", |
| | | pathList: [], |
| | | stairCode: e.detail.value, |
| | | secondCode: '', |
| | | secondCode: "", |
| | | path: path, |
| | | 'stairList.value': e.detail.value, |
| | | "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.push({ |
| | | Path: element, |
| | | Type: '*', |
| | | Type: "*", |
| | | StoreRefCode: app.config.goodsStore, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | backTop: "#assort-title", |
| | | pathList: pathList, |
| | | 'secondList.value': e.detail.value, |
| | | "secondList.value": e.detail.value, |
| | | }); |
| | | }, |
| | | // |
| | | onConfirmSecond() { |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | // 重点项目改变 |
| | | changeMajorProject(e) { |
| | | this.setData({ |
| | | 'majorProjectList.value': e.detail.value, |
| | | backTop: "#assort-title", |
| | | "majorProjectList.value": e.detail.value, |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | // 重点项目重置 |
| | | resetMajorProject() { |
| | | this.setData({ |
| | | 'majorProjectList.value': [], |
| | | "majorProjectList.value": [], |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | // 排序切换 |
| | | onSortChange(e) { |
| | | this.setData({ |
| | | 'sortList.value': e.detail.value |
| | | }) |
| | | backTop: "#assort-title", |
| | | "sortList.value": e.detail.value, |
| | | }); |
| | | |
| | | let path; |
| | | if (this.data.secondCode) { |
| | |
| | | }); |
| | | this.getBookList(path); |
| | | }, |
| | | // 新形态教材改变 |
| | | changeNewText(e) { |
| | | this.setData({ |
| | | 'newTextBook.value': e.detail.value, |
| | | backTop: "#assort-title", |
| | | "newTextBook.value": e.detail.value, |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | resetNewText() { |
| | | this.setData({ |
| | | 'newTextBook.value': [], |
| | | "newTextBook.value": [], |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | |
| | | // }, |
| | | // 搜索图书 |
| | | searchBook(e) { |
| | | console.log(e.detail.value); |
| | | this.setData({ |
| | | backTop: "#assort-title", |
| | | searchValue: e.detail.value, |
| | | }); |
| | | this.getBookList(this.data.path); |
| | |
| | | }, |
| | | onRefresh() { |
| | | this.setData({ |
| | | enable: true |
| | | enable: true, |
| | | }); |
| | | this.getBookList(this.data.path) |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | openDropdown() { |
| | | console.log('展开哦', ); |
| | | this.setData({ |
| | | showDropdown: true |
| | | }) |
| | | showDropdown: true, |
| | | }); |
| | | }, |
| | | closeDropdown() { |
| | | console.log('关闭'); |
| | | this.setData({ |
| | | showDropdown: false |
| | | }) |
| | | } |
| | | showDropdown: false, |
| | | }); |
| | | }, |
| | | }); |