From dc1b48bb46e5715a5a55ee2c0f60175b849a6b3b Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期二, 09 四月 2024 19:32:30 +0800 Subject: [PATCH] 问题修改 --- packageDomain/pages/sampleBookList/index.js | 312 +++++++++++++++++++++++++--------------------------- 1 files changed, 150 insertions(+), 162 deletions(-) diff --git a/packageDomain/pages/sampleBookList/index.js b/packageDomain/pages/sampleBookList/index.js index e01c948..8ee6d3b 100644 --- a/packageDomain/pages/sampleBookList/index.js +++ b/packageDomain/pages/sampleBookList/index.js @@ -14,7 +14,6 @@ userInfo: null, path: '*', pathList: [], - bookList: [], //楂樼骇鍒嗙被 iconList: { @@ -24,20 +23,13 @@ //涓�绾у垎绫� stairList: { value: '', - options: [], + options: [{ + value: "", + label: "涓�绾у垎绫�", + }], }, //浜岀骇鍒嗙被 secondList: { - value: [], - options: [], - }, - //閲嶇偣椤圭洰 - majorProjectList: { - value: [], - options: [], - }, - //鏂板舰鎬佹暀鏉� - newTextBook: { value: [], options: [], }, @@ -46,10 +38,33 @@ name: '', code: '', }, - stairCode: '', // 涓�绾у垎绫婚�変腑椤� secondCode: '', // 浜岀骇鍒嗙被閫変腑椤� sort: '', // 鎺掑簭 + sortList: { + value: "default", + options: [{ + value: "default", + label: "榛樿鎺掑簭", + }, + { + value: "name-asc", + label: "鍚嶇О姝e簭", + }, + { + value: "name-desc", + label: "鍚嶇О鍊掑彊", + }, + { + value: "time-asc", + label: "鍑虹増鏃堕棿姝e簭", + }, + { + value: "time-desc", + label: "鍑虹増鏃堕棿鍊掑彊", + }, + ], + }, //鍒嗛〉 page: 1, limit: 10, @@ -67,28 +82,31 @@ 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, @@ -96,13 +114,13 @@ }, }); } - 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}`, @@ -110,7 +128,7 @@ } // 浜岀骇鍒嗙被璧嬪�� if (options && options.secondCode) { - this.setData({ + that.setData({ secondCode: options.secondCode, pathList: [{ Path: options.secondCode, @@ -119,37 +137,29 @@ }], }) } - 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() + } }, @@ -164,27 +174,40 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ 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', @@ -197,7 +220,7 @@ }) }, // 鑾峰彇鐢靛瓙涔﹀墿浣欐鏁� - getSelectBookCount(item) { + getSelectBookCount() { app.MG.app .getTicketResult({ ticketRefCodeOrGuid: 'electronicSampleBookapplyNum', @@ -228,7 +251,10 @@ } } 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; @@ -244,7 +270,7 @@ ) this.setData({ 'iconList.options': list, - 'iconList.value': this.data.assortCode, + 'iconList.value': this.data.assortCheck.code, }); }) }, @@ -264,7 +290,10 @@ }, }; 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]; @@ -315,50 +344,7 @@ }) }); }, - // 鑾峰彇閲嶇偣椤圭洰 - 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; @@ -374,17 +360,43 @@ 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) { @@ -429,26 +441,30 @@ } 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) { @@ -481,6 +497,8 @@ }) } else { that.setData({ + bookList: [], + pageTotalCount: 0, skeletonLoding: false, loading: false }) @@ -493,9 +511,7 @@ //楂樼骇鍒嗙被閫夋嫨 onChangeIcon(e) { this.setData({ - assortCheck: { - code: e.detail.value, - }, + 'assortCheck.code': e.detail.value, stairCode: '', secondCode: '', path: `${e.detail.value}`, @@ -541,60 +557,32 @@ 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) { @@ -882,13 +870,13 @@ 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 -- Gitblit v1.9.1