|
@@ -1,38 +1,75 @@
|
|
-const app = getApp();
|
|
|
|
|
|
+const app = getApp()
|
|
Page({
|
|
Page({
|
|
- /**
|
|
|
|
- * 页面的初始数据
|
|
|
|
- */
|
|
|
|
data: {
|
|
data: {
|
|
frameStyle: { useTop: true, name: '课程详细信息', leftArrow: true, useBar: false },
|
|
frameStyle: { useTop: true, name: '课程详细信息', leftArrow: true, useBar: false },
|
|
|
|
+ id: '',
|
|
|
|
+ form: {},
|
|
|
|
+ user: {},
|
|
|
|
+ //状态
|
|
|
|
+ statusList: [],
|
|
},
|
|
},
|
|
// 跳转菜单
|
|
// 跳转菜单
|
|
back(e) {
|
|
back(e) {
|
|
wx.navigateBack({ delta: 1 })
|
|
wx.navigateBack({ delta: 1 })
|
|
},
|
|
},
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
- onLoad: function (options) {
|
|
|
|
-
|
|
|
|
|
|
+ onLoad: async function (options) {
|
|
|
|
+ const that = this;
|
|
|
|
+ await that.setData({ id: options.id || null })
|
|
|
|
+ // 查询其他信息
|
|
|
|
+ await that.searchOther();
|
|
|
|
+ // 监听用户是否登录
|
|
|
|
+ await that.watchLogin();
|
|
|
|
+ },
|
|
|
|
+ searchOther: async function () {
|
|
|
|
+ const that = this;
|
|
|
|
+ let arr;
|
|
|
|
+ // 状态
|
|
|
|
+ arr = await app.$get(`/dict`, { code: 'lesson_status' });
|
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list });
|
|
|
|
+ },
|
|
|
|
+ // 监听用户是否登录
|
|
|
|
+ watchLogin: async function () {
|
|
|
|
+ const that = this;
|
|
|
|
+ let statusList = that.data.statusList;
|
|
|
|
+ wx.getStorage({
|
|
|
|
+ key: 'user',
|
|
|
|
+ success: async res => {
|
|
|
|
+ that.setData({ user: res.data })
|
|
|
|
+ if (that.data.id) {
|
|
|
|
+ const arr = await app.$get(`/lesson/${that.data.id}`);
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ // 课程状态
|
|
|
|
+ let status = statusList.find(i => i.value == arr.data.status)
|
|
|
|
+ if (status) arr.data.zhStatus = status.label;
|
|
|
|
+ // 学校名称
|
|
|
|
+ const school = await app.$get(`/school/${arr.data.school_id}`)
|
|
|
|
+ if (school.errcode == '0') arr.data.zhSchool = school.data.name;
|
|
|
|
+ // 课程信息
|
|
|
|
+ that.setData({ form: arr.data })
|
|
|
|
+ }
|
|
|
|
+ else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail: async res => {
|
|
|
|
+ wx.redirectTo({ url: '/pages/index/index' })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
*/
|
|
- onReady: function () {
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
|
|
+ onReady: function () { },
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
*/
|
|
- onShow: function () {
|
|
|
|
- const that = this;
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
|
|
+ onShow: function () {},
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
|
+ */
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
*/
|
|
@@ -54,13 +91,6 @@ Page({
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- /**
|
|
|
|
- * 页面上拉触底事件的处理函数
|
|
|
|
- */
|
|
|
|
- onReachBottom: function () {
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 用户点击右上角分享
|
|
* 用户点击右上角分享
|
|
*/
|
|
*/
|