index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one" @click="toCommon('/pagesMy/account/upPassword')">
  5. <view class="other">
  6. <view class="title">{{passLogin.name}}</view>
  7. <view class="titles">{{passLogin.content}}</view>
  8. </view>
  9. <view class="btn">
  10. <text class="iconfont icon-jiantouyou"></text>
  11. </view>
  12. </view>
  13. <view class="one" @click="toCommon('/pagesMy/account/bindPhone')">
  14. <view class="other">
  15. <view class="title">{{phone.name}} <text>{{phone.phone?phone.phone:'未绑定'}}</text> </view>
  16. <view class="titles">{{phone.content}}</view>
  17. </view>
  18. <view class="btn">
  19. <text class="iconfont icon-jiantouyou"></text>
  20. </view>
  21. </view>
  22. <view class="one" @click="toCommon('/pagesMy/account/bindEmail')">
  23. <view class="other">
  24. <view class="title">{{email.name}}<text>{{email.email?email.email:'未绑定'}}</text></view>
  25. <view class="titles">{{email.content}}</view>
  26. </view>
  27. <view class="btn">
  28. <text class="iconfont icon-jiantouyou"></text>
  29. </view>
  30. </view>
  31. <view class="one" @click="toCommon('/pagesMy/account/upBasic')">
  32. <view class="other">
  33. <view class="title">{{info.name}}</view>
  34. <view class="titles">{{info.content}}</view>
  35. </view>
  36. <view class="btn">
  37. <text class="iconfont icon-jiantouyou"></text>
  38. </view>
  39. </view>
  40. <view class="two">
  41. <button type="default" size="mini" @click="toOut()">退出当前登录</button>
  42. </view>
  43. </view>
  44. </mobile-frame>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. passLogin: {
  51. name: '登录密码',
  52. content: '建议定期修改密码以保护账号安全'
  53. },
  54. phone: {
  55. name: '绑定手机',
  56. content: '如若您已更换手机号,请及时绑定',
  57. phone: ''
  58. },
  59. email: {
  60. name: '绑定邮箱',
  61. // content: '未绑定邮箱,请及时绑定',
  62. email: ''
  63. },
  64. info: {
  65. name: '修改个人信息',
  66. content: '修改个人信息'
  67. },
  68. };
  69. },
  70. onShow: function() {
  71. const that = this;
  72. that.watchLogin();
  73. },
  74. methods: {
  75. watchLogin() {
  76. const that = this;
  77. uni.getStorage({
  78. key: 'token',
  79. success: async (res) => {
  80. let user = that.$jwt(res.data);
  81. if (user) {
  82. const arr = await that.$api(`/user/${user.id}`, 'GET');
  83. if (arr.errcode == '0') {
  84. let data=arr.data;
  85. if (data && data.phone) {
  86. var phone = data.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
  87. that.$set(that.phone, `phone`, phone)
  88. }
  89. if (data && data.email) {
  90. that.$set(that.email, `email`, arr.data.email)
  91. }
  92. } else {
  93. uni.showToast({
  94. title: arr.errmsg,
  95. icon: 'none',
  96. });
  97. }
  98. }
  99. },
  100. fail: (err) => {}
  101. })
  102. },
  103. // 跳转
  104. toCommon(route, e) {
  105. uni.navigateTo({
  106. url: `${route}`
  107. })
  108. },
  109. // 退出登录
  110. toOut(e) {
  111. try {
  112. uni.clearStorage();
  113. uni.reLaunch({
  114. url: '/pages/index/index'
  115. })
  116. } catch (e) {}
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss">
  122. .main {
  123. display: flex;
  124. flex-direction: column;
  125. width: 100vw;
  126. height: 100vh;
  127. .one {
  128. border-bottom: 1px var(--fcColor) solid;
  129. margin: 1vw 3vw;
  130. display: flex;
  131. flex-direction: row;
  132. padding: 1vw 0;
  133. .other {
  134. flex-grow: 1;
  135. .title {
  136. margin: 2vw 0;
  137. font-size: var(--font16Size);
  138. text {
  139. margin: 0 0 0 2vw;
  140. color: var(--fFB1Color);
  141. font-size: var(--font12Size);
  142. }
  143. }
  144. .titles {
  145. font-size: var(--font14Size);
  146. color: var(--f85Color);
  147. margin: 2vw 0;
  148. }
  149. }
  150. .btn {
  151. text-align: right;
  152. font-size: 20px;
  153. }
  154. }
  155. .two {
  156. margin: 5vw 3vw;
  157. text-align: center;
  158. button {
  159. border-radius: 20px;
  160. border: 2px solid var(--fFB1Color);
  161. color: var(--fFB1Color);
  162. }
  163. }
  164. }
  165. </style>