info.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. const app = getApp()
  2. const moment = require("../../utils/moment.min")
  3. Page({
  4. data: {
  5. frameStyle: { useTop: true, name: '羽校信息', leftArrow: true, useBar: false },
  6. user: {},
  7. id: '',
  8. form: {},
  9. // 选中
  10. tabs: {
  11. active: '0',
  12. menu: [
  13. { title: '羽校信息', active: '0' },
  14. { title: '师资信息', active: '1' },
  15. { title: '公开课', active: '2' },
  16. { title: '私教课', active: '3' },
  17. ]
  18. },
  19. // 公开课
  20. openList: []
  21. },
  22. // 跳转菜单
  23. back(e) {
  24. wx.navigateBack({ delta: 1 })
  25. },
  26. // 选项卡选择
  27. tabsChange: function (e) {
  28. const that = this;
  29. let data = e.detail;
  30. that.setData({ 'tabs.active': data.active })
  31. },
  32. //申请入学
  33. toApply: function () {
  34. const that = this;
  35. wx.showModal({
  36. title: '提示',
  37. content: '您是否确定加入此学校?',
  38. async success(res) {
  39. let user = that.data.user;
  40. let form = that.data.form;
  41. if (res.confirm) {
  42. var params = { student_id: user.info.id, school_id: form._id, time: moment().format('YYYY-MM-DD HH:mm:ss') };
  43. let arr = await app.$post(`/safs`, params);
  44. if (arr.errcode == '0') { wx.showToast({ title: `申请入学成功`, icon: 'success', duration: 2000 }); that.watchLogin(); }
  45. else wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
  46. } else if (res.cancel) { }
  47. }
  48. });
  49. },
  50. /**
  51. * 生命周期函数--监听页面加载
  52. */
  53. onLoad: function (options) {
  54. const that = this;
  55. that.setData({ id: options.id || null })
  56. // 监听用户是否登录
  57. that.watchLogin();
  58. },
  59. // 监听用户是否登录
  60. watchLogin: async function () {
  61. const that = this;
  62. wx.getStorage({
  63. key: 'user',
  64. success: async res => {
  65. that.setData({ user: res.data })
  66. if (that.data.id) {
  67. let arr;
  68. // 学校信息
  69. arr = await app.$get(`/school/${that.data.id}`)
  70. if (arr.errcode == '0') { that.setData({ form: arr.data }) }
  71. else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
  72. // 公开课
  73. arr = await app.$get(`/lessonPublic`, { school_id: that.data.id, status: '1' });
  74. if (arr.errcode == '0') { that.setData({ openList: arr.data }) }
  75. else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
  76. }
  77. },
  78. fail: async res => {
  79. wx.redirectTo({ url: '/pages/index/index' })
  80. }
  81. })
  82. },
  83. /**
  84. * 生命周期函数--监听页面初次渲染完成
  85. */
  86. onReady: function () { },
  87. /**
  88. * 生命周期函数--监听页面显示
  89. */
  90. onShow: function () {
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. /**
  96. * 生命周期函数--监听页面隐藏
  97. */
  98. onHide: function () {
  99. },
  100. /**
  101. * 生命周期函数--监听页面卸载
  102. */
  103. onUnload: function () {
  104. },
  105. /**
  106. * 页面相关事件处理函数--监听用户下拉动作
  107. */
  108. onPullDownRefresh: function () {
  109. },
  110. /**
  111. * 用户点击右上角分享
  112. */
  113. onShareAppMessage: function () {
  114. }
  115. })