| | |
| | | // 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({ |
| | | |
| | |
| | | * 页面的初始数据 |
| | | */ |
| | | 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: 0 |
| | | }, |
| | | { |
| | | title: "课程", |
| | | index: "1", |
| | | bookTotal: 0 |
| | | }, |
| | | { |
| | | title: "数字教材", |
| | | index: "2", |
| | | bookTotal: 0 |
| | | }, { |
| | | title: "专题", |
| | | index: "3", |
| | | bookTotal: 0 |
| | | }, |
| | | { |
| | | title: "书目", |
| | | index: "4", |
| | | bookTotal: 0 |
| | | }, |
| | | { |
| | | title: "书展", |
| | | index: "5", |
| | | bookTotal: 0 |
| | | }, |
| | | ], |
| | | tabsId: 0, //默认选型为装备 |
| | | height: '', |
| | | inputStyle: 'border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx; padding: 0 0 0 16rpx;height:70rpx', |
| | | }, |
| | | |
| | | /** |
| | |
| | | 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) |
| | | // 检查登录状态 |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | if (data) { |
| | | this.getUserInfo() |
| | | } |
| | | }) |
| | | } else { |
| | | this.getUserInfo() |
| | | } |
| | | var that = this; |
| | | // 动态获取屏幕高度 |
| | | wx.getSystemInfo({ |
| | | success: (result) => { |
| | | that.setData({ |
| | | height: result.windowHeight |
| | | }); |
| | | }, |
| | | }) |
| | | }, |
| | | |
| | | // 获取登录用户身份 |
| | | getUserInfo() { |
| | | app.MG.identity.getCurrentAppUser().then(res => { |
| | | // 用户信息优先级:教师认证 > 微信 > 学生(注册时默认) |
| | | if (res) { |
| | | //获取用户类型 |
| | | let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher') |
| | | let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo') |
| | | let eMailData = res.secretList.find(i => i.type == 'EMail') |
| | | if (eMailData) { |
| | | this.setData({ |
| | | input: eMailData.credential |
| | | }) |
| | | } else if (teacherRole && teacherInfos) { |
| | | this.setData({ |
| | | input: JSON.parse(teacherInfos.data).email |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | input: '' |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | }, |
| | | onShareAppMessage() {}, |
| | | onShareTimeline() {}, |
| | | goBack() { |
| | | wx.navigateBack(); |
| | | }, |
| | |
| | | this.retrievalPageGet() |
| | | this.bibliographyGet() |
| | | }, |
| | | |
| | | //标签的切换 |
| | | onTabsChange(event) { |
| | | console.log(`Change tab, tab-panel searchVal is ${event.detail.searchVal}.`); |
| | | }, |
| | | const value = event.detail.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: [], |
| | |
| | | 'Name*': this.data.searchVal.trim(), |
| | | '||author*': this.data.searchVal.trim(), |
| | | '||isbn*': this.data.searchVal.trim(), |
| | | '||seriesName*': this.data.searchVal.trim() |
| | | '||seriesName*': this.data.searchVal.trim(), |
| | | '||projectLeader*': this.data.searchVal.trim() |
| | | } |
| | | |
| | | } |
| | |
| | | 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: [], |
| | |
| | | ...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() |
| | | '||seriesName*': this.data.searchVal.trim(), |
| | | '||projectLeader*': this.data.searchVal.trim() |
| | | } |
| | | |
| | | } |
| | | //课程 |
| | | let queryCourse = { |
| | |
| | | }, |
| | | PageQuery: { |
| | | Start: 0, |
| | | Size: 999 |
| | | Size: this.data.pageCount.page * 4 |
| | | }, |
| | | SortQuery: [ |
| | | { |
| | | LinkOrder: 'Desc' |
| | | } |
| | | ], |
| | | SortQuery: [{ |
| | | LinkOrder: 'Desc' |
| | | }], |
| | | CreateDate: [], |
| | | Description: [], |
| | | Name: [], |
| | |
| | | }, |
| | | PageQuery: { |
| | | Start: 0, |
| | | Size: 999 |
| | | Size: this.data.pageCount.page * 9, |
| | | }, |
| | | SortQuery: [ |
| | | { |
| | | LinkOrder: 'Desc' |
| | | } |
| | | ], |
| | | SortQuery: [{ |
| | | LinkOrder: 'Desc' |
| | | }], |
| | | CreateDate: [], |
| | | Description: [], |
| | | Name: [], |
| | |
| | | ...digitalTextbooksObj, |
| | | ...fields |
| | | } |
| | | |
| | | |
| | | let seminarObj = {} |
| | | if (this.data.searchVal) { |
| | | seminarObj = { |
| | |
| | | }, |
| | | PageQuery: { |
| | | Start: 0, |
| | | Size: 999 |
| | | Size: this.data.pageCount.page * 6, |
| | | }, |
| | | SortQuery: [ |
| | | { |
| | | LinkOrder: 'Desc' |
| | | } |
| | | ], |
| | | SortQuery: [{ |
| | | LinkOrder: 'Desc' |
| | | }], |
| | | CreateDate: [], |
| | | Description: [], |
| | | Name: [], |
| | |
| | | |
| | | PageQuery: { |
| | | Start: 0, |
| | | Size: 999 |
| | | Size: this.data.pageCount.page * 10 |
| | | }, |
| | | SortQuery: [ |
| | | { |
| | | LinkOrder: 'Desc' |
| | | } |
| | | ], |
| | | SortQuery: [{ |
| | | LinkOrder: 'Desc' |
| | | }], |
| | | CreateDate: [], |
| | | Description: [], |
| | | Name: [], |
| | |
| | | method: 'post', |
| | | data: body |
| | | }).then((resp) => { |
| | | // console.log(resp); |
| | | |
| | | //图书 0 |
| | | const data1 = resp[0] |
| | | const datas1 = handleQueryResourceListData({ |
| | |
| | | }) |
| | | this.setData({ |
| | | bookData: datas1, |
| | | bookTotal: data1.totalCount |
| | | bookTotal: data1.totalCount, |
| | | [`tabList[${0}].bookTotal`]: data1.totalCount |
| | | }) |
| | | |
| | | |
| | | |
| | | |
| | | //数字课程 1 |
| | | const data2 = resp[1] |
| | | const datas2 = handleQueryResourceListData({ |
| | |
| | | }) |
| | | this.setData({ |
| | | courseData: datas2, |
| | | courseTotal: data2.totalCount |
| | | courseTotal: data2.totalCount, |
| | | [`tabList[${1}].bookTotal`]: data2.totalCount |
| | | }) |
| | | |
| | | |
| | | |
| | | // 数字教材 2 |
| | | const data3 = resp[2] |
| | | const datas3 = handleQueryResourceListData({ |
| | |
| | | }) |
| | | this.setData({ |
| | | digitalTextbooksData: datas3, |
| | | digitalTextbooksTotal: data3.totalCount |
| | | digitalTextbooksTotal: data3.totalCount, |
| | | [`tabList[${2}].bookTotal`]: data3.totalCount |
| | | }) |
| | | |
| | | // 专题研讨 3 |
| | | |
| | | const data4 = resp[3] |
| | | const datas4 = handleQueryResourceListData({ |
| | | datas: data4.datas, |
| | | fields |
| | | }) |
| | | |
| | | this.setData({ |
| | | seminarData: datas4, |
| | | seminarTotal: data4.totalCount |
| | | seminarTotal: data4.totalCount, |
| | | [`tabList[${3}].bookTotal`]: data4.totalCount |
| | | }) |
| | | // 书展 4 |
| | | const data5 = resp[4] |
| | |
| | | datas: data5.datas, |
| | | fields |
| | | }) |
| | | |
| | | datas5.forEach((items) => { |
| | | items.subtitleName = items.subtitle + items.name |
| | | }) |
| | | console.log(datas5, 'sadasd'); |
| | | this.setData({ |
| | | biblioClassificationData: datas5, |
| | | biblioClassificationTotal: data5.totalCount |
| | | biblioClassificationTotal: data5.totalCount, |
| | | [`tabList[${5}].bookTotal`]: data5.totalCount |
| | | }) |
| | | |
| | | |
| | | |
| | | |
| | | this.setData({ |
| | | loading: false, |
| | | hidden: false, |
| | | isMore: null |
| | | }) |
| | | }) |
| | | |
| | | wx.stopPullDownRefresh() |
| | | }, |
| | | bibliographyGet() { |
| | | let bibliographyObj = {} |
| | |
| | | queryType: '*', |
| | | paging: { |
| | | start: 0, |
| | | size: 999 |
| | | size: this.data.pageCount.page * 9, |
| | | }, |
| | | coverSize: { |
| | | width: 260 |
| | |
| | | }, |
| | | SysType: "CmsItem" |
| | | }).then(res => { |
| | | // console.log(res); |
| | | |
| | | this.setData({ |
| | | bookFairData: res.datas, |
| | | bookFairTotal: res.total |
| | | bookFairTotal: res.total, |
| | | [`tabList[${4}].bookTotal`]: 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'); |
| | | setTimeout(() => { |
| | | if (URL) { |
| | | item.determine = true |
| | |
| | | } |
| | | }); |
| | | }, |
| | | openBookFair(event) { |
| | | const item = event.currentTarget.dataset.item |
| | | if (item.fileType == "pdf") { |
| | | wx.navigateTo({ |
| | | url: "/packageBookService/pages/components/webView/index?md5=" + |
| | | item.freeFile + |
| | | "&fileName=" + |
| | | item.name + |
| | | "&fileType=" + |
| | | item.fileType + "&bookBuy=true" |
| | | // "&freePage=" + |
| | | // this.data.fileInfo.freePage + |
| | | |
| | | + |
| | | "&bookId=" + |
| | | item.id, |
| | | }); |
| | | } else { |
| | | Toast({ |
| | | context: this, |
| | | selector: '#t-toast', |
| | | message: '此书不能查看', |
| | | theme: 'warning', |
| | | direction: 'column', |
| | | }); |
| | | } |
| | | }, |
| | | onSearchSubmit() { |
| | | console.log(this.data.searchVal); |
| | | this.setData({ |
| | | loading: true, |
| | | hidden: true, |
| | | }) |
| | | 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 |
| | | |
| | | |
| | | 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("下拉刷新..."); |
| | | }, |
| | | |
| | | // 下拉函数 |
| | | onPullDownRefresh() { |
| | | 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) { |
| | | const key = e.currentTarget.dataset.key; |
| | | const item = e.currentTarget.dataset.item; |
| | | this.setData({ |
| | | [key]: true, |
| | | dialogKey: key, |
| | | 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 |
| | | }); |
| | | 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 |
| | | }); |
| | | }, |
| | | onScrollToLower() { |
| | | if (this.data.tabValue == 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) |
| | | |
| | | } |
| | | } 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) |
| | | |
| | | } |
| | | } 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) |
| | | } |
| | | } 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) |
| | | } |
| | | } 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) |
| | | } |
| | | } |
| | | }, |
| | | |
| | | // 滑动时触发的事件 |
| | | slideOn(e) { |
| | | // 拿到当前索引并动态改变 |
| | | this.setData({ |
| | | tabsId: e.detail.current |
| | | }) |
| | | }, |
| | | |
| | | //点击tab时触发 |
| | | tabsOn(e) { |
| | | this.setData({ |
| | | //拿到当前索引并动态改变 |
| | | tabsId: e.currentTarget.dataset.idx |
| | | }) |
| | | }, |
| | | |
| | | }) |