// teacher/pages/workPushDetail/workPushDetail.js import { request } from "../../../utils/api" Page({ /** * 页面的初始数据 */ data: { vh: 0, //作业ID workId: 0, // 作业详情 workDetail: {}, // 班级信息列表 classList: [], workPath: '' }, // 下载文件 download() { let that = this wx.showToast({ title: '下载中', icon: "loading" }) wx.downloadFile({ url: that.data.workDetail.homeworkPath, success(res) { console.log(res, "res") const filePath = res.tempFilePath; that.setData({ workPath: filePath }) wx.hideToast() } }) }, // 打开文件 openWork() { wx.showToast({ title: '打开中', icon: "loading" }) wx.openDocument({ filePath: this.data.workPath, // showMenu: true, // fileType:, success: function (resp) { console.log('打开文档成功', resp) wx.hideToast() } }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(options) let { workId } = options this.setData({ workId }) let data = wx.getSystemInfo({ success: (res) => { console.log(res) this.setData({ vh: res.windowHeight }) } }) }, // 获取作业详细信息 async getPushWorkDetail() { let res = await request('/app-api/tutor/h5/getHomeworkDetail', "GET", { id: this.data.workId }) this.setData({ workDetail: res.data }) console.log(res, "work") }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { wx.hideHomeButton() this.getPushWorkDetail() }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })