info.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. const app = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. frameStyle: { useTop: true, name: '羽校详细信息', leftArrow: true, useBar: false },
  8. school_id: '',
  9. form: {},
  10. },
  11. // 返回
  12. back: function () {
  13. wx.navigateBack({ delta: 1 })
  14. },
  15. // 图片预览
  16. imgView: function (e) {
  17. const that = this;
  18. const { item } = e.currentTarget.dataset;
  19. if (item && item.length > 0) {
  20. wx.previewImage({
  21. current: '',
  22. urls: [item[0].url]
  23. })
  24. }
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: async function (options) {
  30. const that = this;
  31. that.setData({ school_id: options.school_id || '' });
  32. // 监听用户是否登录
  33. await that.watchLogin();
  34. },
  35. // 监听用户是否登录
  36. watchLogin: async function () {
  37. const that = this;
  38. wx.getStorage({
  39. key: 'user',
  40. success: async res => {
  41. let arr;
  42. arr = await app.$get(`/school/${that.data.school_id}`,);
  43. if (arr.errcode == '0') { that.setData({ form: arr.data }) }
  44. },
  45. fail: async res => {
  46. wx.redirectTo({ url: '/pages/index/index' })
  47. }
  48. })
  49. },
  50. /**
  51. * 生命周期函数--监听页面初次渲染完成
  52. */
  53. onReady: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面显示
  57. */
  58. onShow: function () { },
  59. /**
  60. * 生命周期函数--监听页面隐藏
  61. */
  62. onHide: function () {
  63. },
  64. /**
  65. * 生命周期函数--监听页面卸载
  66. */
  67. onUnload: function () {
  68. },
  69. /**
  70. * 页面相关事件处理函数--监听用户下拉动作
  71. */
  72. onPullDownRefresh: function () {
  73. },
  74. /**
  75. * 页面上拉触底事件的处理函数
  76. */
  77. onReachBottom: function () {
  78. },
  79. /**
  80. * 用户点击右上角分享
  81. */
  82. onShareAppMessage: function () {
  83. }
  84. })