index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // pages/mine/mine.js
  2. const app = getApp();
  3. import {
  4. doGetInfo
  5. } from '../../../utils/api/api'
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. StatusBar: app.globalData.StatusBar, //胶囊按钮位置
  12. CustomBar: app.globalData.CustomBar,
  13. userInfo: null,
  14. itemList: [{
  15. name: '身份信息',
  16. id: 1,
  17. },
  18. // {
  19. // name: '个人信息',
  20. // id: 2,
  21. // },
  22. ]
  23. },
  24. goLogin() {
  25. wx.navigateTo({
  26. url: '/pages/login/index',
  27. })
  28. },
  29. async loginOut() {
  30. let that = this
  31. wx.showToast({
  32. title: '操作成功',
  33. icon: 'none',
  34. duration: 800,
  35. mask: true,
  36. success: function () {
  37. setTimeout(function () {
  38. that.setData({
  39. userInfo: null
  40. })
  41. wx.removeStorageSync('userInfo')
  42. wx.navigateTo({
  43. url: '/pages/login/index',
  44. })
  45. }, 800)
  46. }
  47. })
  48. },
  49. doGetInfo() {
  50. let userInfo = wx.getStorageSync('userInfo')
  51. if (userInfo) {
  52. doGetInfo().then(res => {
  53. userInfo = Object.assign(userInfo, res.data);
  54. this.setData({
  55. userInfo
  56. })
  57. wx.setStorageSync('userInfo', userInfo)
  58. })
  59. }
  60. },
  61. goto(e) {
  62. let id = e.currentTarget.dataset.id
  63. let url = ""
  64. switch (id) {
  65. case 1:
  66. url = "/pages/mine/standing/index"
  67. break;
  68. case 2:
  69. url = "/pages/mine/personage/index"
  70. break;
  71. default:
  72. break;
  73. }
  74. wx.navigateTo({
  75. url
  76. })
  77. },
  78. /**
  79. * 生命周期函数--监听页面加载
  80. */
  81. onLoad(options) {},
  82. /**
  83. * 生命周期函数--监听页面初次渲染完成
  84. */
  85. onReady() {
  86. },
  87. /**
  88. * 生命周期函数--监听页面显示
  89. */
  90. onShow() {
  91. this.doGetInfo()
  92. },
  93. /**
  94. * 生命周期函数--监听页面隐藏
  95. */
  96. onHide() {
  97. },
  98. /**
  99. * 生命周期函数--监听页面卸载
  100. */
  101. onUnload() {
  102. },
  103. /**
  104. * 页面相关事件处理函数--监听用户下拉动作
  105. */
  106. onPullDownRefresh() {
  107. },
  108. /**
  109. * 页面上拉触底事件的处理函数
  110. */
  111. onReachBottom() {
  112. },
  113. /**
  114. * 用户点击右上角分享
  115. */
  116. onShareAppMessage() {
  117. }
  118. })