index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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="goSet">
  20. <view class="option_title">系统设置</view>
  21. <u-icon name="arrow-right" size="20"></u-icon>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. token: '',
  30. userInfo: {},
  31. }
  32. },
  33. mounted() {
  34. var token = this.$cache.getToken()
  35. this.token = token
  36. var userInfo = this.$cache.getCache('userInfo')
  37. this.userInfo = userInfo
  38. },
  39. methods: {
  40. //微信授权
  41. set_is_login(val) {
  42. let _this = this;
  43. uni.getUserProfile({
  44. 'desc': '获取用户基本信息',
  45. 'lang': 'zh_CN',
  46. success: function(infoRes) {
  47. console.log(infoRes, 8)
  48. uni.login({
  49. success: function(loginRes) {
  50. console.log(loginRes, 23)
  51. }
  52. });
  53. },
  54. });
  55. },
  56. // 登录注册
  57. login() {
  58. uni.navigateTo({
  59. url: '/pages/login'
  60. });
  61. },
  62. // 个人资料
  63. goPersonal() {
  64. uni.navigateTo({
  65. url: '/pages/mine/personal'
  66. });
  67. },
  68. // 系统设置
  69. goSet() {
  70. uni.navigateTo({
  71. url: '/pages/mine/system'
  72. });
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss">
  78. .card_user_title {
  79. display: flex;
  80. flex-direction: column;
  81. align-items: flex-start;
  82. }
  83. .card_mine {
  84. padding-top: var(--status-bar-height);
  85. padding: 0rpx 30rpx;
  86. }
  87. .mine_image {
  88. width: 100rpx;
  89. height: 100rpx;
  90. border-radius: 50%;
  91. }
  92. .mine_phone {
  93. margin-left: 20rpx;
  94. font-size: 30rpx;
  95. }
  96. .mine_title {
  97. margin-left: 20rpx;
  98. font-size: 40rpx;
  99. font-weight: bold;
  100. }
  101. .card_avatar {
  102. display: flex;
  103. align-items: center;
  104. margin-bottom: 60rpx;
  105. padding-top: 60rpx;
  106. }
  107. .card_mine_option {
  108. margin: 40rpx 0rpx;
  109. padding-bottom: 30rpx;
  110. border-bottom: 2rpx solid #E4E7ED;
  111. }
  112. .option_title {
  113. font-size: 32rpx;
  114. font-weight: bold;
  115. }
  116. </style>