// pages/bibliographyList/index.js const app = getApp() const config = Page({ /** * 页面的初始数据 */ data: { higherList: [], vocationalList: [], teacherList: [], higherTotal: 0, vocationalTotal: 0, teacherTotal: 0, value: '', BarHeight: '', navBarHeight: '' }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.higherGet() this.vocationalGet() this.teacherGet() const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 this.setData({ navBarHeight: navBarHeight, barHeight: systInfo.statusBarHeight, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { console.log(this.data.value); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, onTabsChange(event) { console.log(`Change tab, tab-panel value is ${event.detail.value}.`); }, onTabsClick(event) { console.log(`Click tab, tab-panel value is ${event.detail.value}.`); }, //高等教育 higherGet(keyword) { let searchObj = { 'Name*': keyword, '||author*': keyword, '||isbn*': keyword } app.MG.resource.getItem({ path: 'jsek_biblioClassification\\jsek_bCHigherEducation', queryType: '*', paging: { start: '0', size: '999' }, coverSize: { width: 260 }, fields: { jsek_link: [], content: [], subtitle: [], fileType: [], jsek_resource: [], freeFile: [], ...searchObj, }, SysType: 'CmsItem' }).then(res => { res.datas.forEach(item => { item.determine = true }) console.log(res, 789111); this.setData({ higherList: res.datas, higherTotal: res.total }) console.log(this.data.higherList, '5555'); }) }, //教师教育 vocationalGet(keyword) { let searchObj = { 'Name*': keyword, '||author*': keyword, '||isbn*': keyword } app.MG.resource.getItem({ path: 'jsek_biblioClassification\\jsek_bCVocationalEducation', queryType: '*', paging: { start: '0', size: '999' }, coverSize: { width: 260 }, fields: { jsek_link: [], content: [], subtitle: [], fileType: [], jsek_resource: [], freeFile: [], ...searchObj }, SysType: 'CmsItem' }).then(res => { res.datas.forEach(item => { item.determine = true }) this.setData({ vocationalList: res.datas, vocationalTotal: res.total }) }) }, // 职业教育 teacherGet(keyword) { let searchObj = { 'Name*': keyword, '||author*': keyword, '||isbn*': keyword } app.MG.resource.getItem({ path: 'jsek_biblioClassification\\jsek_bCTeacherEducation', queryType: '*', paging: { start: '0', size: '999' }, coverSize: { width: 260 }, fields: { jsek_link: [], content: [], subtitle: [], fileType: [], jsek_resource: [], freeFile: [], ...searchObj }, SysType: 'CmsItem' }).then(res => { res.datas.forEach(item => { item.determine = true }) this.setData({ teacherList: res.datas, teacherTotal: res.total }) }) }, downloadData(event) { console.log(111); const item = event.currentTarget.dataset.item; // console.log(item.datas.freeFile.Value); const URL = 'http://182.92.203.7:3001/file/api/ApiDownload?md5=' + item.datas.freeFile.Value item.determine = false 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: function (e) { const keyword = e.detail.value; // 处理搜索逻辑,例如发送搜索请求等 console.log('搜索关键词:', keyword); this.higherGet(keyword) this.vocationalGet(keyword) this.teacherGet(keyword) }, goBack() { wx.navigateBack(); }, })