From 56b70cdad0a96691eaf37e04a79ef5e92b892480 Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期五, 19 四月 2024 11:14:40 +0800 Subject: [PATCH] bug1 --- pages/bookExhibitionList/index.js | 331 +++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 260 insertions(+), 71 deletions(-) diff --git a/pages/bookExhibitionList/index.js b/pages/bookExhibitionList/index.js index c4d4a70..e3b7d50 100644 --- a/pages/bookExhibitionList/index.js +++ b/pages/bookExhibitionList/index.js @@ -8,6 +8,14 @@ * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { + loading: true, + hidden: true, + totalSize: '', + start: 0, + isMore: null, + keynoteDisabled: true, + value: '', + keyword: '', nameSort: null, total: null, page: { @@ -17,18 +25,14 @@ keynoteValue: null, filteredItems: [], newValue: null, - value: '', bookExhibitionList: [], sorter: { value: 'default', }, product: { value: '*', - - options: [ - { + options: [{ value: '*', - label: '鎬诲垎绫�', }, { @@ -55,9 +59,79 @@ value: [], options: [], }, + navBarHeight: '', + barHeight: '', + windowHeight: '', + sorter: { + value: 'timeAsc', + options: [{ + value: 'nameAsc', + label: '鍚嶇О姝e簭', + }, + { + value: 'nameDesc', + label: '鍚嶇О鍊掑簭', + }, + { + value: 'timeAsc', + label: '鍑虹増鏃堕棿姝e簭', + }, + { + value: 'timeDesc', + label: '鍑虹増鏃堕棿鍊掑簭', + }, + ], + }, }, + + /** + * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 + */ + 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; // 瀵艰埅鏍忛珮搴� + this.setData({ + navBarHeight: navBarHeight, + barHeight: systInfo.statusBarHeight, + }) + + // 鍗曞垪閫夋嫨鍣ㄩ�夐」 + const singleSelectOptions = this.data.filteredItems.map(item => ({ + label: item.name, + value: item.value, + disabled: false, + })) + + if (this.data.filteredItems = []) { + console.log(11111); + // singleSelectOptions.push({ + // label: '鏆傛棤鏁版嵁', + // value: 'disabled', + // disabled: true, + // }); + } else { + console.log(7889); + } + + + + + + console.log(this.data.bookExhibitionList.length, 'this.data.bookExhibitionList.length'); + // 鏇存柊鏁版嵁 + this.setData({ + 'multipleSelect.options': singleSelectOptions, + }); + + + // + }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 @@ -71,8 +145,8 @@ */ onShow() { this.bookExhibitionGet() - this.keyProjectsGet() + }, /** @@ -95,7 +169,33 @@ onPullDownRefresh() { }, + // onPullDownRefresh() { + // this.data.page.size = 16 //鏇存敼鏄剧ず鐨勫�� + // this.bookExhibitionGet(); // 璋冪敤鏂规硶鍔犺浇鏇村鏁版嵁 + // }, + 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, + start: this.data.start + 1 + }) + this.bookExhibitionGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + console.log('300'); + }, 300) + } + }, /** * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� */ @@ -120,8 +220,10 @@ // 'page.start': currentPage, 'page.size': newSize }); - this.bookExhibitionGet(); // 璋冪敤鏂规硶鍔犺浇鏇村鏁版嵁 - console.log(1111); + // this.bookExhibitionGet(); // 璋冪敤鏂规硶鍔犺浇鏇村鏁版嵁 + + + } }, @@ -138,113 +240,165 @@ wx.showLoading({ title: '鍔犺浇涓�...', }) - - // console.log(this.data.keynoteValue); - let sort = { - Name: this.data.nameSort || 'Desc' + let searchObj = { + 'Name*': this.data.keyword, + '||subtitle*': this.data.keyword } + // console.log(this.data.keynoteValue); + let sort = {}; + + const sortOptions = { + '*': { + CreateDate: 'Asc' + }, + 'nameAsc': { + Name: 'Asc' + }, + 'nameDesc': { + Name: 'Desc' + }, + 'timeAsc': { + CreateDate: 'Asc' + }, + 'timeDesc': { + CreateDate: 'Desc' + } + }; + + sort = sortOptions[this.data.product.value] || {}; + + console.log(sort); + app.MG.store.getProductList({ storeInfo: 'jsek_bookFair', path: newValue, queryType: '*', fields: { jsek_link: [], - 'bookClassification*': this.data.keynoteValue || [] + subtitle: [], + 'bookClassification*': this.data.keynoteValue || [], + ...searchObj }, - paging: this.data.page, + paging: { + start: '0', + size: this.data.start * 10 + }, sort: sort, // coverSize: { // width: 100 // }, }).then(res => { - + res.datas.forEach((item) => { + if (item.subtitle == undefined) { + item.subtitle = '' + } + item.subtitleName = item.subtitle + item.name + }) + console.log(res, 'item'); this.data.total = res.total - // list.push(res.datas) - const list = [...res.datas] + // list.push(res.datas) + console.log(res.datas.length); + + if (res.datas.length == 0) { + this.setData({ + keynoteDisabled: true + }) + } + + const list = [...res.datas] + console.log(res); this.setData({ - bookExhibitionList: list + bookExhibitionList: list, + totalSize: res.total }) + // 鍒ゆ柇鏁版嵁闀垮害 + console.log(list.length, 'list.length'); + + //鍙栨秷 wx.hideLoading() // console.log(this.data.bookExhibitionList, '鏁版嵁'); + + this.setData({ + loading: false, + hidden: false, + }) }) }, //閲嶇偣椤圭洰鎺ュ彛 keyProjectsGet(newPrice) { + + this.setData({ + loading: true, + hidden: true, + }) // console.log(newPrice, 'newPrice'); let parms = { refCodes: ['bookClassification'] } app.MG.store.getProductTypeField(parms).then(res => { - const checkData = JSON.parse(res[0].config) - - checkData.option.forEach(item => { if (newPrice == item.value) { - this.setData({ filteredItems: item.child || [] // 濡傛灉瀛樺湪瀛愰」鍒欒祴鍊硷紝鍚﹀垯璧嬪�间负绌烘暟缁� }); - // console.log(this.data.filteredItems); - } }) this.onLoad(); + + this.setData({ + loading: false, + hidden: false, + }) }) }, - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 - */ - onLoad(options) { - // console.log(this.data.filteredItems, 88888); - - // 鍗曞垪閫夋嫨鍣ㄩ�夐」 - const singleSelectOptions = this.data.filteredItems.map(item => ({ - label: item.name, - value: item.value, - disabled: false, - })) - - if (this.data.filteredItems = []) { - console.log(11111); - singleSelectOptions.push({ - label: '绂佺敤閫夐」', - value: 'disabled', - disabled: true, - }); - } - - // singleSelectOptions.push({ - // label: '绂佺敤閫夐」', - // value: 'disabled', - // disabled: true, - // }); - - - // 鏇存柊鏁版嵁 - this.setData({ - 'multipleSelect.options': singleSelectOptions, - }); - - }, // 鎬诲垎绫� // 鎬诲垎绫� onChange(e) { + // e.stopImmediatePropagation(); + + + + + + + + + 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 鍊间繚瀛樺湪鏁版嵁涓� @@ -256,15 +410,10 @@ if (this.data.keynoteValue) { //濡傛灉鏈夋暟鎹氨娓呯┖骞跺埛鏂伴〉闈� this.data.keynoteValue = [] - this.bookExhibitionGet(newValue) this.onLoad() - console.log('true'); - } else { - // this.bookExhibitionGet(newValue); - // this.keyProjectsGet(newPrice); - console.log('fals'); } + // e.stopImmediatePropagation() }, @@ -275,23 +424,40 @@ }); }, handleConfirm(event) { - const { value } = event.detail; + const { + value + } = event.detail; // 纭鎿嶄綔鐨勫鐞嗛�昏緫 console.log('纭鎿嶄綔锛岄�変腑鐨勫�间负锛�', value); this.data.keynoteValue = value this.bookExhibitionGet() }, - handleReset() { + + + handleReset(e) { + // 閲嶇疆鎿嶄綔鐨勫鐞嗛�昏緫 this.data.keynoteValue = [] - console.log('閲嶇疆鎿嶄綔'); this.bookExhibitionGet() }, onSwapRight() { - // console.log('xxxxxx'); - this.data.nameSort = 'Asc' + if (!this.data.nameSort) { + this.setData({ + nameSort: 'Desc', + }); + } else if (this.data.nameSort == 'Desc') { + this.setData({ + nameSort: 'Asc', + }); + } else if (this.data.nameSort == 'Asc') { + this.setData({ + nameSort: '', + }); + } + this.bookExhibitionGet() + }, onSwapLeft() { this.data.nameSort = 'Desc' @@ -299,10 +465,33 @@ 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 // 鍋囪璺宠浆鍒拌鎯呴〉闈紝骞朵紶閫掍簡id鍙傛暟 + url: '/pages/bookExhibitionDetails/index?id=' + item.id + '&bookName=' + item.name + '&subtitleName=' + item.subtitleName // 鍋囪璺宠浆鍒拌鎯呴〉闈紝骞朵紶閫掍簡id鍙傛暟 }); + }, + + // 鎼滅储妗� + onSearchSubmit(e) { + this.setData({ + keyword: e.detail.value + }) + console.log(this.data.keyword, 'keyword'); + this.bookExhibitionGet() + }, + goBack() { + wx.navigateBack(); + }, + onSort(e) { + this.setData({ + 'product.value': e.detail.value, + }); + console.log(e.detail.value, 'e.detail.value'); + this.bookExhibitionGet() + }, + onOpend() { + console.log(7555); } }) \ No newline at end of file -- Gitblit v1.9.1