index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. userMsg: {},
  8. pathList: [{
  9. name: "团队管理",
  10. icon: "icon-a-wodetuanduiguanli",
  11. color: "var(--assist)",
  12. path: "/pages/teams/index"
  13. }, {
  14. name: "修改登录密码",
  15. icon: "icon-a-wodeguanyuyingyong",
  16. color: "var(--warning)",
  17. path: "/pages/tabbar/mine/changePassword/index"
  18. }, {
  19. name: "绑定微信",
  20. icon: "icon-a-wodebangdingweixin",
  21. color: "var(--success)",
  22. path: "#"
  23. }]
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad(options) {
  29. this.queryUserMsg();
  30. },
  31. /* 查询用户信息 */
  32. queryUserMsg() {
  33. _Http.basic({
  34. "classname": "common.usercenter.usercenter",
  35. "method": "queryUserMsg",
  36. "content": {}
  37. }).then(res => {
  38. if (res.msg != '成功') return wx.showToast({
  39. title: res.data,
  40. icon: "none"
  41. })
  42. this.setData({
  43. userMsg: res.data
  44. })
  45. })
  46. },
  47. /**
  48. * 生命周期函数--监听页面初次渲染完成
  49. */
  50. onReady() {
  51. },
  52. /**
  53. * 生命周期函数--监听页面显示
  54. */
  55. onShow() {
  56. this.getTabBar().init();
  57. },
  58. /**
  59. * 生命周期函数--监听页面隐藏
  60. */
  61. onHide() {
  62. },
  63. /**
  64. * 生命周期函数--监听页面卸载
  65. */
  66. onUnload() {
  67. },
  68. /**
  69. * 页面相关事件处理函数--监听用户下拉动作
  70. */
  71. onPullDownRefresh() {
  72. },
  73. /**
  74. * 页面上拉触底事件的处理函数
  75. */
  76. onReachBottom() {
  77. },
  78. /**
  79. * 用户点击右上角分享
  80. */
  81. onShareAppMessage() {
  82. },
  83. /* 退出登录 */
  84. outLogin() {
  85. _Http.logout().then(res => {
  86. wx.showToast({
  87. title: '退出成功'
  88. });
  89. setTimeout(() => {
  90. wx.reLaunch({
  91. url: '/pages/login/index',
  92. })
  93. }, 300)
  94. })
  95. },
  96. /* 去修改用户信息 */
  97. changeUserMsg() {
  98. let {
  99. name,
  100. phonenumber,
  101. attinfos
  102. } = this.data.userMsg;
  103. wx.navigateTo({
  104. url: `./userMsg/index?attinfos=${JSON.stringify(attinfos)}&name=${name}&phonenumber=${phonenumber}`
  105. })
  106. },
  107. listClick(e) {
  108. const {
  109. name
  110. } = e.currentTarget.dataset;
  111. console.log(name)
  112. if (name == '绑定微信') {
  113. wx.showModal({
  114. title: "提示",
  115. content: "是否使用当前微信绑定此账号?",
  116. success: res => {
  117. console.log(res)
  118. if (res.confirm) {
  119. wx.login({
  120. success(res) {
  121. if (res.code) _Http.basic({
  122. "classname": "common.usercenter.usercenter",
  123. "method": "WechatBinding",
  124. "content": {
  125. "wechat_code": res.code
  126. }
  127. }).then(res => {
  128. if (res.code == 0) return wx.showToast({
  129. title: res.msg,
  130. icon: "none"
  131. });
  132. wx.showToast({
  133. title: '绑定成功',
  134. })
  135. })
  136. }
  137. })
  138. }
  139. }
  140. })
  141. }
  142. }
  143. })