|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
courseList: [],
|
|
|
isAdmin: true
|
|
|
},
|
|
|
enterCourse : function(event) {
|
|
|
const courseId = event.currentTarget.dataset.id;
|
|
|
const description = event.currentTarget.dataset.description;
|
|
|
wx.setStorageSync('courseId', courseId);
|
|
|
wx.setStorageSync('description', description);
|
|
|
console.log('courseId', courseId);
|
|
|
console.log('description', description);
|
|
|
if (this.data.isAdmin) {
|
|
|
wx.navigateTo({url: '/pages/course_detail/course_detail'});
|
|
|
} else {
|
|
|
wx.navigateTo({url: '/pages/course_detail(2)/course_detail(2)'});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad(options) {
|
|
|
const that = this;
|
|
|
that.setData ({
|
|
|
isAdmin: wx.getStorageSync("isAdmin")
|
|
|
});
|
|
|
if (that.data.isAdmin) {
|
|
|
wx.request({
|
|
|
url: 'http://10.133.15.50:8888/admin/ownCourseList',
|
|
|
method: 'GET',
|
|
|
header: {
|
|
|
admin_token: wx.getStorageSync('token') // 携带token
|
|
|
},
|
|
|
success(res) {
|
|
|
if (res.statusCode === 200) {
|
|
|
console.log(res.data.data);
|
|
|
that.setData({
|
|
|
courseList: res.data.data
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
fail(error) {
|
|
|
console.error(err);
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
wx.request({
|
|
|
url: 'http://10.133.15.50:8888/student/ownCourseList',
|
|
|
method: 'GET',
|
|
|
header: {
|
|
|
student_token: wx.getStorageSync('token') // 携带token
|
|
|
},
|
|
|
success(res) {
|
|
|
if (res.statusCode === 200) {
|
|
|
console.log(res.data.data);
|
|
|
that.setData({
|
|
|
courseList: res.data.data
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
fail(error) {
|
|
|
console.error(err);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
util: function (currentStatu) {
|
|
|
/* 动画部分 */
|
|
|
// 第1步:创建动画实例
|
|
|
var animation = wx.createAnimation({
|
|
|
duration: 200, //动画时长
|
|
|
timingFunction: "linear", //线性
|
|
|
delay: 0 //0则不延迟
|
|
|
});
|
|
|
// 第2步:这个动画实例赋给当前的动画实例
|
|
|
this.animation = animation;
|
|
|
|
|
|
// 第3步:执行第一组动画
|
|
|
animation.opacity(0).rotateX(-100).step();
|
|
|
|
|
|
// 第4步:导出动画对象赋给数据对象储存
|
|
|
this.setData({
|
|
|
animationData: animation.export()
|
|
|
})
|
|
|
|
|
|
// 第5步:设置定时器到指定时候后,执行第二组动画
|
|
|
setTimeout(function () {
|
|
|
// 执行第二组动画
|
|
|
animation.opacity(1).rotateX(0).step();
|
|
|
// 给数据对象储存的第一组动画,更替为执行完第二组动画的动画对象
|
|
|
this.setData({
|
|
|
animationData: animation
|
|
|
})
|
|
|
//关闭
|
|
|
if (currentStatu == "close") {
|
|
|
this.setData({
|
|
|
showModalStatus: false
|
|
|
});
|
|
|
}
|
|
|
}.bind(this), 200)
|
|
|
// 显示
|
|
|
if (currentStatu == "open") {
|
|
|
this.setData({
|
|
|
showModalStatus: true
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
}) |