// pages/retrievalPage/index.js import request from '../../assets/request/index' import { handleQueryResourceListData } from '../../assets/js/middleGround/tool' const app = getApp() Page({ /** * 页面的初始数据 */ data: { tabPanelstyle: 'display:flex;justify-content:center;align-items:center;', navBarHeight: '', barHeight: '', searchVal: '', bookData: [], //图书 bookTotal: 0, courseData: [], //课程 courseTotal: 0, digitalTextbooksData: [], //数字教材 digitalTextbooksTotal: 0, seminarData: [], //专题研讨 seminarTotal: 0, biblioClassificationData: [],//书展 biblioClassificationTotal: 0, bookFairData: [],//书目 bookFairTotal: 0 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { 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() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, goBack() { wx.navigateBack(); }, //取消按钮 onCancellation() { this.setData({ searchVal: '' }) this.retrievalPageGet() this.bibliographyGet() }, onTabsChange(event) { console.log(`Change tab, tab-panel searchVal is ${event.detail.searchVal}.`); }, onTabsClick(event) { console.log(`Click tab, tab-panel searchVal is ${event.detail.searchVal}.`); }, retrievalPageGet() { let fields = { liveTime: [], lecturer: [], startTime: [], jsek_link: [], courseLeader: [], affiliatedUnit: [], publishingUnit: [], classHours: [], author: [], subtitle: [] } let searchObj = {} if (this.data.searchVal) { searchObj = { 'Name*': this.data.searchVal.trim(), '||author*': this.data.searchVal.trim(), '||isbn*': this.data.searchVal.trim(), '||seriesName*': this.data.searchVal.trim() } } let url = '/store/api/ApiQueryProductByAppUser' //图书 let queryBook = { AccessControl: { Path: '*', StoreRefCode: 'defaultGoodsStore27', Type: '*', LinkType: '' }, PageQuery: { Start: 0, Size: 999 }, SortQuery: [ { LinkOrder: 'Desc' } ], CreateDate: [], Description: [], Name: [], Icon: [], RefCode: [], TypeId: [], SysType: [], State: [], Tag: [], BeginDate: [], EndDate: [], ProductLinkInfo: [], AllowDonate: [], ...searchObj, ...fields } let courseObj = {} if (this.data.searchVal) { courseObj = { 'Name*': this.data.searchVal.trim(), '||author*': this.data.searchVal.trim(), '||isbn*': this.data.searchVal.trim(), '||seriesName*': this.data.searchVal.trim() } } //课程 let queryCourse = { AccessControl: { Path: '*', StoreRefCode: 'jsek_digitalCourses', Type: '*', LinkType: '' }, PageQuery: { Start: 0, Size: 999 }, SortQuery: [ { LinkOrder: 'Desc' } ], CreateDate: [], Description: [], Name: [], Icon: [], RefCode: [], TypeId: [], SysType: [], State: [], Tag: [], BeginDate: [], EndDate: [], ProductLinkInfo: [], AllowDonate: [], ...courseObj, ...fields } let digitalTextbooksObj = {} if (this.data.searchVal) { digitalTextbooksObj = { 'Name*': this.data.searchVal.trim(), '||author*': this.data.searchVal.trim(), '||isbn*': this.data.searchVal.trim(), '||seriesName*': this.data.searchVal.trim() } } // 数字教材 let queryDigitalTextbooks = { AccessControl: { Path: '*', StoreRefCode: 'jsek_digitalTextbooks', Type: '*', LinkType: '' }, PageQuery: { Start: 0, Size: 999 }, SortQuery: [ { LinkOrder: 'Desc' } ], CreateDate: [], Description: [], Name: [], Icon: [], RefCode: [], TypeId: [], SysType: [], State: [], Tag: [], BeginDate: [], EndDate: [], ProductLinkInfo: [], AllowDonate: [], ...digitalTextbooksObj, ...fields } let seminarObj = {} if (this.data.searchVal) { seminarObj = { 'Name*': this.data.searchVal.trim(), '||author*': this.data.searchVal.trim(), '||isbn*': this.data.searchVal.trim(), '||seriesName*': this.data.searchVal.trim() } } // 专题研讨 let querySeminar = { AccessControl: { Path: '*', StoreRefCode: 'jsek_seminar', Type: '*', LinkType: '' }, PageQuery: { Start: 0, Size: 999 }, SortQuery: [ { LinkOrder: 'Desc' } ], CreateDate: [], Description: [], Name: [], Icon: [], RefCode: [], TypeId: [], SysType: [], State: [], Tag: [], BeginDate: [], EndDate: [], ProductLinkInfo: [], AllowDonate: [], ...fields, ...seminarObj } let biblioClassificationObj = {} if (this.data.searchVal) { biblioClassificationObj = { 'Name*': this.data.searchVal.trim(), '||author*': this.data.searchVal.trim(), '||isbn*': this.data.searchVal.trim(), '||seriesName*': this.data.searchVal.trim() } } //书展 let queryBiblioClassification = { AccessControl: { Path: '*', StoreRefCode: 'jsek_bookFair', Type: '*', LinkType: '' }, PageQuery: { Start: 0, Size: 999 }, SortQuery: [ { LinkOrder: 'Desc' } ], CreateDate: [], Description: [], Name: [], Icon: [], RefCode: [], TypeId: [], SysType: [], State: [], Tag: [], BeginDate: [], EndDate: [], ProductLinkInfo: [], AllowDonate: [], content: [], backgroundSelection: [], ...fields, ...biblioClassificationObj } let body = { query: JSON.stringify({ Query: [{ queryBook: queryBook }, { queryCourse: queryCourse }, { queryDigitalTextbooks: queryDigitalTextbooks }, { querySeminar: querySeminar }, { queryBiblioClassification: queryBiblioClassification }] }) } request({ url: url, method: 'post', data: body }).then((resp) => { // console.log(resp); //图书 0 const data1 = resp[0] const datas1 = handleQueryResourceListData({ datas: data1.datas, fields }) this.setData({ bookData: datas1, bookTotal: data1.totalCount }) //数字课程 1 const data2 = resp[1] const datas2 = handleQueryResourceListData({ datas: data2.datas, fields }) this.setData({ courseData: datas2, courseTotal: data2.totalCount }) // 数字教材 2 const data3 = resp[2] const datas3 = handleQueryResourceListData({ datas: data3.datas, fields }) this.setData({ digitalTextbooksData: datas3, digitalTextbooksTotal: data3.totalCount }) // 专题研讨 3 const data4 = resp[3] const datas4 = handleQueryResourceListData({ datas: data4.datas, fields }) this.setData({ seminarData: datas4, seminarTotal: data4.totalCount }) // 书展 4 const data5 = resp[4] const datas5 = handleQueryResourceListData({ datas: data5.datas, fields }) datas5.forEach((items) => { items.subtitleName = items.subtitle + items.name }) console.log(datas5, 'sadasd'); this.setData({ biblioClassificationData: datas5, biblioClassificationTotal: data5.totalCount }) }) }, bibliographyGet() { let bibliographyObj = {} if (this.data.searchVal) { bibliographyObj = { 'Name*': this.data.searchVal.trim(), '||author*': this.data.searchVal.trim(), '||isbn*': this.data.searchVal.trim(), '||seriesName*': this.data.searchVal.trim() } } app.MG.resource.getItem({ path: 'jsek_biblioClassification', queryType: '*', paging: { start: 0, size: 999 }, coverSize: { width: 260 }, fields: { jsek_link: [], content: [], subtitle: [], fileType: [], jsek_resource: [], freeFile: [], ...bibliographyObj }, SysType: "CmsItem" }).then(res => { // console.log(res); this.setData({ bookFairData: res.datas, bookFairTotal: res.total }) }) }, 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'); setTimeout(() => { if (URL) { item.determine = true } }, 600) wx.downloadFile({ url: URL, success: function (res) { const filePath = res.tempFilePath; wx.openDocument({ filePath: filePath, success: function (res) { console.log('打开文档成功'); }, fail: function (res) { console.log('打开文档失败', res); } }); }, fail: function (res) { console.log('下载文件失败', res); } }); }, onSearchSubmit() { console.log(this.data.searchVal); this.retrievalPageGet() this.bibliographyGet() }, onBook(e) { console.log(e.currentTarget.dataset.item); const item = e.currentTarget.dataset.item wx.navigateTo({ url: '/packageBookService/pages/bookServices/detail/index?id=' + item.id + '&name=' + item.name }) }, onBookExhibitionDetails(e) { console.log(e.currentTarget.dataset.item); const item = e.currentTarget.dataset.item wx.navigateTo({ url: '/pages/bookExhibitionDetails/index?id=' + item.id + '&bookName=' + item.name // 假设跳转到详情页面,并传递了id参数 }); }, //触底函数 onReachBottom() { console.log("上拉加载...."); }, //上拉函数 onPullDownRefresh() { console.log("下拉刷新..."); }, })