index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. const _my = require("../../../__antmove/api/index.js")(my);
  2. const wx = _my; // pages/mine/mine.js
  3. const app = getApp();
  4. import { doGetInfo } from "../../../utils/api/api";
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. StatusBar: app.globalData.StatusBar,
  11. //胶囊按钮位置
  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. onShow() {
  97. this.doGetInfo();
  98. },
  99. /**
  100. * 生命周期函数--监听页面隐藏
  101. */
  102. onHide() { },
  103. /**
  104. * 生命周期函数--监听页面卸载
  105. */
  106. onUnload() { },
  107. /**
  108. * 页面相关事件处理函数--监听用户下拉动作
  109. */
  110. onPullDownRefresh() { },
  111. /**
  112. * 页面上拉触底事件的处理函数
  113. */
  114. onReachBottom() { },
  115. /**
  116. * 用户点击右上角分享
  117. */
  118. onShareAppMessage() { },
  119. antmoveAction: function () {
  120. //执行时动态赋值,请勿删除
  121. }
  122. });