118 lines
2.4 KiB
JavaScript
118 lines
2.4 KiB
JavaScript
const { getResourceDetail } = require("../../../utils/serve/teacher")
|
||
|
||
// subpackage/teacher/resource/resource.js
|
||
Page({
|
||
|
||
/**
|
||
* 页面的初始数据
|
||
*/
|
||
data: {
|
||
id:2,
|
||
list:[],
|
||
title:'',
|
||
url:'https://yuedong-wechatapplet.oss-cn-shanghai.aliyuncs.com/static/teacher/1-card-bg.png'
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面加载
|
||
*/
|
||
async onLoad(options) {
|
||
const that = this
|
||
const {id} = options
|
||
const res = await getResourceDetail({
|
||
id:id
|
||
})
|
||
that.setData({
|
||
list:res.data,
|
||
id:id,
|
||
title:id == 1 ? '口令':id==2?'音乐':id==3?'教案':'视频',
|
||
url:`https://yuedong-wechatapplet.oss-cn-shanghai.aliyuncs.com/static/teacher/${id}-card-bg.png`
|
||
},()=>{
|
||
console.log(res)
|
||
console.log(that.data.list)
|
||
})
|
||
|
||
|
||
},
|
||
|
||
goDetail(e){
|
||
console.log(e)
|
||
if(this.data.id == 3){
|
||
wx.showLoading({
|
||
title: '加载中',
|
||
})
|
||
wx.downloadFile({
|
||
// 示例 url,并非真实存在
|
||
url: e.currentTarget.dataset.item.resourceUrl,
|
||
success: function (res) {
|
||
wx.hideLoading()
|
||
const filePath = res.tempFilePath
|
||
wx.openDocument({
|
||
filePath: filePath,
|
||
// showMenu:true,
|
||
success: function (res) {
|
||
console.log('打开文档成功')
|
||
}
|
||
})
|
||
}
|
||
})
|
||
}else if(this.data.id == 4){
|
||
return
|
||
}else {
|
||
const data = e.currentTarget.dataset.item
|
||
data.id = this.data.id
|
||
wx.navigateTo({
|
||
url: '/subpackage/teacher/resource-detail/resource-detail?data='+JSON.stringify(data),
|
||
})
|
||
}
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面初次渲染完成
|
||
*/
|
||
onReady() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面显示
|
||
*/
|
||
onShow() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面隐藏
|
||
*/
|
||
onHide() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面卸载
|
||
*/
|
||
onUnload() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面相关事件处理函数--监听用户下拉动作
|
||
*/
|
||
onPullDownRefresh() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面上拉触底事件的处理函数
|
||
*/
|
||
onReachBottom() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 用户点击右上角分享
|
||
*/
|
||
onShareAppMessage() {
|
||
|
||
}
|
||
}) |