info.js 1.8 KB

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