From 312fd09aaf90c0e52ab61bde22d0edbf105baa5e Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期二, 02 四月 2024 09:16:03 +0800 Subject: [PATCH] 书展的排序1 --- pages/bookExhibitionList/index.js | 152 +++++++++++++++++++++++++++++++++++++------------- 1 files changed, 113 insertions(+), 39 deletions(-) diff --git a/pages/bookExhibitionList/index.js b/pages/bookExhibitionList/index.js index 032e4a3..a16ce9e 100644 --- a/pages/bookExhibitionList/index.js +++ b/pages/bookExhibitionList/index.js @@ -8,6 +8,7 @@ * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { + keynoteDisabled: true, value: '', keyword: '', nameSort: null, @@ -25,9 +26,7 @@ }, product: { value: '*', - - options: [ - { + options: [{ value: '*', label: '鎬诲垎绫�', }, @@ -49,25 +48,45 @@ price: 'jsek_teacherEducation', label: '鏁欏笀鏁欒偛', }, - ], - }, multipleSelect: { value: [], options: [], }, navBarHeight: '', - barHeight: '' - + barHeight: '', + windowHeight: '', + sorter: { + value: 'timeAsc', + options: [{ + value: 'nameAsc', + label: '鍚嶇О浠庨珮鍒颁綆', + }, + { + value: 'nameDesc', + label: '鍚嶇О浠庝綆鍒伴珮', + }, + { + value: 'timeAsc', + label: '鍒涘缓鏃堕棿浠庨珮鍒颁綆', + }, + { + 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(); // 鑳跺泭淇℃伅 @@ -86,25 +105,27 @@ if (this.data.filteredItems = []) { console.log(11111); - singleSelectOptions.push({ - label: '绂佺敤閫夐」', - value: 'disabled', - disabled: true, - }); + // singleSelectOptions.push({ + // label: '鏆傛棤鏁版嵁', + // value: 'disabled', + // disabled: true, + // }); + } else { + console.log(7889); } - // singleSelectOptions.push({ - // label: '绂佺敤閫夐」', - // value: 'disabled', - // disabled: true, - // }); + + + console.log(this.data.bookExhibitionList.length, 'this.data.bookExhibitionList.length'); // 鏇存柊鏁版嵁 this.setData({ 'multipleSelect.options': singleSelectOptions, }); + + // }, /** @@ -119,8 +140,8 @@ */ onShow() { this.bookExhibitionGet() - this.keyProjectsGet() + }, /** @@ -196,9 +217,30 @@ '||subtitle*': this.data.keyword } // console.log(this.data.keynoteValue); - let sort = { - Name: this.data.nameSort || 'Desc' - } + 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, @@ -216,17 +258,32 @@ // }, }).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) + // list.push(res.datas) + console.log(res.datas.length); + + + if (res.datas.length == 0) { + this.setData({ + keynoteDisabled: true + }) + } + const list = [...res.datas] this.setData({ bookExhibitionList: list }) + // 鍒ゆ柇鏁版嵁闀垮害 + console.log(list.length, 'list.length'); + //鍙栨秷 wx.hideLoading() @@ -272,6 +329,24 @@ 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 + }) + } this.setData({ 'product.value': newValue, 'product.price': newPrice, // 灏嗛�変腑鐨� price 鍊间繚瀛樺湪鏁版嵁涓� @@ -283,16 +358,9 @@ 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'); } - }, // 閲嶇偣椤圭洰 @@ -300,9 +368,13 @@ this.setData({ 'multipleSelect.value': e.detail.value, }); + }, handleConfirm(event) { - const { value } = event.detail; + + const { + value + } = event.detail; // 纭鎿嶄綔鐨勫鐞嗛�昏緫 console.log('纭鎿嶄綔锛岄�変腑鐨勫�间负锛�', value); @@ -310,16 +382,13 @@ this.bookExhibitionGet() }, handleReset() { + // 閲嶇疆鎿嶄綔鐨勫鐞嗛�昏緫 this.data.keynoteValue = [] console.log('閲嶇疆鎿嶄綔'); this.bookExhibitionGet() }, onSwapRight() { - // console.log('xxxxxx'); - // this.data.nameSort = 'Asc' - - if (!this.data.nameSort) { this.setData({ nameSort: 'Desc', @@ -341,14 +410,12 @@ this.data.nameSort = 'Desc' // console.log('sssssss'); this.bookExhibitionGet() - - }, onBookExhibitionDetails: function (event) { const item = event.currentTarget.dataset.item; console.log(item); wx.navigateTo({ - url: '/pages/bookExhibitionDetails/index?id=' + item.id + '&bookName=' + item.name // 鍋囪璺宠浆鍒拌鎯呴〉闈紝骞朵紶閫掍簡id鍙傛暟 + url: '/pages/bookExhibitionDetails/index?id=' + item.id + '&bookName=' + item.name + '&subtitleName=' + item.subtitleName // 鍋囪璺宠浆鍒拌鎯呴〉闈紝骞朵紶閫掍簡id鍙傛暟 }); }, // 鎼滅储妗� @@ -362,4 +429,11 @@ goBack() { wx.navigateBack(); }, + onSort(e) { + this.setData({ + 'product.value': e.detail.value, + }); + console.log(e.detail.value, 'e.detail.value'); + this.bookExhibitionGet() + } }) \ No newline at end of file -- Gitblit v1.9.1