myAccount.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="account-info">
  3. <view class="info-item">
  4. <view class="item-label">
  5. <text>姓名</text>
  6. </view>
  7. <view class="item-content">
  8. <text>{{name}}</text>
  9. </view>
  10. </view>
  11. <view class="info-item">
  12. <view class="item-label">
  13. <text>身份证号</text>
  14. </view>
  15. <view class="item-content">
  16. <text>{{idNumber}}</text>
  17. </view>
  18. </view>
  19. <view class="info-item">
  20. <view class="item-label">
  21. <text>手机号</text>
  22. </view>
  23. <view class="item-content">
  24. <text>{{phone}}</text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="update-button">
  29. <button @click="gotoUpdateUserInfo">修改信息</button>
  30. </view>
  31. </template>
  32. <script setup>
  33. import {
  34. ref
  35. } from 'vue'
  36. import {
  37. onShow
  38. } from '@dcloudio/uni-app'
  39. import {
  40. useUserStore
  41. } from '../../store/userStore'
  42. let name = ref('')
  43. let idNumber = ref('')
  44. let phone = ref('')
  45. const userInfo = useUserStore().userInfo
  46. function gotoUpdateUserInfo() {
  47. uni.navigateTo({
  48. url: '/subpkg/updateUserInfo/updateUserInfo'
  49. })
  50. }
  51. onShow(() => {
  52. if (userInfo.name && userInfo.idNumber && userInfo.phone) {
  53. if (userInfo.name.length == 2) {
  54. name.value = userInfo.name[0] + '*'
  55. } else {
  56. name.value = userInfo.name[0] + '*' + userInfo.name[userInfo.name.length - 1]
  57. }
  58. idNumber.value = userInfo.idNumber.slice(0, 6) + '********' + userInfo.idNumber.slice(14, 18)
  59. phone.value = userInfo.phone.slice(0, 3) + '****' + userInfo.phone.slice(7)
  60. } else {
  61. uni.showModal({
  62. title: '请完善姓名及身份证号以正常使用!',
  63. success: res => {
  64. gotoUpdateUserInfo()
  65. },
  66. showCancel: false
  67. })
  68. }
  69. })
  70. </script>
  71. <style lang="scss">
  72. .account-info {
  73. .info-item {
  74. height: 100rpx;
  75. display: flex;
  76. justify-content: space-between;
  77. align-items: center;
  78. margin: 0 40rpx;
  79. border-bottom: black 1px solid;
  80. font-size: 30rpx;
  81. }
  82. }
  83. .update-button {
  84. button {
  85. margin: 40rpx auto;
  86. width: 80vw;
  87. background-color: #a09cc4;
  88. color: #ffffff;
  89. }
  90. }
  91. </style>