basic.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. that.setData({ form: res.data })
  34. // const arr = await app.$get(`/newCourt/api/user/${res.data._id}`);
  35. // if (arr.errcode == '0') { that.setData({ form: arr.data }) }
  36. // else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
  37. },
  38. fail: async res => {
  39. wx.redirectTo({ url: '/pages/index/index' })
  40. }
  41. })
  42. },
  43. /**
  44. * 页面上拉触底事件的处理函数
  45. */
  46. /**
  47. * 生命周期函数--监听页面隐藏
  48. */
  49. onHide: function () {
  50. },
  51. /**
  52. * 生命周期函数--监听页面卸载
  53. */
  54. onUnload: function () {
  55. },
  56. /**
  57. * 页面相关事件处理函数--监听用户下拉动作
  58. */
  59. onPullDownRefresh: function () {
  60. },
  61. /**
  62. * 用户点击右上角分享
  63. */
  64. onShareAppMessage: function () {
  65. }
  66. })