You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.3 KiB

const app = getApp();
5 years ago
const typeMap = {
course: 0,
shixun: 1,
path: 2,
subject:2
}
const titleMap = {
course:"教学课堂",
shixun:"实训项目",
path:"实践课程"
}
Page({
data:{
statusBarHeight: 24,
current:0,
show:[1],
5 years ago
showSearch:0,
title:"我的教学课堂",
list:[
5 years ago
{text:"课堂", type:"course"},
{text:"实训", type:"shixun"},
5 years ago
{text:"课程", type:"path"}
]
},
5 years ago
onLoad(options){
let { statusBarHeight=24 } = wx.getSystemInfoSync();
this.setData({ statusBarHeight });
5 years ago
if(options.type){
let current = typeMap[options.type]||0;
this.switch({current});
}
},
enterSearch(){
5 years ago
let type = this.data.list[this.data.current].type||'';
app.navigateTo({url:`{search}?type=${type}`});
},
5 years ago
switch({current}){
let title = "我的"+titleMap[this.data.list[current].type];
this.setData({['show['+current+']']:1, current, title})
},
switchNav({target:{dataset:{current}}}){
5 years ago
this.switch({current});
},
switchTab({detail:{current, source, value}}){
if(source=="touch"){
5 years ago
this.switch({current});
}
5 years ago
},
onShareAppMessage(){
5 years ago
let {list, current} = this.data;
return app.shareApp({
5 years ago
path: "/"+this.route+"?type="+list[current].type
})
}
})