const DEFAULT_PAGE = 0; const baseUrl = getApp(); const api = require('../../config/api.js'); const util = require('../../config/util.js'); import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast'; Page({ /** * 页面的初始数据 */ data: { startPageX: 0, currentView: DEFAULT_PAGE, baseurl: baseUrl.globalData.baseimgurl, movies: [], active: 1, challengeactive: 1, toView: `card_${DEFAULT_PAGE}`, list: [], itemdata: [], resfiles_id: 1, pathid: "", showdiage: false }, getpaperattrlist: function (params) { const that = this; let url = baseUrl.globalData.baseUrl + '/res/getrespagelist'; var param = { resfiles_id: params }; //此处为使用封装的post请求 util.get(url, param).then((res) => { console.log(res); that.setData({ itemdata: res.data }); }).catch((errMsg) => { console.log(errMsg); }); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options); this.setData({ resfiles_id: options.id }) }, onshowdiageClose() { console.log('324323222222') this.setData({ showdiage: false }); console.log(this.data.showdiage) }, downfilepoto: function (knowfiles) { // let files = knowfiles.currentTarget.id; let files = this.data.pathid wx.downloadFile({ url: files, success(res) { wx.openDocument({ filePath: res.tempFilePath, showMenu: true, //关键点 success() { } }) } }) }, downfile: function (knowfiles) { let files = this.data.pathid;// knowfiles.currentTarget.id; wx.downloadFile({ url: files, success(res) { wx.shareFileMessage({ filePath: res.tempFilePath, success() { }, fail: console.error, }) } }) }, showdiagePopup(e) { console.log(e); let pathid = e.currentTarget.id; let files = pathid; // knowfiles.currentTarget.id; if (files.length == 0) { wx.showToast({ title: '暂时还没有讲义,不可下载',//提示文字 duration: 2000,//显示时长 mask: true,//是否显示透明蒙层,防止触摸穿透,默认:false icon: 'none', //图标,支持"success"、"loading" success: function () { return; },//接口调用成功 fail: function () { }, //接口调用失败的回调函数 complete: function () { } //接口调用结束的回调函数 }) } else { this.setData({ showdiage: true, pathid: pathid }); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getpaperattrlist(this.data.resfiles_id); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, })