index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. preview(event) {
  79. let currentUrl = event.currentTarget.dataset.src
  80. wx.previewImage({
  81. current: currentUrl, // 当前显示图片的http链接
  82. urls: [currentUrl] // 需要预览的图片http链接列表
  83. })
  84. },
  85. /**
  86. * 生命周期函数--监听页面加载
  87. */
  88. onLoad(options) {},
  89. /**
  90. * 生命周期函数--监听页面初次渲染完成
  91. */
  92. onReady() {
  93. },
  94. /**
  95. * 生命周期函数--监听页面显示
  96. */
  97. onShow() {
  98. this.doGetInfo()
  99. },
  100. /**
  101. * 生命周期函数--监听页面隐藏
  102. */
  103. onHide() {
  104. },
  105. /**
  106. * 生命周期函数--监听页面卸载
  107. */
  108. onUnload() {
  109. },
  110. /**
  111. * 页面相关事件处理函数--监听用户下拉动作
  112. */
  113. onPullDownRefresh() {
  114. },
  115. /**
  116. * 页面上拉触底事件的处理函数
  117. */
  118. onReachBottom() {
  119. },
  120. /**
  121. * 用户点击右上角分享
  122. */
  123. onShareAppMessage() {
  124. }
  125. })