mine.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // pages/mine/mine.js
  2. const app = getApp()
  3. const utils = require('../../utils/util.js')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. globalUrl: app.globalData.globalUrl,
  10. isLogin: '', //是否登陆
  11. userInfo: '', //缓存的用户信息
  12. user: '', //用户信息
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. },
  19. //个人名片
  20. toUserinfo() {
  21. if (this.data.isLogin) {
  22. //企业用户
  23. if (this.data.userInfo.roles === 1) {
  24. wx.navigateTo({
  25. url: '/pages/userInfo/userInfo'
  26. })
  27. }
  28. //服务商
  29. if (this.data.userInfo.roles === 2) {
  30. wx.navigateTo({
  31. url: '/pages/ispUserInfo/ispUserInfo'
  32. })
  33. }
  34. //运营商
  35. if (this.data.userInfo.roles === 3) {
  36. wx.navigateTo({
  37. url: '/pages/operUserInfo/operUserInfo'
  38. })
  39. }
  40. } else {
  41. utils.toLogin()
  42. }
  43. },
  44. //修改手机号
  45. toMobile() {
  46. if (this.data.isLogin) {
  47. wx.navigateTo({
  48. url: '/pages/changeMobile/changeMobile'
  49. })
  50. } else {
  51. utils.toLogin()
  52. }
  53. },
  54. //账号管理
  55. toAccount() {
  56. if (this.data.isLogin) {
  57. wx.navigateTo({
  58. url: '/pages/switchAccount/switchAccount'
  59. })
  60. } else {
  61. utils.toLogin()
  62. }
  63. },
  64. //联系客服
  65. contact() {
  66. if (this.data.isLogin) {
  67. wx.makePhoneCall({
  68. phoneNumber: '18789257620',
  69. success: () => {},
  70. fail: () => {}
  71. })
  72. } else {
  73. utils.toLogin()
  74. }
  75. },
  76. //退出登录
  77. loginOut() {
  78. utils.loginOut()
  79. },
  80. /**
  81. * 生命周期函数--监听页面初次渲染完成
  82. */
  83. onReady: function () {
  84. },
  85. /**
  86. * 生命周期函数--监听页面显示
  87. */
  88. onShow: function () {
  89. if (typeof this.getTabBar === 'function' &&
  90. this.getTabBar()) {
  91. this.getTabBar().setData({
  92. selected: 2
  93. })
  94. }
  95. //获取个人信息
  96. utils.getUser({
  97. noLogin: () => {
  98. this.setData({
  99. isLogin: false
  100. })
  101. }
  102. }).then(res => {
  103. this.setData({
  104. isLogin: true,
  105. userInfo: utils.getInfo(),
  106. user: res.data
  107. })
  108. })
  109. },
  110. /**
  111. * 生命周期函数--监听页面隐藏
  112. */
  113. onHide: function () {
  114. },
  115. /**
  116. * 生命周期函数--监听页面卸载
  117. */
  118. onUnload: function () {
  119. },
  120. /**
  121. * 页面相关事件处理函数--监听用户下拉动作
  122. */
  123. onPullDownRefresh: function () {
  124. },
  125. /**
  126. * 页面上拉触底事件的处理函数
  127. */
  128. onReachBottom: function () {
  129. },
  130. /**
  131. * 用户点击右上角分享
  132. */
  133. onShareAppMessage: function () {
  134. return {
  135. title: '诺信云',
  136. path: '/pages/index/index'
  137. }
  138. }
  139. })