From c2cd778fd3f40a75df483758bb2f1fe1dedc7eef Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期五, 26 四月 2024 09:49:25 +0800 Subject: [PATCH] 资源购买页请求慢优化 --- pages/bookExhibitionList/index.js | 216 ++++++++++++++++++++++++----------------------------- 1 files changed, 98 insertions(+), 118 deletions(-) diff --git a/pages/bookExhibitionList/index.js b/pages/bookExhibitionList/index.js index 64570f8..37a8d66 100644 --- a/pages/bookExhibitionList/index.js +++ b/pages/bookExhibitionList/index.js @@ -8,22 +8,6 @@ * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - product: { - value: 'all', - options: [{ - value: 'all', - label: '鍏ㄩ儴浜у搧', - }, - { - value: 'new', - label: '鏈�鏂颁骇鍝�', - }, - { - value: 'hot', - label: '鏈�鐏骇鍝�', - }, - ], - }, loading: true, hidden: true, totalSize: '', @@ -45,32 +29,32 @@ sorter: { value: 'default', }, - // product: { - // value: '*', - // options: [{ - // value: '*', - // label: '鎬诲垎绫�', - // }, - // { - // value: 'jsek_bFHigherEducation', - // //閲嶇偣椤圭洰 - // price: 'jsek_higherEducation', - // label: '楂樼瓑鏁欒偛', - // }, - // { - // value: 'jsek_bFVocationalEducation', - // //閲嶇偣椤圭洰 - // price: 'jsek_vocationalEducation', - // label: '鑱屼笟鏁欒偛', - // }, - // { - // value: 'jsek_bFTeacherEducation', - // //閲嶇偣椤圭洰 - // price: 'jsek_teacherEducation', - // label: '鏁欏笀鏁欒偛', - // }, - // ], - // }, + product: { + value: '*', + options: [{ + value: '*', + label: '鎬诲垎绫�', + }, + { + value: 'jsek_bFHigherEducation', + //閲嶇偣椤圭洰 + price: 'jsek_higherEducation', + label: '楂樼瓑鏁欒偛', + }, + { + value: 'jsek_bFVocationalEducation', + //閲嶇偣椤圭洰 + price: 'jsek_vocationalEducation', + label: '鑱屼笟鏁欒偛', + }, + { + value: 'jsek_bFTeacherEducation', + //閲嶇偣椤圭洰 + price: 'jsek_teacherEducation', + label: '鏁欏笀鏁欒偛', + }, + ], + }, multipleSelect: { value: [], options: [], @@ -107,8 +91,7 @@ */ onLoad(options) { - console.log(this.data.keynoteDisabled, 'keynoteDisabled'); - // console.log(this.data.filteredItems, 88888); + const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� @@ -125,7 +108,7 @@ })) if (this.data.filteredItems = []) { - console.log(11111); + // singleSelectOptions.push({ // label: '鏆傛棤鏁版嵁', // value: 'disabled', @@ -139,7 +122,7 @@ - console.log(this.data.bookExhibitionList.length, 'this.data.bookExhibitionList.length'); + // 鏇存柊鏁版嵁 this.setData({ 'multipleSelect.options': singleSelectOptions, @@ -191,9 +174,7 @@ // }, onScrollToLower() { - console.log(789); - console.log(this.data.bookExhibitionList.length); - console.log(this.data.totalSize); + if (this.data.bookExhibitionList.length < this.data.totalSize) { this.setData({ isMore: true, @@ -208,7 +189,7 @@ this.setData({ isMore: false }) - console.log('300'); + }, 300) } }, @@ -216,10 +197,9 @@ * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� */ onReachBottom() { - // console.log(this.data.page.size); - // console.log(this.data.total); + if (this.data.page.size >= this.data.total) { - console.log('宸插姞杞藉畬鎵�鏈夋暟鎹�'); + Toast({ context: this, selector: '#t-toast', @@ -260,7 +240,7 @@ 'Name*': this.data.keyword, '||subtitle*': this.data.keyword } - // console.log(this.data.keynoteValue); + let sort = {}; const sortOptions = { @@ -283,7 +263,7 @@ sort = sortOptions[this.data.product.value] || {}; - console.log(sort); + app.MG.store.getProductList({ storeInfo: 'jsek_bookFair', @@ -310,11 +290,11 @@ } item.subtitleName = item.subtitle + item.name }) - console.log(res, 'item'); + this.data.total = res.total // list.push(res.datas) - console.log(res.datas.length); + if (res.datas.length == 0) { @@ -324,18 +304,17 @@ } const list = [...res.datas] - console.log(res); + this.setData({ bookExhibitionList: list, totalSize: res.total }) - // 鍒ゆ柇鏁版嵁闀垮害 - console.log(list.length, 'list.length'); + //鍙栨秷 wx.hideLoading() - // console.log(this.data.bookExhibitionList, '鏁版嵁'); + this.setData({ loading: false, @@ -351,7 +330,7 @@ loading: true, hidden: true, }) - // console.log(newPrice, 'newPrice'); + let parms = { refCodes: ['bookClassification'] } @@ -362,7 +341,7 @@ this.setData({ filteredItems: item.child || [] // 濡傛灉瀛樺湪瀛愰」鍒欒祴鍊硷紝鍚﹀垯璧嬪�间负绌烘暟缁� }); - // console.log(this.data.filteredItems); + } }) @@ -376,52 +355,57 @@ }, + + + // 鎬诲垎绫� + // 鎬诲垎绫� onChange(e) { - console.log(e); + this.data.page.size = 16 //鏇存敼鏄剧ず鐨勫�� + const newValue = e.detail.value; + const selectedOption = this.data.product.options.find(option => option.value === newValue); + const newPrice = selectedOption ? selectedOption.price : null; + + + // const bookExhibitionListsubsidiary = [] + // this.setData({ + // bookExhibitionListsubsidiary: this.data.bookExhibitionList + // }) + + + if (newPrice) { + this.setData({ + keynoteDisabled: false + }) + } + if (!newPrice) { + this.setData({ + keynoteDisabled: true + }) + } + + this.setData({ + 'product.value': newValue, + 'product.price': newPrice, // 灏嗛�変腑鐨� price 鍊间繚瀛樺湪鏁版嵁涓� + }); + this.bookExhibitionGet(newValue); + this.keyProjectsGet(newPrice); + // 璋冪敤鏇存柊椤甸潰鏁版嵁鐨勫嚱鏁帮紝浼犲叆鏂扮殑 value 鍜� price 鍊� + + if (this.data.keynoteValue) { + //濡傛灉鏈夋暟鎹氨娓呯┖骞跺埛鏂伴〉闈� + this.data.keynoteValue = [] + this.bookExhibitionGet(newValue) + this.onLoad() + } + + + + + + + // e.stopImmediatePropagation() + }, - - // 鎬诲垎绫� - // 鎬诲垎绫� - // onChange(e) { - - // this.data.page.size = 16 //鏇存敼鏄剧ず鐨勫�� - // const newValue = e.detail.value; - // const selectedOption = this.data.product.options.find(option => option.value === newValue); - // const newPrice = selectedOption ? selectedOption.price : null; - // const bookExhibitionListsubsidiary = [] - // this.setData({ - // bookExhibitionListsubsidiary: this.data.bookExhibitionList - // }) - // console.log(bookExhibitionListsubsidiary, 'bookExhibitionListsubsidiary'); - // console.log(newValue, 'newValue'); - // console.log(newPrice, 'newPrice'); - - // if (newPrice) { - // this.setData({ - // keynoteDisabled: false - // }) - // } - // if (!newPrice) { - // this.setData({ - // keynoteDisabled: true - // }) - // } - // console.log(newValue); - // this.setData({ - // 'product.value': newValue, - // 'product.price': newPrice, // 灏嗛�変腑鐨� price 鍊间繚瀛樺湪鏁版嵁涓� - // }); - // this.bookExhibitionGet(newValue); - // this.keyProjectsGet(newPrice); - // // 璋冪敤鏇存柊椤甸潰鏁版嵁鐨勫嚱鏁帮紝浼犲叆鏂扮殑 value 鍜� price 鍊� - - // if (this.data.keynoteValue) { - // //濡傛灉鏈夋暟鎹氨娓呯┖骞跺埛鏂伴〉闈� - // this.data.keynoteValue = [] - // this.bookExhibitionGet(newValue) - // this.onLoad() - // } - // }, // 閲嶇偣椤圭洰 handleMultipleSelect(e) { @@ -430,15 +414,12 @@ }); }, handleConfirm(event) { - - - const { value } = event.detail; // 纭鎿嶄綔鐨勫鐞嗛�昏緫 - console.log('纭鎿嶄綔锛岄�変腑鐨勫�间负锛�', value); + this.data.keynoteValue = value this.bookExhibitionGet() }, @@ -470,13 +451,12 @@ }, onSwapLeft() { this.data.nameSort = 'Desc' - // console.log('sssssss'); this.bookExhibitionGet() }, onBookExhibitionDetails: function (event) { - console.log(456); + const item = event.currentTarget.dataset.item; - console.log(item); + wx.navigateTo({ url: '/pages/bookExhibitionDetails/index?id=' + item.id + '&bookName=' + item.name + '&subtitleName=' + item.subtitleName // 鍋囪璺宠浆鍒拌鎯呴〉闈紝骞朵紶閫掍簡id鍙傛暟 }); @@ -487,7 +467,7 @@ this.setData({ keyword: e.detail.value }) - console.log(this.data.keyword, 'keyword'); + this.bookExhibitionGet() }, goBack() { @@ -497,10 +477,10 @@ this.setData({ 'product.value': e.detail.value, }); - console.log(e.detail.value, 'e.detail.value'); + this.bookExhibitionGet() }, - onTest() { - console.log(7555); + onOpend() { + } }) \ No newline at end of file -- Gitblit v1.9.1