|
@@ -1,38 +1,135 @@
|
|
const app = getApp();
|
|
const app = getApp();
|
|
|
|
+import { is_pay } from '../../../utils/dict';
|
|
|
|
+const moment = require("../../../utils/moment.min")
|
|
Page({
|
|
Page({
|
|
/**
|
|
/**
|
|
* 页面的初始数据
|
|
* 页面的初始数据
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
frameStyle: { useTop: true, name: '课程信息', leftArrow: true, useBar: false },
|
|
frameStyle: { useTop: true, name: '课程信息', leftArrow: true, useBar: false },
|
|
|
|
+ list: [],
|
|
|
|
+ total: 0,
|
|
|
|
+ page: 0,
|
|
|
|
+ skip: 0,
|
|
|
|
+ limit: 5,
|
|
|
|
+ // 支付状态
|
|
|
|
+ is_payList: is_pay,
|
|
|
|
+ // 课程状态
|
|
|
|
+ statusList: [],
|
|
},
|
|
},
|
|
- // 跳转菜单
|
|
|
|
- back(e) {
|
|
|
|
- wx.navigateBack({ delta: 1 })
|
|
|
|
|
|
+ // 返回
|
|
|
|
+ back: function () { wx.navigateBack({ delta: 1 }) },
|
|
|
|
+ //详细信息
|
|
|
|
+ toCommon: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ const { item, route } = e.currentTarget.dataset;
|
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] });
|
|
|
|
+ wx.navigateTo({ url: `${route}?id=${item && item.lesson_id ? item.lesson_id : ''}` })
|
|
|
|
+ },
|
|
|
|
+ // 支付
|
|
|
|
+ toPay: async function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ const { item } = e.currentTarget.dataset;
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: '是否确认支付?',
|
|
|
|
+ async success(res) {
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ console.log('支付');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 退款
|
|
|
|
+ toRefund: async function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ const { item } = e.currentTarget.dataset;
|
|
|
|
+ let time = moment().format('YYYY-MM-DD HH:mm:ss');
|
|
|
|
+ let data = moment(time).isBefore(item.lesson_id_refund_hour);
|
|
|
|
+ if (data == true) {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: '是否确认退款?',
|
|
|
|
+ async success(res) {
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ console.log('退款');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({ title: '超过退款期限无法退款', icon: 'none', duration: 2000 })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 分页
|
|
|
|
+ toPage: function () {
|
|
|
|
+ const that = this;
|
|
|
|
+ let list = that.data.list;
|
|
|
|
+ let limit = that.data.limit;
|
|
|
|
+ if (that.data.total > list.length) {
|
|
|
|
+ wx.showLoading({ title: '加载中', mask: true })
|
|
|
|
+ let page = that.data.page + 1;
|
|
|
|
+ that.setData({ page: page })
|
|
|
|
+ let skip = page * limit;
|
|
|
|
+ that.setData({ skip: skip })
|
|
|
|
+ that.watchLogin();
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
|
|
},
|
|
},
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
- onLoad: function (options) {
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
|
|
+ onLoad: function (options) { },
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
*/
|
|
- onReady: function () {
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
|
|
+ onReady: function () { },
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
*/
|
|
- onShow: function () {
|
|
|
|
|
|
+ onShow: async function () {
|
|
const that = this;
|
|
const that = this;
|
|
-
|
|
|
|
|
|
+ // 查询其他信息
|
|
|
|
+ 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;
|
|
|
|
+ wx.getStorage({
|
|
|
|
+ key: 'user',
|
|
|
|
+ success: async res => {
|
|
|
|
+ let info = { skip: that.data.skip, limit: that.data.limit, student_id: res.data.info._id };
|
|
|
|
+ let arr = await app.$get(`/lessonStudent`, { ...info });
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ let list = [...that.data.list, ...arr.data];
|
|
|
|
+ for (const val of list) {
|
|
|
|
+ // 课程状态
|
|
|
|
+ let status = that.data.statusList.find(i => i.value == val.lesson_id_status)
|
|
|
|
+ if (status) val.zhStatus = status.label;
|
|
|
|
+ // 支付状态
|
|
|
|
+ let pay = is_pay.find(i => i.value == val.is_pay)
|
|
|
|
+ if (pay) val.zhPay = pay.label;
|
|
|
|
+ }
|
|
|
|
+ that.setData({ list })
|
|
|
|
+ that.setData({ total: arr.total })
|
|
|
|
+ } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
|
|
+ },
|
|
|
|
+ fail: async res => {
|
|
|
|
+ wx.redirectTo({ url: '/pages/index/index' })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
|
+ */
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
*/
|
|
@@ -44,7 +141,8 @@ Page({
|
|
* 生命周期函数--监听页面卸载
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
*/
|
|
onUnload: function () {
|
|
onUnload: function () {
|
|
-
|
|
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] })
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -54,13 +152,6 @@ Page({
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- /**
|
|
|
|
- * 页面上拉触底事件的处理函数
|
|
|
|
- */
|
|
|
|
- onReachBottom: function () {
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 用户点击右上角分享
|
|
* 用户点击右上角分享
|
|
*/
|
|
*/
|