userInfo.js 1.7 KB

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