123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- frameStyle: { useTop: true, name: '学员课程详细信息', leftArrow: true, useBar: false },
- id: '',
- // 选中
- tabs: {
- active: '0',
- menu: [
- { title: '学生信息', active: '0' },
- { title: '课程信息', active: '1' },
- ]
- },
- // 学员信息
- stuInfo: {},
- // 课程信息
- lesInfo: {},
- // 学生id
- student_id: '',
- // 课程id
- lesson_id: '',
- // 学员等级
- levelList: [],
- // 学员性别
- genderList: [],
- // 状态列表
- statusList: [],
- // 类型列表
- typeList: [],
- },
- // 返回
- back: function () {
- wx.navigateBack({ delta: 1 })
- },
- // 选项卡选择
- tabsChange: function (e) {
- const that = this;
- let data = e.detail;
- that.setData({ 'tabs.active': data.active })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- const that = this;
- that.setData({ id: options.id || '' })
- // 监听用户是否登录
- that.watchLogin();
- },
- // 监听用户是否登录
- watchLogin: async function () {
- const that = this;
- wx.getStorage({
- key: 'user',
- success: async res => {
- that.setData({ school_id: res.data.info.id })
- // 学员等级
- const aee = await app.$get(`/dict`, { code: "student_grade" });
- if (aee.errcode == '0' && aee.total > 0) that.setData({ levelList: aee.data[0].list });
- // 学员性别
- const ree = await app.$get(`/dict`, { code: "gender" });
- if (ree.errcode == '0' && ree.total > 0) that.setData({ genderList: ree.data[0].list });
- // 课程状态
- const aff = await app.$get(`/dict`, { code: "lesson_status" });
- if (aff.errcode == '0' && aff.total > 0) that.setData({ statusList: aff.data[0].list });
- // 课程列表
- const acc = await app.$get(`/dict`, { code: "lesson_type" });
- if (acc.errcode == '0' && aee.total > 0) that.setData({ typeList: acc.data[0].list });
- if (that.data.id) {
- const aee = await app.$get(`/tempLessonApply/${that.data.id}`);
- if (aee.errcode == '0') {
- that.setData({ student_id: aee.data.student_id })
- that.setData({ lesson_id: aee.data.lesson_id })
- }
- // 学员信息
- const arr = await app.$get(`/student/${that.data.student_id}`);
- if (arr.errcode == '0') {
- let gender = that.data.genderList.find(i => i.value == arr.data.gender)
- if (gender) arr.data.zhGender = gender.label;
- let level = that.data.levelList.find(i => i.value == arr.data.level)
- if (level) arr.data.zhLevel = level.label;
- that.setData({ stuInfo: arr.data });
- }
- // 课程信息
- const abb = await app.$get(`/lesson/${that.data.lesson_id}`);
- if (abb.errcode == '0') {
- let status = that.data.statusList.find(i => i.value == abb.data.status)
- if (status) abb.data.zhstatus = status.label;
- let type = that.data.typeList.find(i => i.value == abb.data.type)
- if (type) abb.data.zhtype = type.label;
- that.setData({ lesInfo: abb.data });
- }
- }
- },
- fail: res => {
- wx.redirectTo({ url: '/pages/index/index', })
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|