info.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. const app = getApp()
  2. Page({
  3. data: {
  4. frameStyle: { useTop: true, name: '私教课信息', leftArrow: true, useBar: false },
  5. id: '',
  6. form: {},
  7. //状态
  8. statusList: []
  9. },
  10. // 跳转菜单
  11. back(e) {
  12. wx.navigateBack({ delta: 1 })
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: async function (options) {
  18. const that = this;
  19. await that.setData({ id: options.id || null })
  20. // 查询其他信息
  21. await that.searchOther();
  22. // 监听用户是否登录
  23. await that.watchLogin();
  24. },
  25. searchOther: async function () {
  26. const that = this;
  27. let arr;
  28. // 状态
  29. arr = await app.$get(`/dict`, { code: 'lesson_status' });
  30. if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list });
  31. },
  32. // 监听用户是否登录
  33. watchLogin: async function () {
  34. const that = this;
  35. let statusList = that.data.statusList;
  36. wx.getStorage({
  37. key: 'user',
  38. success: async res => {
  39. if (that.data.id) {
  40. const arr = await app.$get(`/lessonPublic/${that.data.id}`);
  41. if (arr.errcode == '0') {
  42. let status = statusList.find(i => i.value == arr.data.status)
  43. if (status) arr.data.zhStatus = level.label;
  44. that.setData({ form: arr.data })
  45. } else {
  46. wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
  47. }
  48. }
  49. },
  50. fail: async res => {
  51. wx.redirectTo({ url: '/pages/index/index' })
  52. }
  53. })
  54. },
  55. /**
  56. * 生命周期函数--监听页面初次渲染完成
  57. */
  58. onReady: function () { },
  59. /**
  60. * 生命周期函数--监听页面显示
  61. */
  62. onShow: function () {
  63. },
  64. /**
  65. * 页面上拉触底事件的处理函数
  66. */
  67. /**
  68. * 生命周期函数--监听页面隐藏
  69. */
  70. onHide: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面卸载
  74. */
  75. onUnload: function () {
  76. },
  77. /**
  78. * 页面相关事件处理函数--监听用户下拉动作
  79. */
  80. onPullDownRefresh: function () {
  81. },
  82. /**
  83. * 用户点击右上角分享
  84. */
  85. onShareAppMessage: function () {
  86. }
  87. })