basic.js 1.6 KB

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