| | |
| | | userInfo: null, |
| | | path: '*', |
| | | pathList: [], |
| | | |
| | | bookList: [], |
| | | //高级分类 |
| | | iconList: { |
| | |
| | | //一级分类 |
| | | stairList: { |
| | | value: '', |
| | | options: [], |
| | | options: [{ |
| | | value: "", |
| | | label: "一级分类", |
| | | }], |
| | | }, |
| | | //二级分类 |
| | | secondList: { |
| | | value: [], |
| | | options: [], |
| | | }, |
| | | //重点项目 |
| | | majorProjectList: { |
| | | value: [], |
| | | options: [], |
| | | }, |
| | | //新形态教材 |
| | | newTextBook: { |
| | | value: [], |
| | | options: [], |
| | | }, |
| | |
| | | name: '', |
| | | code: '', |
| | | }, |
| | | |
| | | stairCode: '', // 一级分类选中项 |
| | | secondCode: '', // 二级分类选中项 |
| | | sort: '', // 排序 |
| | | sortList: { |
| | | value: "default", |
| | | options: [{ |
| | | value: "default", |
| | | label: "默认排序", |
| | | }, |
| | | { |
| | | value: "name-asc", |
| | | label: "名称正序", |
| | | }, |
| | | { |
| | | value: "name-desc", |
| | | label: "名称倒叙", |
| | | }, |
| | | { |
| | | value: "time-asc", |
| | | label: "出版时间正序", |
| | | }, |
| | | { |
| | | value: "time-desc", |
| | | label: "出版时间倒叙", |
| | | }, |
| | | ], |
| | | }, |
| | | //分页 |
| | | page: 1, |
| | | limit: 10, |
| | |
| | | paperBookCount: 0, //纸质书剩余次数 |
| | | ebookCount: 0, //电子书剩余次数 |
| | | num: 0, |
| | | x: 280, |
| | | y: 300, |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | let that = this; |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | this.setData({ |
| | | that.setData({ |
| | | barHeight: systInfo.statusBarHeight, |
| | | navBarHeight: navBarHeight, |
| | | }); |
| | | // 搜索赋值 |
| | | if (options && options.searchValue) { |
| | | this.setData({ |
| | | that.setData({ |
| | | searchValue: options.searchValue, |
| | | }); |
| | | } |
| | | // 高级分类赋值 |
| | | if (options && options.assortCode) { |
| | | this.setData({ |
| | | that.setData({ |
| | | assortCheck: { |
| | | name: options.assorName, |
| | | code: options.assortCode, |
| | |
| | | }, |
| | | }); |
| | | } |
| | | if (this.data.assortCheck.code) { |
| | | if (that.data.assortCheck.code) { |
| | | // 获取一级分类 |
| | | this.getStairList(this.data.assortCheck.code); |
| | | ththatis.getStairList(that.data.assortCheck.code); |
| | | } |
| | | // 一级分类和path赋值 |
| | | if (options && options.assortCode && options.stairCode) { |
| | | this.setData({ |
| | | that.setData({ |
| | | 'stairList.value': options.stairCode, |
| | | stairCode: options.stairCode, |
| | | path: `${options.assortCode}\\${options.stairCode}`, |
| | |
| | | } |
| | | // 二级分类赋值 |
| | | if (options && options.secondCode) { |
| | | this.setData({ |
| | | that.setData({ |
| | | secondCode: options.secondCode, |
| | | pathList: [{ |
| | | Path: options.secondCode, |
| | |
| | | }], |
| | | }) |
| | | } |
| | | this.getIconTypeList(); |
| | | // 获取重点项目 |
| | | this.getProjectList('bookClassification'); |
| | | //新形态教材 |
| | | this.getProjectList('newFormsTextbooks'); |
| | | that.getIconTypeList(); |
| | | |
| | | // 检查登录状态 |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | if (data) { |
| | | this.setData({ |
| | | that.setData({ |
| | | userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)) |
| | | }) |
| | | this.getAlreadyPBookList() |
| | | this.getAlreadyEBookList() |
| | | that.getAlreadyPBookList() |
| | | that.getAlreadyEBookList() |
| | | // 获取申请次数 |
| | | this.getSelectPaperBookCount() |
| | | this.getSelectBookCount() |
| | | that.getSelectPaperBookCount() |
| | | that.getSelectBookCount() |
| | | |
| | | } |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | that.setData({ |
| | | userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)) |
| | | }) |
| | | this.getAlreadyPBookList() |
| | | this.getAlreadyEBookList() |
| | | // 获取申请次数 |
| | | this.getSelectPaperBookCount() |
| | | this.getSelectBookCount() |
| | | |
| | | } |
| | | }, |
| | | |
| | |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | if (wx.getStorageSync("paperBookList")) { |
| | | this.setData({ |
| | | paperBookList: wx.getStorageSync("paperBookList"), |
| | | }) |
| | | } |
| | | if (wx.getStorageSync("electronicBookList")) { |
| | | this.setData({ |
| | | electronicBookList: wx.getStorageSync("electronicBookList"), |
| | | }) |
| | | } |
| | | this.setData({ |
| | | num: this.data.paperBookList.length + this.data.electronicBookList.length |
| | | let that = this; |
| | | that.setData({ |
| | | page: 1, |
| | | paperBookList: [], |
| | | electronicBookList: [] |
| | | }) |
| | | this.getBookList(false); |
| | | that.getAlreadyPBookList() |
| | | that.getAlreadyEBookList() |
| | | // 获取申请次数 |
| | | that.getSelectPaperBookCount() |
| | | that.getSelectBookCount() |
| | | if (wx.getStorageSync("paperBookList") || wx.getStorageSync("electronicBookList")) { |
| | | if (wx.getStorageSync("paperBookList")) { |
| | | that.setData({ |
| | | paperBookList: JSON.parse(wx.getStorageSync("paperBookList")), |
| | | }) |
| | | } |
| | | if (wx.getStorageSync("electronicBookList")) { |
| | | that.setData({ |
| | | electronicBookList: JSON.parse(wx.getStorageSync("electronicBookList")), |
| | | }) |
| | | } |
| | | that.setData({ |
| | | num: Number(that.data.paperBookList.length) + Number(that.data.electronicBookList.length) |
| | | }) |
| | | } |
| | | that.getBookList(false); |
| | | }, |
| | | goBack() { |
| | | wx.navigateBack(); |
| | | }, |
| | | |
| | | // 获取纸质书剩余次数 |
| | | getSelectPaperBookCount(item) { |
| | | getSelectPaperBookCount() { |
| | | app.MG.app |
| | | .getTicketResult({ |
| | | ticketRefCodeOrGuid: 'paperSampleBookapplyNum', |
| | |
| | | }) |
| | | }, |
| | | // 获取电子书剩余次数 |
| | | getSelectBookCount(item) { |
| | | getSelectBookCount() { |
| | | app.MG.app |
| | | .getTicketResult({ |
| | | ticketRefCodeOrGuid: 'electronicSampleBookapplyNum', |
| | |
| | | } |
| | | } |
| | | app.MG.store.getStoreChannelList(query).then((res) => { |
| | | let list = []; |
| | | let list = [{ |
| | | value: "", |
| | | label: "总分类", |
| | | }]; |
| | | if (res.datas.length > 0)( |
| | | res.datas.forEach((item) => { |
| | | item.value = item.refCode; |
| | |
| | | ) |
| | | this.setData({ |
| | | 'iconList.options': list, |
| | | 'iconList.value': this.data.assortCode, |
| | | 'iconList.value': this.data.assortCheck.code, |
| | | }); |
| | | }) |
| | | }, |
| | |
| | | }, |
| | | }; |
| | | app.MG.store.getStoreChannelList(query).then(async (res) => { |
| | | let options = []; |
| | | let options = [{ |
| | | value: "", |
| | | label: "一级分类", |
| | | }]; |
| | | if (res.datas.length > 0) { |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | let item = res.datas[index]; |
| | |
| | | }) |
| | | }); |
| | | }, |
| | | // 获取重点项目 |
| | | getProjectList(type) { |
| | | const options = []; |
| | | const arr = []; |
| | | let array = []; |
| | | const query = { |
| | | refCodes: [type], |
| | | }; |
| | | app.MG.store.getProductTypeField(query).then((res) => { |
| | | array = JSON.parse(res[0].config).option; |
| | | for (let index = 0; index < array.length; index++) { |
| | | const element = array[index]; |
| | | if (element.child) { |
| | | for (let index = 0; index < element.child.length; index++) { |
| | | const item = element.child[index]; |
| | | arr.push(item); |
| | | } |
| | | } |
| | | } |
| | | if (type == 'bookClassification') { |
| | | for (let index = 0; index < arr.length; index++) { |
| | | const element = arr[index]; |
| | | options.push({ |
| | | value: element.value, |
| | | label: element.name, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | 'majorProjectList.options': options, |
| | | }); |
| | | } else if (type == 'newFormsTextbooks') { |
| | | for (let index = 0; index < arr.length; index++) { |
| | | const element = arr[index]; |
| | | options.push({ |
| | | value: element.value, |
| | | label: element.name, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | 'newTextBook.options': options, |
| | | }); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | // 获取图书列表 |
| | | getBookList(isReachBottom) { |
| | | let that = this; |
| | |
| | | queryType: '*', |
| | | }; |
| | | } |
| | | if (that.data.sort) { |
| | | if (this.data.sortList.value == "name-asc") { |
| | | sort = { |
| | | Name: that.data.sort, |
| | | BaseType: '', |
| | | Name: "Asc", |
| | | BaseType: "", |
| | | }; |
| | | } else { |
| | | } 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 (that.data.sort) { |
| | | // sort = { |
| | | // Name: that.data.sort, |
| | | // BaseType: '', |
| | | // }; |
| | | // } else { |
| | | // sort = { |
| | | // type: 'Desc', |
| | | // field: 'ViewCount', |
| | | // }; |
| | | // } |
| | | // 搜索 |
| | | let searchObj = {}; |
| | | if (that.data.searchValue) { |
| | |
| | | } |
| | | if (that.data.alreadyPaperBookList.length > 0) { |
| | | that.data.alreadyPaperBookList.forEach((pBook) => { |
| | | pBook.content.forEach((pBookItem) => { |
| | | if (pBookItem.id === item.id && pBook.state == 'WaitAudit') { |
| | | item.paperDisabled = true |
| | | item.paperChecked = true |
| | | } |
| | | if (pBookItem.id === item.id && pBook.state == 'Normal') { |
| | | item.paperDisabled = false |
| | | } |
| | | }) |
| | | if (pBook.content.length > 0) { |
| | | pBook.content.forEach((pBookItem) => { |
| | | if (pBookItem.id === item.id && pBook.state == 'WaitAudit') { |
| | | item.paperDisabled = true |
| | | item.paperChecked = true |
| | | } |
| | | if (pBookItem.id === item.id && pBook.state == 'Normal') { |
| | | item.paperDisabled = false |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (that.data.alreadyElectronicBookList.length > 0) { |
| | | that.data.alreadyElectronicBookList.forEach((eBook) => { |
| | | eBook.content.forEach((eBookItem) => { |
| | | if (eBookItem.id === item.id && !eBook.isExpiry && eBook.state != 'Reject') { |
| | | item.electronDisabled = true |
| | | item.electronChecked = true |
| | | } |
| | | }) |
| | | if (eBook.content.length > 0) { |
| | | eBook.content.forEach((eBookItem) => { |
| | | if (eBookItem.id === item.id && !eBook.isExpiry && eBook.state != 'Reject') { |
| | | item.electronDisabled = true |
| | | item.electronChecked = true |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | if (that.data.paperBookList.length > 0) { |
| | |
| | | }) |
| | | } else { |
| | | that.setData({ |
| | | bookList: [], |
| | | pageTotalCount: 0, |
| | | skeletonLoding: false, |
| | | loading: false |
| | | }) |
| | |
| | | onConfirmSecond() { |
| | | this.getBookList(false); |
| | | }, |
| | | // 重点项目改变 |
| | | changeMajorProject(e) { |
| | | onResetSecond() { |
| | | this.setData({ |
| | | 'majorProjectList.value': e.detail.value, |
| | | 'secondList.value': [], |
| | | }); |
| | | this.getBookList(false); |
| | | }, |
| | | // 重点项目重置 |
| | | resetMajorProject() { |
| | | |
| | | // 排序切换 |
| | | onSortChange(e) { |
| | | this.setData({ |
| | | 'majorProjectList.value': [], |
| | | backTop: "#assort-title", |
| | | "sortList.value": e.detail.value, |
| | | }); |
| | | this.getBookList(false); |
| | | }, |
| | | changeNewText(e) { |
| | | this.setData({ |
| | | 'newTextBook.value': e.detail.value, |
| | | }); |
| | | this.getBookList(false); |
| | | }, |
| | | resetNewText() { |
| | | this.setData({ |
| | | 'newTextBook.value': [], |
| | | }); |
| | | this.getBookList(false); |
| | | }, |
| | | // 排序按钮 |
| | | 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}`; |
| | | path = `${this.data.assortCheck.code}\\${this.data.stairCode}`; |
| | | } else { |
| | | path = this.data.assortCheck.code; |
| | | } |
| | | this.setData({ |
| | | path: path, |
| | | }); |
| | | this.getBookList(false); |
| | | this.getBookList(path); |
| | | }, |
| | | // 搜索图书 |
| | | searchBook(e) { |
| | |
| | | this.setData({ |
| | | electronicBookList: eList, |
| | | }) |
| | | wx.setStorageSync("electronicBookList", eList); |
| | | wx.setStorageSync("electronicBookList", JSON.stringify(eList)); |
| | | } else { |
| | | pList.push(itemAttr) |
| | | this.setData({ |
| | | paperBookList: pList, |
| | | }) |
| | | wx.setStorageSync("paperBookList", pList); |
| | | wx.setStorageSync("paperBookList", JSON.stringify(pList)); |
| | | } |
| | | this.setData({ |
| | | num: this.data.num + 1 |