person.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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: {},
  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. /**
  46. * 生命周期函数--监听页面加载
  47. */
  48. onLoad: function () {
  49. wx.hideHomeButton();
  50. },
  51. /**
  52. * 生命周期函数--监听页面初次渲染完成
  53. */
  54. onReady: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面显示
  58. */
  59. onShow: async function () {
  60. wx.hideHomeButton();
  61. if (wx.getStorageSync('userId') && wx.getStorageSync('userToken')) {
  62. // 获取用户信息
  63. await getHwUserInfo()
  64. this.setData({
  65. userInfo: wx.getStorageSync('userInfo'),
  66. })
  67. taxRegistration().then(res => {
  68. const data = <responseOptionsType<taxRegistrationResponseType>>res
  69. if (data.data?.taxUrl) {
  70. this.setData({
  71. taxUrl: encodeURIComponent(data.data.taxUrl),
  72. taxName: data.data.taxName
  73. })
  74. }
  75. if (data.data?.taxMessage && wx.getStorageSync('firstLogin')) {
  76. wx.showModal({
  77. title: '提示',
  78. content: data.data.taxMessage,
  79. showCancel: false,
  80. confirmText: '知道了',
  81. success: res => {
  82. if (res.confirm) {
  83. wx.setStorageSync('firstLogin', false)
  84. }
  85. }
  86. })
  87. }
  88. })
  89. } else {
  90. // wx.reLaunch({
  91. // url: '/pages/login/login',
  92. // })
  93. }
  94. },
  95. /**
  96. * 生命周期函数--监听页面隐藏
  97. */
  98. onHide: function () {
  99. },
  100. /**
  101. * 生命周期函数--监听页面卸载
  102. */
  103. onUnload: function () {
  104. },
  105. /**
  106. * 页面相关事件处理函数--监听用户下拉动作
  107. */
  108. onPullDownRefresh: function () {
  109. },
  110. /**
  111. * 页面上拉触底事件的处理函数
  112. */
  113. onReachBottom: function () {
  114. },
  115. })