person.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // pages/person/person.js
  2. import { getHwUserInfo } from '../../utils/util'
  3. import { taxRegistration } from "../../service/hwVersion";
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. sign: '认证用户',
  10. userInfo: { authenticationStatus: 0 },
  11. taxUrl: '',
  12. taxName: ''
  13. },
  14. /**
  15. * 跳转用户信息列表
  16. *
  17. */
  18. toUserinfo() {
  19. wx.navigateTo({
  20. url: '/pages/userinfo/userinfo',
  21. })
  22. },
  23. /**
  24. * 退出登录
  25. * 清除所有缓存 并跳转登录页
  26. */
  27. quit() {
  28. wx.showModal({
  29. title: '是否退出登录',
  30. cancelColor: '#888A8E',
  31. confirmColor: '#31364C',
  32. success: (res) => {
  33. if (res.confirm) {
  34. wx.clearStorage({
  35. success: () => {
  36. wx.navigateBack({
  37. delta: 1
  38. })
  39. },
  40. })
  41. }
  42. },
  43. })
  44. },
  45. toWebView() {
  46. if (this.data.taxUrl) {
  47. wx.navigateTo({
  48. url: `/pages/web-view/web-view?url=${encodeURIComponent(this.data.taxUrl)}`
  49. })
  50. } else {
  51. wx.showToast({
  52. title: '该功能暂未开放',
  53. icon: 'none'
  54. })
  55. }
  56. },
  57. /**
  58. * 生命周期函数--监听页面加载
  59. */
  60. onLoad: function () {
  61. wx.hideHomeButton();
  62. },
  63. /**
  64. * 生命周期函数--监听页面初次渲染完成
  65. */
  66. onReady: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面显示
  70. */
  71. onShow: async function () {
  72. wx.hideHomeButton();
  73. if (wx.getStorageSync('userId') && wx.getStorageSync('userToken')) {
  74. // 获取用户信息
  75. await getHwUserInfo()
  76. this.setData({
  77. userInfo: wx.getStorageSync('userInfo'),
  78. })
  79. taxRegistration().then(res => {
  80. const data = <responseOptionsType<taxRegistrationResponseType>>res
  81. this.setData({
  82. taxUrl: data.data?.taxUrl || '',
  83. taxName: data.data?.taxName || ''
  84. })
  85. if (data.data?.taxMessage && wx.getStorageSync('firstLogin')) {
  86. wx.showModal({
  87. title: '提示',
  88. content: data.data.taxMessage,
  89. showCancel: false,
  90. confirmText: '知道了',
  91. success: res => {
  92. if (res.confirm) {
  93. wx.setStorageSync('firstLogin', false)
  94. }
  95. }
  96. })
  97. }
  98. })
  99. } else {
  100. this.setData({
  101. userInfo: { authenticationStatus: 0 }
  102. })
  103. // wx.reLaunch({
  104. // url: '/pages/login/login',
  105. // })
  106. }
  107. },
  108. /**
  109. * 生命周期函数--监听页面隐藏
  110. */
  111. onHide: function () {
  112. },
  113. /**
  114. * 生命周期函数--监听页面卸载
  115. */
  116. onUnload: function () {
  117. },
  118. /**
  119. * 页面相关事件处理函数--监听用户下拉动作
  120. */
  121. onPullDownRefresh: function () {
  122. },
  123. /**
  124. * 页面上拉触底事件的处理函数
  125. */
  126. onReachBottom: function () {
  127. },
  128. })