From c6abdfaf883e35e9c930dbdbe533d36e2966eb23 Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期一, 08 七月 2024 12:00:37 +0800 Subject: [PATCH] 检索页修改 --- pages/retrievalPage/index.js | 532 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 451 insertions(+), 81 deletions(-) diff --git a/pages/retrievalPage/index.js b/pages/retrievalPage/index.js index 77f1025..4346ab2 100644 --- a/pages/retrievalPage/index.js +++ b/pages/retrievalPage/index.js @@ -1,7 +1,9 @@ // pages/retrievalPage/index.js import request from '../../assets/request/index' -import { handleQueryResourceListData } from '../../assets/js/middleGround/tool' +import { + handleQueryResourceListData +} from '../../assets/js/middleGround/tool' const app = getApp() Page({ @@ -9,41 +11,91 @@ * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - tabPanelstyle: 'display:flex;justify-content:center;align-items:center;', + loading: true, + hidden: true, + input: '', + dialogKey: '', + showWithInput: false, + showTextAndTitleWithInput: false, + downloadLoadin: false, + isMore: null, navBarHeight: '', barHeight: '', searchVal: '', - bookData: [], //鍥句功 + bookData: [], //鍥句功 bookTotal: 0, - courseData: [], //璇剧▼ + courseData: [], //璇剧▼ courseTotal: 0, - digitalTextbooksData: [], //鏁板瓧鏁欐潗 + digitalTextbooksData: [], //鏁板瓧鏁欐潗 digitalTextbooksTotal: 0, seminarData: [], //涓撻鐮旇 seminarTotal: 0, - biblioClassificationData: [],//涔﹀睍 + biblioClassificationData: [], //涔﹀睍 biblioClassificationTotal: 0, - bookFairData: [],//涔︾洰 - bookFairTotal: 0 + bookFairData: [], //涔︾洰 + bookFairTotal: 0, + pageCount: { + page: 1, + total: 0, + }, + tabValue: 0, + tabPanelstyle: 'display:flex;justify-content:center;align-items:center;', + // tab閫夐」 + tabList: [{ + title: "鍥句功", + index: "0", + // bookTotal: this.data.bookTotal + }, + { + title: "璇剧▼", + index: "1", + // bookTotal: this.data.courseTotal + }, + { + title: "鏁板瓧鏁欐潗", + index: "2", + // bookTotal: this.data.digitalTextbooksTotal + }, { + title: "涓撻", + index: "3", + // bookTotal: this.data.seminarTotal + }, + { + title: "涔︾洰", + index: "4", + // bookTotal: this.data.bookFairTotal + }, + { + title: "涔﹀睍", + index: "5", + // bookTotal: this.data.biblioClassificationTotal + }, + ], + tabsId: 0, //榛樿閫夊瀷涓鸿澶� + }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { + console.log(app.config.appId); const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� this.setData({ - navBarHeight: navBarHeight, barHeight: systInfo.statusBarHeight, searchVal: options.searchVal }) - - this.retrievalPageGet() this.bibliographyGet() + let e = { + detail: { + value: "0" + } + } + this.onTabsChange(e) }, /** @@ -105,17 +157,24 @@ this.retrievalPageGet() this.bibliographyGet() }, + + //鏍囩鐨勫垏鎹� onTabsChange(event) { - console.log(`Change tab, tab-panel searchVal is ${event.detail.searchVal}.`); - }, + const value = event.detail.value + console.log(value); + this.setData({ + tabValue: value, + isMore: false + }) - onTabsClick(event) { - console.log(`Click tab, tab-panel searchVal is ${event.detail.searchVal}.`); + if (value === '4') { + this.bibliographyGet() + } else { + this.retrievalPageGet() + } }, - retrievalPageGet() { - let fields = { liveTime: [], lecturer: [], @@ -143,19 +202,17 @@ let queryBook = { AccessControl: { Path: '*', - StoreRefCode: 'defaultGoodsStore27', + StoreRefCode: `defaultGoodsStore${app.config.appId}`, Type: '*', LinkType: '' }, PageQuery: { Start: 0, - Size: 999 + Size: this.data.pageCount.page * 9, }, - SortQuery: [ - { - LinkOrder: 'Desc' - } - ], + SortQuery: [{ + LinkOrder: 'Desc' + }], CreateDate: [], Description: [], Name: [], @@ -172,8 +229,6 @@ ...searchObj, ...fields } - - let courseObj = {} if (this.data.searchVal) { courseObj = { @@ -182,7 +237,6 @@ '||isbn*': this.data.searchVal.trim(), '||seriesName*': this.data.searchVal.trim() } - } //璇剧▼ let queryCourse = { @@ -194,13 +248,11 @@ }, PageQuery: { Start: 0, - Size: 999 + Size: this.data.pageCount.page * 4 }, - SortQuery: [ - { - LinkOrder: 'Desc' - } - ], + SortQuery: [{ + LinkOrder: 'Desc' + }], CreateDate: [], Description: [], Name: [], @@ -238,13 +290,11 @@ }, PageQuery: { Start: 0, - Size: 999 + Size: this.data.pageCount.page * 9, }, - SortQuery: [ - { - LinkOrder: 'Desc' - } - ], + SortQuery: [{ + LinkOrder: 'Desc' + }], CreateDate: [], Description: [], Name: [], @@ -283,13 +333,11 @@ }, PageQuery: { Start: 0, - Size: 999 + Size: this.data.pageCount.page * 6, }, - SortQuery: [ - { - LinkOrder: 'Desc' - } - ], + SortQuery: [{ + LinkOrder: 'Desc' + }], CreateDate: [], Description: [], Name: [], @@ -327,13 +375,11 @@ PageQuery: { Start: 0, - Size: 999 + Size: this.data.pageCount.page * 10 }, - SortQuery: [ - { - LinkOrder: 'Desc' - } - ], + SortQuery: [{ + LinkOrder: 'Desc' + }], CreateDate: [], Description: [], Name: [], @@ -372,8 +418,7 @@ method: 'post', data: body }).then((resp) => { - // console.log(resp); - + console.log(resp, 'resp'); //鍥句功 0 const data1 = resp[0] const datas1 = handleQueryResourceListData({ @@ -382,12 +427,8 @@ }) this.setData({ bookData: datas1, - bookTotal: data1.totalCount + bookTotal: data1.totalCount, }) - - - - //鏁板瓧璇剧▼ 1 const data2 = resp[1] const datas2 = handleQueryResourceListData({ @@ -398,9 +439,6 @@ courseData: datas2, courseTotal: data2.totalCount }) - - - // 鏁板瓧鏁欐潗 2 const data3 = resp[2] const datas3 = handleQueryResourceListData({ @@ -411,15 +449,12 @@ digitalTextbooksData: datas3, digitalTextbooksTotal: data3.totalCount }) - // 涓撻鐮旇 3 - const data4 = resp[3] const datas4 = handleQueryResourceListData({ datas: data4.datas, fields }) - this.setData({ seminarData: datas4, seminarTotal: data4.totalCount @@ -430,21 +465,20 @@ datas: data5.datas, fields }) - datas5.forEach((items) => { items.subtitleName = items.subtitle + items.name }) - console.log(datas5, 'sadasd'); + // console.log(datas5, 'sadasd'); this.setData({ biblioClassificationData: datas5, biblioClassificationTotal: data5.totalCount }) - - - - + this.setData({ + loading: false, + hidden: false, + }) }) - + wx.stopPullDownRefresh() }, bibliographyGet() { let bibliographyObj = {} @@ -462,7 +496,7 @@ queryType: '*', paging: { start: 0, - size: 999 + size: this.data.pageCount.page * 9, }, coverSize: { width: 260 @@ -478,18 +512,17 @@ }, SysType: "CmsItem" }).then(res => { - // console.log(res); + this.setData({ bookFairData: res.datas, bookFairTotal: res.total }) }) + wx.stopPullDownRefresh() }, downloadData(event) { - console.log(111); const item = event.currentTarget.dataset.item; - // console.log(item.datas.freeFile.Value); const URL = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.datas.freeFile.Value item.determine = false console.log(URL, 'URL'); @@ -518,6 +551,10 @@ }); }, onSearchSubmit() { + this.setData({ + loading: true, + hidden: true, + }) console.log(this.data.searchVal); this.retrievalPageGet() this.bibliographyGet() @@ -527,8 +564,6 @@ const item = e.currentTarget.dataset.item wx.navigateTo({ url: '/packageBookService/pages/bookServices/detail/index?id=' + item.id + '&name=' + item.name - - }) }, onBookExhibitionDetails(e) { @@ -539,14 +574,349 @@ url: '/pages/bookExhibitionDetails/index?id=' + item.id + '&bookName=' + item.name // 鍋囪璺宠浆鍒拌鎯呴〉闈紝骞朵紶閫掍簡id鍙傛暟 }); }, - //瑙﹀簳鍑芥暟 - onReachBottom() { - console.log("涓婃媺鍔犺浇...."); - }, + //涓婃媺鍑芥暟 onPullDownRefresh() { console.log("涓嬫媺鍒锋柊..."); }, + /** + * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� + */ + onReachBottom(e) { + console.log(this.data.tabValue); + if (this.data.tabValue == 0) { + console.log(0); + if (this.data.bookData.length < this.data.bookTotal) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.retrievalPageGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + } + + } else if (this.data.tabValue == 1) { + + if (this.data.courseData.length < this.data.courseTotal) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.retrievalPageGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + + } + console.log(2); + } else if (this.data.tabValue == 2) { + + if (this.data.digitalTextbooksData.length < this.data.digitalTextbooksTotal && this.data.digitalTextbooksData.length > 9) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.retrievalPageGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + + } + console.log(2); + } else if (this.data.tabValue == 3) { + if (this.data.seminarData.length < this.data.seminarTotal) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.retrievalPageGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + } + console.log(3); + } else if (this.data.tabValue == 4) { + if (this.data.bookFairData.length < this.data.bookFairTotal) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.bibliographyGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + } + console.log(4); + } else if (this.data.tabValue == 5) { + if (this.data.biblioClassificationData.length < this.data.biblioClassificationTotal) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.retrievalPageGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + } + } + }, + + // 涓嬫媺鍑芥暟 + onPullDownRefresh() { + console.log(456); + if (this.data.tabValue == 4) { + this.setData({ + "pageCount.page": 1 + }) + this.bibliographyGet() + } else { + this.setData({ + "pageCount.page": 1 + }) + this.retrievalPageGet() + } + }, + + underConstruction() { + wx.showToast({ + title: "寤鸿涓�", + icon: 'none', + duration: 1000 + }) + }, + // 閭鐐瑰嚮 + mailbox(e) { + console.log(e); + const key = e.currentTarget.dataset.key; + const item = e.currentTarget.dataset.item; + this.setData({ + [key]: true, + dialogKey: key, + input: '', + Md5: item.datas.freeFile.FileList[0].Md5 + }); + }, + //閭鐨勬牎楠� + onEmailInput(e) { + const isEmailValid = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(e.detail.value); + this.setData({ + emailError: !isEmailValid, + "input": e.detail.value, + }); + }, + //寮圭獥纭 + onConfirm() { + if (!this.data.emailError && this.data.input) { + const { + dialogKey + } = this.data; + this.setData({ + [dialogKey]: false + }); + console.log(this.data.input); + console.log(this.data.Md5); + if (this.data.input) { + let query = { + eMail: this.data.input, + md5s: [this.data.Md5] + } + app.MG.file.sendFileWithEmail(query).then(res => { + console.log(res); + }) + } + } else { + // 鏍¢獙涓嶉�氳繃锛岀粰鍑洪敊璇彁绀� + wx.showToast({ + title: '閭鏍煎紡涓嶆纭�', + icon: 'none', + }); + } + }, + // 寮圭獥鍙栨秷 + closeDialog() { + const { + dialogKey + } = this.data; + this.setData({ + [dialogKey]: false + }); + console.log(111); + }, + onScrollToLower() { + if (this.data.tabValue == 0) { + console.log(0); + if (this.data.bookData.length < this.data.bookTotal) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.retrievalPageGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + + } + + } else if (this.data.tabValue == 1) { + + if (this.data.courseData.length < this.data.courseTotal) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.retrievalPageGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + + } + console.log(2); + } else if (this.data.tabValue == 2) { + + if (this.data.digitalTextbooksData.length < this.data.digitalTextbooksTotal && this.data.digitalTextbooksData.length > 9) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.retrievalPageGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + + } + console.log(2); + } else if (this.data.tabValue == 3) { + if (this.data.seminarData.length < this.data.seminarTotal) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.retrievalPageGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + } + console.log(3); + } else if (this.data.tabValue == 4) { + if (this.data.bookFairData.length < this.data.bookFairTotal) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.bibliographyGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + } + console.log(4); + } else if (this.data.tabValue == 5) { + if (this.data.biblioClassificationData.length < this.data.biblioClassificationTotal) { + this.setData({ + isMore: true, + "pageCount.page": this.data.pageCount.page + 1 + }) + this.retrievalPageGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + } + } + }, + onTabsClick(event) { + console.log(`Click tab, tab-panel value is ${event.detail.value}.`); + }, + tabClick() { + console.log(2323); + }, + // 婊戝姩鏃惰Е鍙戠殑浜嬩欢 + slideOn(e) { + // 鎷垮埌褰撳墠绱㈠紩骞跺姩鎬佹敼鍙� + this.setData({ + tabsId: e.detail.current + }) + }, + + //鐐瑰嚮tab鏃惰Е鍙� + tabsOn(e) { + this.setData({ + //鎷垮埌褰撳墠绱㈠紩骞跺姩鎬佹敼鍙� + tabsId: e.currentTarget.dataset.idx + }) + }, }) \ No newline at end of file -- Gitblit v1.9.1