152 lines
3.2 KiB
JavaScript
Raw Normal View History

2025-06-06 15:17:30 +08:00
// subpackage/student/teach/teach.js
2026-04-16 13:38:33 +08:00
const { getTeachType, getHotVic ,getTeachList, vicBtn, redeemClassList} = require("../../../utils/serve/user");
2025-06-06 15:17:30 +08:00
const tabService = require("../../../utils/tab-serve");
Page({
/**
* 页面的初始数据
*/
data: {
teachTypeList:[],
teachList:[],
2026-04-16 13:38:33 +08:00
buyTypeList:[], //购买课程类型列表
buyList:[], //
buyId:0,
buyTypeId:0,
2025-06-06 15:17:30 +08:00
hotList:[],
typeId:1,
2026-04-16 13:38:33 +08:00
hotId:0,
playId:0,
nowIsBuy:false,//当前课程是否购买
2025-06-06 15:17:30 +08:00
},
/**
* 生命周期函数--监听页面加载
*/
async onLoad(options) {
this.getData()
},
async getData(){
const that = this
const res = await getHotVic()
const re = await getTeachType()
2026-04-16 13:38:33 +08:00
const rea = await redeemClassList()
await that.getListt(re.data[0].id , 'teachList')
await that.getListt(rea.data[0].id , 'buyList')
2025-06-06 15:17:30 +08:00
this.setData({
teachTypeList:re.data,
hotList:res.data,
typeId:re.data[0].id,
2026-04-16 13:38:33 +08:00
buyTypeList:rea.data,
buyTypeId:rea.data[0].id,
nowIsBuy:rea.data[0].isPurchase
2025-06-06 15:17:30 +08:00
})
},
//获取教学视频列表
2026-04-16 13:38:33 +08:00
async getListt(idd,type){
2025-06-06 15:17:30 +08:00
const res = await getTeachList({
TaxonomyId:idd,
PageIndex:1,
PageSize:50
})
this.setData({
2026-04-16 13:38:33 +08:00
[type]:res.data.datas
2025-06-06 15:17:30 +08:00
})
},
//点击tab
changeTab(e){
2026-04-16 13:38:33 +08:00
console.log(e)
const key = e.target.dataset.key
2025-06-06 15:17:30 +08:00
this.setData({
2026-04-16 13:38:33 +08:00
[key]:e.currentTarget.id
2025-06-06 15:17:30 +08:00
})
2026-04-16 13:38:33 +08:00
if(key == 'buyTypeId'){
this.setData({
nowIsBuy:e.target.dataset.buy
})
}
this.getListt(e.currentTarget.id,key == 'typeId' ? 'teachList' : 'buyList')
2025-06-06 15:17:30 +08:00
},
//点击视频
async vicTap(e){
console.log(e)
2026-04-16 13:38:33 +08:00
const idd = e.currentTarget.id
if(e.currentTarget.dataset.idkey == 'buyId' && !this.data.nowIsBuy){
return wx.showToast({
title: '购买冠军跳绳并扫码兑换课程后即可激活课程哦~',
icon:'none'
})
}
if(idd == this.data[e.currentTarget.dataset.idkey]) return console.log('aaa')
this.setData({
[e.currentTarget.dataset.idkey]:idd
})
await vicBtn(Number(idd))
2025-06-06 15:17:30 +08:00
},
//跳转场馆列表
goList(){
wx.navigateTo({
url: '/subpackage/teacher/room-list/room-list',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
tabService.updateIndex(this,1)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
async onPullDownRefresh() {
console.log('下拉刷新')
await this.getData()
wx.showToast({
title: '刷新成功',
icon:'none'
})
wx.stopPullDownRefresh()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})