152 lines
3.2 KiB
JavaScript
152 lines
3.2 KiB
JavaScript
// subpackage/student/teach/teach.js
|
|
const { getTeachType, getHotVic ,getTeachList, vicBtn, redeemClassList} = require("../../../utils/serve/user");
|
|
const tabService = require("../../../utils/tab-serve");
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
teachTypeList:[],
|
|
teachList:[],
|
|
buyTypeList:[], //购买课程类型列表
|
|
buyList:[], //
|
|
buyId:0,
|
|
buyTypeId:0,
|
|
hotList:[],
|
|
typeId:1,
|
|
hotId:0,
|
|
playId:0,
|
|
nowIsBuy:false,//当前课程是否购买
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
async onLoad(options) {
|
|
this.getData()
|
|
},
|
|
|
|
async getData(){
|
|
const that = this
|
|
const res = await getHotVic()
|
|
const re = await getTeachType()
|
|
const rea = await redeemClassList()
|
|
await that.getListt(re.data[0].id , 'teachList')
|
|
await that.getListt(rea.data[0].id , 'buyList')
|
|
this.setData({
|
|
teachTypeList:re.data,
|
|
hotList:res.data,
|
|
typeId:re.data[0].id,
|
|
buyTypeList:rea.data,
|
|
buyTypeId:rea.data[0].id,
|
|
nowIsBuy:rea.data[0].isPurchase
|
|
})
|
|
},
|
|
|
|
//获取教学视频列表
|
|
async getListt(idd,type){
|
|
const res = await getTeachList({
|
|
TaxonomyId:idd,
|
|
PageIndex:1,
|
|
PageSize:50
|
|
})
|
|
this.setData({
|
|
[type]:res.data.datas
|
|
})
|
|
},
|
|
|
|
//点击tab
|
|
changeTab(e){
|
|
console.log(e)
|
|
const key = e.target.dataset.key
|
|
this.setData({
|
|
[key]:e.currentTarget.id
|
|
})
|
|
if(key == 'buyTypeId'){
|
|
this.setData({
|
|
nowIsBuy:e.target.dataset.buy
|
|
})
|
|
}
|
|
this.getListt(e.currentTarget.id,key == 'typeId' ? 'teachList' : 'buyList')
|
|
},
|
|
|
|
//点击视频
|
|
async vicTap(e){
|
|
console.log(e)
|
|
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))
|
|
},
|
|
|
|
//跳转场馆列表
|
|
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() {
|
|
|
|
}
|
|
}) |