From f1e20feafa89c8d50af5e69c0333a9efc239ee49 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期一, 01 四月 2024 14:09:11 +0800 Subject: [PATCH] 图书详情页bug修改,我的错题、收藏模式下答题卡添加题目类型,非单选题添加查看解析按钮 --- packageBookService/pages/bookServices/list/index.js | 215 +++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 164 insertions(+), 51 deletions(-) diff --git a/packageBookService/pages/bookServices/list/index.js b/packageBookService/pages/bookServices/list/index.js index 656c94b..9409fb6 100644 --- a/packageBookService/pages/bookServices/list/index.js +++ b/packageBookService/pages/bookServices/list/index.js @@ -1,4 +1,7 @@ const app = getApp(); +import { + loginInfo +} from '../../../../assets/js/login'; Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� @@ -21,20 +24,42 @@ bookList: [], stairList: { value: '', - options: [ - { - value: '', - label: '涓�绾�', - }, - ], + options: [{ + value: '', + label: '涓�绾�', + }, ], }, secondList: { value: [], options: [], + disabled: false, }, majorProjectList: { value: [], options: [], + }, + sortList: { + value: '', + options: [{ + value: '', + label: '缁煎悎鎺掑簭', + }, { + value: '1', + label: '鍚嶇О姝e簭' + }, + { + value: '2', + label: '鍚嶇О鍊掑彊' + }, + { + value: '3', + label: '鍑虹増鏃堕棿姝e簭' + }, + { + value: '3', + label: '鍑虹増鏃堕棿鍊掑彊' + } + ], }, newTextBook: { value: [], @@ -48,7 +73,14 @@ size: '50rpx' }, loading: false, - noData: false + noData: false, + showDropdown: false, + isRequesting: false, + disabledStair: false, + disabledSecondList: false, + disabledProject: false, + disabledNewForms: false, + triggered: false, }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 @@ -95,8 +127,7 @@ Path: options.secondCode, Type: '*', StoreRefCode: app.config.goodsStore, - } - ], + }], }) } // 鑾峰彇浜岀骇鍒嗙被 @@ -110,30 +141,34 @@ /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 */ - onReady() { - }, + onReady() {}, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ - onShow() { - }, + onShow() {}, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 */ - onHide() { }, + onHide() {}, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 */ - onUnload() { }, + onUnload() {}, /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 */ onPullDownRefresh() { - console.log('涓嬫媺'); + this.setData({ + triggered: true + }) + this.setData({ + 'pageCount.page': 1 + }) + this.getBookList(this.data.path); }, /** @@ -142,11 +177,13 @@ onReachBottom(e) { const flag = this.data.bookList.length < this.data.pageCount.total if (flag) { - this.setData({ - isMore: true, - "pageCount.page": this.data.pageCount.page + 1 - }) - this.getBookList(this.data.path) + if (!this.data.isRequesting) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.getBookList(this.data.path) + } } else { this.setData({ isMore: true, @@ -163,12 +200,15 @@ /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� */ - onShareAppMessage() { }, + onShareAppMessage() {}, goBack() { wx.navigateBack(); }, // 鑾峰彇涓�绾у垪琛� getStairList(path) { + this.setData({ + disabledStair: false + }) const query = { path, filterList: [], @@ -177,15 +217,16 @@ size: '30', start: '0', storeRefCode: app.config.goodsStore, - sort: { type: 'Asc', field: 'LinkOrder' }, + sort: { + type: 'Asc', + field: 'LinkOrder' + }, }; app.MG.store.getStoreChannelList(query).then(async (res) => { - const options = [ - { - value: '', - label: '涓�绾�', - }, - ]; + const options = [{ + value: '', + label: '涓�绾�', + }, ]; for (let index = 0; index < res.datas.length; index++) { const item = res.datas[index]; options.push({ @@ -197,6 +238,11 @@ 'stairList.options': options, 'stairList.value': this.data.stairCode, }); + if (!options.length) { + this.setData({ + disabledStair: true + }) + } }); }, // 鑾峰彇涓�绾у垎绫讳笅浜岀骇鍒嗙被 @@ -210,7 +256,10 @@ size: '30', start: '0', storeRefCode: app.config.goodsStore, - sort: { type: 'Asc', field: 'LinkOrder' }, + sort: { + type: 'Asc', + field: 'LinkOrder' + }, }; app.MG.store.getStoreChannelList(query).then((res) => { for (let index = 0; index < res.datas.length; index++) { @@ -231,6 +280,10 @@ }, // 鑾峰彇閲嶇偣椤圭洰 getProjectList(type) { + this.setData({ + disabledProject: false, + disabledNewForms: false + }) const options = []; const arr = []; let array = []; @@ -238,7 +291,7 @@ refCodes: [type], }; app.MG.store.getProductTypeField(query).then((res) => { - array = JSON.parse(res[0].config).option; + array = JSON.parse(res[0].config).option.filter(item => item.value == this.data.assortCheck.code); for (let index = 0; index < array.length; index++) { const element = array[index]; if (element.child) { @@ -256,6 +309,11 @@ label: element.name, }); } + if (!options.length) { + this.setData({ + disabledProject: true + }) + } this.setData({ 'majorProjectList.options': options, }); @@ -267,6 +325,11 @@ label: element.name, }); } + if (!options.length) { + this.setData({ + disabledNewForms: true + }) + } this.setData({ 'newTextBook.options': options, }); @@ -276,9 +339,13 @@ }, // 鑾峰彇鍥句功鍒楄〃 getBookList(path) { + if (this.data.isRequesting) { + return false; + } this.setData({ loading: true, - noData: false + noData: false, + isRequesting: true }) let sort; let pathObj = {}; @@ -287,7 +354,7 @@ subAccess: this.data.pathList, }; } else { - pathObj = { + pathObj = { path, queryType: '*', }; @@ -315,16 +382,11 @@ } const query = { ...pathObj, - filterList: [ - { - value: 'Normal', - field: 'state', - }, - ], + filterList: [{ + value: 'Normal', + field: 'state', + }, ], sort, - coverSize: { - height: 145, - }, paging: { start: 0, size: this.data.pageCount.page * 8, @@ -342,21 +404,40 @@ bookList: res.datas, enable: false, "pageCount.total": res.total, - loading: false + loading: false, + isRequesting: false }); - console.log('鍥句功鍒楄〃', res.datas); if (!res.datas.length) { this.setData({ - noData: true + noData: true, + }) + if (!this.data.pathList.length) { + // 鏈�夋嫨浜岀骇鍒嗙被锛屼笖鏃犲浘涔� + this.setData({ + disabledSecondList: true + }) + } else { + this.setData({ + disabledSecondList: false + }) + } + } + if (this.data.triggered) { + this.setData({ + triggered: false + }) + wx.showToast({ + title: '鍒锋柊鎴愬姛', }) } }); }, // 涓�绾у垎绫诲垏鎹� onChangeStair(e) { - const path = e.detail.value.length - ? `${this.data.assortCheck.code}\\${e.detail.value}` - : this.data.assortCheck.code; + const path = e.detail.value.length ? + `${this.data.assortCheck.code}\\${e.detail.value}` : + this.data.assortCheck.code; + console.log(this.data.path); this.setData({ pathList: [], stairCode: e.detail.value, @@ -366,6 +447,16 @@ }); this.getBookList(path); this.getSecondList(path); + if (e.detail.value == '') { + this.setData({ + disabledSecondList: true + }) + } else { + this.setData({ + disabledSecondList: false + }) + } + console.log(this.data.disabledSecondList); }, // 浜岀骇鍒嗙被鍒囨崲 onChangeSecond(e) { @@ -400,6 +491,12 @@ 'majorProjectList.value': [], }); this.getBookList(this.data.path); + }, + // 鎺掑簭鍒囨崲 + onSortChange(e) { + this.setData({ + 'sortList.value': e.detail.value + }) }, changeNewText(e) { this.setData({ @@ -451,13 +548,29 @@ }, // 璺宠浆鍥句功璇︽儏 goDetail(e) { - const { book } = e.currentTarget.dataset; + const { + book + } = e.currentTarget.dataset; wx.navigateTo({ url: `/packageBookService/pages/bookServices/detail/index?id=${book.id}&name=${book.name}`, }); }, onRefresh() { - this.setData({ enable: true }); + this.setData({ + enable: true + }); this.getBookList(this.data.path) }, -}); + openDropdown() { + console.log('灞曞紑鍝�', ); + this.setData({ + showDropdown: true + }) + }, + closeDropdown() { + console.log('鍏抽棴'); + this.setData({ + showDropdown: false + }) + } +}); \ No newline at end of file -- Gitblit v1.9.1