123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- const app = getApp()
- const moment = require("../../utils/moment.min")
- Page({
- data: {
- frameStyle: { useTop: true, name: '羽校信息', leftArrow: true, useBar: false },
- user: {},
- id: '',
- form: {},
- // 选中
- tabs: {
- active: '0',
- menu: [
- { title: '羽校信息', active: '0' },
- { title: '师资信息', active: '1' },
- { title: '公开课', active: '2' },
- { title: '私教课', active: '3' },
- ]
- },
- // 公开课
- openList: []
- },
- // 跳转菜单
- back(e) {
- wx.navigateBack({ delta: 1 })
- },
- // 选项卡选择
- tabsChange: function (e) {
- const that = this;
- let data = e.detail;
- that.setData({ 'tabs.active': data.active })
- },
- //申请入学
- toApply: function () {
- const that = this;
- wx.showModal({
- title: '提示',
- content: '您是否确定加入此学校?',
- async success(res) {
- let user = that.data.user;
- let form = that.data.form;
- if (res.confirm) {
- var params = { student_id: user.info.id, school_id: form._id, time: moment().format('YYYY-MM-DD HH:mm:ss') };
- let arr = await app.$post(`/safs`, params);
- if (arr.errcode == '0') { wx.showToast({ title: `申请入学成功`, icon: 'success', duration: 2000 }); that.watchLogin(); }
- else wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
- } else if (res.cancel) { }
- }
- });
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- const that = this;
- that.setData({ id: options.id || null })
- // 监听用户是否登录
- that.watchLogin();
- },
- // 监听用户是否登录
- watchLogin: async function () {
- const that = this;
- wx.getStorage({
- key: 'user',
- success: async res => {
- that.setData({ user: res.data })
- if (that.data.id) {
- let arr;
- // 学校信息
- arr = await app.$get(`/school/${that.data.id}`)
- if (arr.errcode == '0') { that.setData({ form: arr.data }) }
- else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
- // 公开课
- arr = await app.$get(`/lessonPublic`, { school_id: that.data.id, status: '1' });
- if (arr.errcode == '0') { that.setData({ openList: arr.data }) }
- else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
- }
- },
- fail: async res => {
- wx.redirectTo({ url: '/pages/index/index' })
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () { },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|