| | |
| | | const app = getApp(); |
| | | import { loginInfo } from '../../../../assets/js/login'; |
| | | import { |
| | | loginInfo |
| | | } from '../../../../assets/js/login'; |
| | | Page({ |
| | | /** |
| | | * 页面的初始数据 |
| | |
| | | bookList: [], |
| | | stairList: { |
| | | value: '', |
| | | options: [ |
| | | { |
| | | value: '', |
| | | label: '一级', |
| | | }, |
| | | ], |
| | | options: [{ |
| | | value: '', |
| | | label: '一级', |
| | | }, ], |
| | | }, |
| | | secondList: { |
| | | value: [], |
| | | options: [], |
| | | disabled: false, |
| | | }, |
| | | majorProjectList: { |
| | | value: [], |
| | | options: [], |
| | | }, |
| | | sortList: { |
| | | value: 'default', |
| | | options: [{ |
| | | value: 'default', |
| | | label: '默认排序', |
| | | }, { |
| | | value: 'name-asc', |
| | | label: '名称正序' |
| | | }, |
| | | { |
| | | value: 'name-desc', |
| | | label: '名称倒叙' |
| | | }, |
| | | { |
| | | value: 'time-asc', |
| | | label: '出版时间正序' |
| | | }, |
| | | { |
| | | value: 'time-desc', |
| | | label: '出版时间倒叙' |
| | | } |
| | | ], |
| | | }, |
| | | newTextBook: { |
| | | value: [], |
| | |
| | | size: '50rpx' |
| | | }, |
| | | loading: false, |
| | | noData: false |
| | | noData: false, |
| | | showDropdown: false, |
| | | isRequesting: false, |
| | | disabledStair: false, |
| | | disabledSecondList: false, |
| | | disabledProject: false, |
| | | disabledNewForms: false, |
| | | triggered: false, |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | |
| | | Path: options.secondCode, |
| | | Type: '*', |
| | | StoreRefCode: app.config.goodsStore, |
| | | } |
| | | ], |
| | | }], |
| | | }) |
| | | } |
| | | // 获取二级分类 |
| | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | }, |
| | | onReady() {}, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | }, |
| | | onShow() {}, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { }, |
| | | onHide() {}, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload() { }, |
| | | onUnload() {}, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | console.log('下拉'); |
| | | this.setData({ |
| | | triggered: true |
| | | }) |
| | | this.setData({ |
| | | 'pageCount.page': 1 |
| | | }) |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | |
| | | /** |
| | |
| | | onReachBottom(e) { |
| | | const flag = this.data.bookList.length < this.data.pageCount.total |
| | | if (flag) { |
| | | this.setData({ |
| | | isMore: true, |
| | | "pageCount.page": this.data.pageCount.page + 1 |
| | | }) |
| | | this.getBookList(this.data.path) |
| | | if (!this.data.isRequesting) { |
| | | this.setData({ |
| | | isMore: true, |
| | | "pageCount.page": this.data.pageCount.page + 1 |
| | | }) |
| | | this.getBookList(this.data.path) |
| | | } |
| | | } else { |
| | | this.setData({ |
| | | isMore: true, |
| | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { }, |
| | | onShareAppMessage() {}, |
| | | goBack() { |
| | | wx.navigateBack(); |
| | | }, |
| | | // 获取一级列表 |
| | | getStairList(path) { |
| | | this.setData({ |
| | | disabledStair: false |
| | | }) |
| | | const query = { |
| | | path, |
| | | filterList: [], |
| | |
| | | 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) => { |
| | | const options = [ |
| | | { |
| | | value: '', |
| | | label: '一级', |
| | | }, |
| | | ]; |
| | | const options = [{ |
| | | value: '', |
| | | label: '一级', |
| | | }, ]; |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | const item = res.datas[index]; |
| | | options.push({ |
| | |
| | | 'stairList.options': options, |
| | | 'stairList.value': this.data.stairCode, |
| | | }); |
| | | if (!options.length) { |
| | | this.setData({ |
| | | disabledStair: true |
| | | }) |
| | | } |
| | | }); |
| | | }, |
| | | // 获取一级分类下二级分类 |
| | |
| | | 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) => { |
| | | if (!res.datas.length) { |
| | | this.setData({ |
| | | disabledSecondList: true |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | disabledSecondList: false |
| | | }) |
| | | } |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | const item = res.datas[index]; |
| | | options.push({ |
| | |
| | | }, |
| | | // 获取重点项目 |
| | | getProjectList(type) { |
| | | this.setData({ |
| | | disabledProject: 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; |
| | | 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) { |
| | |
| | | label: element.name, |
| | | }); |
| | | } |
| | | if (!options.length) { |
| | | this.setData({ |
| | | disabledProject: true |
| | | }) |
| | | } |
| | | this.setData({ |
| | | 'majorProjectList.options': options, |
| | | }); |
| | |
| | | label: element.name, |
| | | }); |
| | | } |
| | | if (!options.length) { |
| | | this.setData({ |
| | | disabledNewForms: true |
| | | }) |
| | | } |
| | | this.setData({ |
| | | 'newTextBook.options': options, |
| | | }); |
| | |
| | | }, |
| | | // 获取图书列表 |
| | | getBookList(path) { |
| | | if (this.data.isRequesting) { |
| | | return false; |
| | | } |
| | | this.setData({ |
| | | loading: true, |
| | | noData: false |
| | | noData: false, |
| | | isRequesting: true |
| | | }) |
| | | let sort; |
| | | let pathObj = {}; |
| | |
| | | queryType: '*', |
| | | }; |
| | | } |
| | | if (this.data.sort) { |
| | | if (this.data.sortList.value == 'name-asc') { |
| | | sort = { |
| | | Name: this.data.sort, |
| | | BaseType: '', |
| | | }; |
| | | } else { |
| | | Name: 'Asc', |
| | | BaseType: '' |
| | | } |
| | | } else if (this.data.sortList.value == 'name-desc') { |
| | | sort = { |
| | | type: 'Desc', |
| | | field: 'ViewCount', |
| | | }; |
| | | Name: 'Desc', |
| | | BaseType: '' |
| | | } |
| | | } else if (this.data.sortList.value == 'time-asc') { |
| | | sort = { |
| | | PublicationDate: 'Asc', |
| | | BaseType: 'DateTime' |
| | | } |
| | | } else if (this.data.sortList.value == 'time-desc') { |
| | | sort = { |
| | | PublicationDate: 'Desc', |
| | | BaseType: 'DateTime' |
| | | } |
| | | } else if (this.data.sortList.value == 'default') { |
| | | sort = { |
| | | field: 'order', |
| | | type: 'Desc' |
| | | } |
| | | } |
| | | // if (this.data.sort) { |
| | | // sort = { |
| | | // Name: this.data.sort, |
| | | // BaseType: '', |
| | | // }; |
| | | // } else { |
| | | // sort = { |
| | | // type: 'Desc', |
| | | // field: 'ViewCount', |
| | | // }; |
| | | // } |
| | | // 搜索 |
| | | let searchObj = {}; |
| | | if (this.data.searchValue) { |
| | |
| | | } |
| | | const query = { |
| | | ...pathObj, |
| | | filterList: [ |
| | | { |
| | | value: 'Normal', |
| | | field: 'state', |
| | | }, |
| | | ], |
| | | filterList: [{ |
| | | value: 'Normal', |
| | | field: 'state', |
| | | }, ], |
| | | sort, |
| | | paging: { |
| | | start: 0, |
| | |
| | | bookList: res.datas, |
| | | enable: false, |
| | | "pageCount.total": res.total, |
| | | loading: false |
| | | loading: false, |
| | | isRequesting: false |
| | | }); |
| | | console.log('图书列表', res.datas); |
| | | if (!res.datas.length) { |
| | | this.setData({ |
| | | noData: true |
| | | noData: true, |
| | | }) |
| | | } |
| | | if (this.data.triggered) { |
| | | this.setData({ |
| | | triggered: false |
| | | }) |
| | | wx.showToast({ |
| | | title: '刷新成功', |
| | | }) |
| | | } |
| | | }); |
| | | }, |
| | | // 一级分类切换 |
| | | onChangeStair(e) { |
| | | const path = e.detail.value.length |
| | | ? `${this.data.assortCheck.code}\\${e.detail.value}` |
| | | : this.data.assortCheck.code; |
| | | const path = e.detail.value.length ? |
| | | `${this.data.assortCheck.code}\\${e.detail.value}` : |
| | | this.data.assortCheck.code; |
| | | console.log(this.data.path); |
| | | |
| | | this.setData({ |
| | | pathList: [], |
| | | stairCode: e.detail.value, |
| | |
| | | path: path, |
| | | 'stairList.value': e.detail.value, |
| | | }); |
| | | |
| | | if (e.detail.value == '') { |
| | | this.setData({ |
| | | disabledSecondList: true |
| | | }); |
| | | } else { |
| | | this.getSecondList(path); |
| | | } |
| | | this.getBookList(path); |
| | | this.getSecondList(path); |
| | | console.log(this.data.disabledSecondList); |
| | | }, |
| | | // 二级分类切换 |
| | | onChangeSecond(e) { |
| | |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | changeNewText(e) { |
| | | // 排序切换 |
| | | onSortChange(e) { |
| | | this.setData({ |
| | | 'newTextBook.value': e.detail.value, |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | resetNewText() { |
| | | this.setData({ |
| | | 'newTextBook.value': [], |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | // 排序按钮 |
| | | sortClick() { |
| | | if (!this.data.sort.length) { |
| | | this.setData({ |
| | | sort: 'Desc', |
| | | }); |
| | | } else if (this.data.sort == 'Desc') { |
| | | this.setData({ |
| | | sort: 'Asc', |
| | | }); |
| | | } else if (this.data.sort == 'Asc') { |
| | | this.setData({ |
| | | sort: '', |
| | | }); |
| | | } |
| | | 'sortList.value': e.detail.value |
| | | }) |
| | | |
| | | let path; |
| | | if (this.data.secondCode) { |
| | | path = this.data.secondCode; |
| | |
| | | }); |
| | | this.getBookList(path); |
| | | }, |
| | | changeNewText(e) { |
| | | this.setData({ |
| | | 'newTextBook.value': e.detail.value, |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | resetNewText() { |
| | | this.setData({ |
| | | 'newTextBook.value': [], |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | // 排序按钮 |
| | | // sortClick() { |
| | | // if (!this.data.sort.length) { |
| | | // this.setData({ |
| | | // sort: 'Desc', |
| | | // }); |
| | | // } else if (this.data.sort == 'Desc') { |
| | | // this.setData({ |
| | | // sort: 'Asc', |
| | | // }); |
| | | // } else if (this.data.sort == 'Asc') { |
| | | // this.setData({ |
| | | // sort: '', |
| | | // }); |
| | | // } |
| | | // let path; |
| | | // if (this.data.secondCode) { |
| | | // path = this.data.secondCode; |
| | | // } else if (this.data.stairCode) { |
| | | // path = `${this.data.assortCheck.code}\\${this.data.stairCode}`; |
| | | // } else { |
| | | // path = this.data.assortCheck.code; |
| | | // } |
| | | // this.setData({ |
| | | // path: path, |
| | | // }); |
| | | // this.getBookList(path); |
| | | // }, |
| | | // 搜索图书 |
| | | searchBook(e) { |
| | | console.log(e.detail.value); |
| | |
| | | }, |
| | | // 跳转图书详情 |
| | | 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}`, |
| | | }); |
| | | }, |
| | | onRefresh() { |
| | | this.setData({ enable: true }); |
| | | this.setData({ |
| | | enable: true |
| | | }); |
| | | this.getBookList(this.data.path) |
| | | }, |
| | | }); |
| | | openDropdown() { |
| | | console.log('展开哦', ); |
| | | this.setData({ |
| | | showDropdown: true |
| | | }) |
| | | }, |
| | | closeDropdown() { |
| | | console.log('关闭'); |
| | | this.setData({ |
| | | showDropdown: false |
| | | }) |
| | | } |
| | | }); |