index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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="goPersonal">
  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. goSet() {
  103. if (this.token) {
  104. uni.navigateTo({
  105. url: '/pages/mine/system'
  106. });
  107. } else {
  108. uni.$u.toast('请先登录')
  109. }
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss">
  115. .card_user_title {
  116. display: flex;
  117. flex-direction: column;
  118. align-items: flex-start;
  119. }
  120. .card_mine {
  121. padding-top: var(--status-bar-height);
  122. padding: 0rpx 30rpx;
  123. }
  124. .mine_image {
  125. width: 100rpx;
  126. height: 100rpx;
  127. border-radius: 50%;
  128. }
  129. .mine_phone {
  130. margin-left: 20rpx;
  131. font-size: 30rpx;
  132. }
  133. .mine_title {
  134. margin-left: 20rpx;
  135. font-size: 40rpx;
  136. font-weight: bold;
  137. }
  138. .card_avatar {
  139. display: flex;
  140. align-items: center;
  141. margin-bottom: 60rpx;
  142. padding-top: 60rpx;
  143. }
  144. .card_mine_option {
  145. margin: 40rpx 0rpx;
  146. padding-bottom: 30rpx;
  147. border-bottom: 2rpx solid #E4E7ED;
  148. }
  149. .option_title {
  150. font-size: 32rpx;
  151. font-weight: bold;
  152. }
  153. </style>