index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <!-- 我的 -->
  3. <view class="card_mine">
  4. <view class="card_avatar" v-if="token != ''">
  5. <image class="mine_image" src="../../static/portrait.png" mode=""></image>
  6. <view class="card_user_title">
  7. <view class="mine_phone">{{userInfo.nickName}}</view>
  8. <view class="mine_phone">{{userInfo.username}}</view>
  9. </view>
  10. </view>
  11. <view class="card_avatar" v-else @click="login">
  12. <image class="mine_image" src="../../static/portrait.png" mode=""></image>
  13. <view class="mine_title">登录/注册</view>
  14. </view>
  15. <view class="space_between card_mine_option" @click="goPersonal">
  16. <view class="option_title">个人资料</view>
  17. <u-icon name="arrow-right" size="20"></u-icon>
  18. </view>
  19. <view class="space_between card_mine_option" @click="changePassword">
  20. <view class="option_title">修改密码</view>
  21. <u-icon name="arrow-right" size="20"></u-icon>
  22. </view>
  23. <view class="space_between card_mine_option" @click="goAddress">
  24. <view class="option_title">地址管理</view>
  25. <u-icon name="arrow-right" size="20"></u-icon>
  26. </view>
  27. <view class="space_between card_mine_option" @click="goPersonal">
  28. <view class="option_title">我的安全检查</view>
  29. <u-icon name="arrow-right" size="20"></u-icon>
  30. </view>
  31. <view class="space_between card_mine_option" @click="goSet">
  32. <view class="option_title">系统设置</view>
  33. <u-icon name="arrow-right" size="20"></u-icon>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. token: '',
  42. userInfo: {},
  43. }
  44. },
  45. mounted() {
  46. var token = this.$cache.getToken()
  47. this.token = token
  48. var userInfo = this.$cache.getCache('userInfo')
  49. this.userInfo = userInfo
  50. },
  51. methods: {
  52. // 刷新token
  53. refreshTokenil() {
  54. var token = this.$cache.getToken()
  55. this.token = token
  56. var userInfo = this.$cache.getCache('userInfo')
  57. this.userInfo = userInfo
  58. },
  59. //微信授权
  60. set_is_login(val) {
  61. let _this = this;
  62. uni.getUserProfile({
  63. 'desc': '获取用户基本信息',
  64. 'lang': 'zh_CN',
  65. success: function(infoRes) {
  66. console.log(infoRes, 8)
  67. uni.login({
  68. success: function(loginRes) {
  69. console.log(loginRes, 23)
  70. }
  71. });
  72. },
  73. });
  74. },
  75. // 登录注册
  76. login() {
  77. uni.navigateTo({
  78. url: '/pages/login'
  79. });
  80. },
  81. // 个人资料
  82. goPersonal() {
  83. if (this.token) {
  84. uni.navigateTo({
  85. url: '/pages/mine/personal'
  86. });
  87. } else {
  88. uni.$u.toast('请先登录')
  89. }
  90. },
  91. // 修改密码
  92. changePassword() {
  93. if (this.token) {
  94. uni.navigateTo({
  95. url: '/pages/mine/password'
  96. });
  97. } else {
  98. uni.$u.toast('请先登录')
  99. }
  100. },
  101. // 地址管理
  102. goAddress() {
  103. if (this.token) {
  104. uni.navigateTo({
  105. url: '/pages/mine/address'
  106. });
  107. } else {
  108. uni.$u.toast('请先登录')
  109. }
  110. },
  111. // 系统设置
  112. goSet() {
  113. if (this.token) {
  114. uni.navigateTo({
  115. url: '/pages/mine/system'
  116. });
  117. } else {
  118. uni.$u.toast('请先登录')
  119. }
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss">
  125. .card_user_title {
  126. display: flex;
  127. flex-direction: column;
  128. align-items: flex-start;
  129. }
  130. .card_mine {
  131. padding-top: var(--status-bar-height);
  132. padding: 0rpx 30rpx;
  133. }
  134. .mine_image {
  135. width: 100rpx;
  136. height: 100rpx;
  137. border-radius: 50%;
  138. }
  139. .mine_phone {
  140. margin-left: 20rpx;
  141. font-size: 30rpx;
  142. }
  143. .mine_title {
  144. margin-left: 20rpx;
  145. font-size: 40rpx;
  146. font-weight: bold;
  147. }
  148. .card_avatar {
  149. display: flex;
  150. align-items: center;
  151. margin-bottom: 60rpx;
  152. padding-top: 60rpx;
  153. }
  154. .card_mine_option {
  155. margin: 40rpx 0rpx;
  156. padding-bottom: 30rpx;
  157. border-bottom: 2rpx solid #E4E7ED;
  158. }
  159. .option_title {
  160. font-size: 32rpx;
  161. font-weight: bold;
  162. }
  163. </style>