2025-06-06 15:17:30 +08:00
|
|
|
|
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 {
|
2026-08-04 09:59:35 +08:00
|
|
|
|
const data = Object.assign({}, e.currentTarget.dataset.item, { id: this.data.id })
|
|
|
|
|
|
const playlist = []
|
|
|
|
|
|
const collectResources = (nodes) => {
|
|
|
|
|
|
(nodes || []).forEach((node) => {
|
|
|
|
|
|
(node.resourceDetails || []).forEach((item) => playlist.push(Object.assign({}, item, { id: this.data.id })))
|
|
|
|
|
|
collectResources(node.children)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
collectResources(this.data.list)
|
|
|
|
|
|
const currentIndex = Math.max(playlist.findIndex((item) => item.resourceUrl === data.resourceUrl), 0)
|
2025-06-06 15:17:30 +08:00
|
|
|
|
wx.navigateTo({
|
2026-08-04 09:59:35 +08:00
|
|
|
|
url: '/subpackage/teacher/resource-detail/resource-detail?data='+encodeURIComponent(JSON.stringify(data)),
|
|
|
|
|
|
success(res) {
|
|
|
|
|
|
res.eventChannel.emit('setPlaylist', { playlist, currentIndex })
|
|
|
|
|
|
}
|
2025-06-06 15:17:30 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
|
*/
|
|
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
|
*/
|
|
|
|
|
|
onShow() {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
|
*/
|
|
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
|
*/
|
|
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
|
*/
|
|
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
|
*/
|
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 用户点击右上角分享
|
|
|
|
|
|
*/
|
|
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2026-08-04 09:59:35 +08:00
|
|
|
|
})
|