s-user-card.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <!-- 页面 -->
  2. <template>
  3. <view class="ss-user-info-wrap ss-p-t-50">
  4. <view class="ss-flex ss-col-center ss-row-between ss-m-b-20">
  5. <view class="left-box ss-flex ss-col-center ss-m-l-36">
  6. <view class="avatar-box ss-m-r-24">
  7. <image
  8. class="avatar-img"
  9. :src="
  10. isLogin
  11. ? sheep.$url.cdn(userInfo.avatar)
  12. : sheep.$url.static('/static/img/shop/default_avatar.png')
  13. "
  14. mode="aspectFill"
  15. @tap="sheep.$router.go('/pages/user/info')"
  16. ></image>
  17. </view>
  18. <view>
  19. <view class="nickname-box ss-flex ss-col-center">
  20. <view class="nick-name ss-m-r-20">{{ userInfo?.nickname || nickname }}</view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="right-box ss-m-r-52">
  25. <button class="ss-reset-button" @tap="showShareModal">
  26. <text class="sicon-qrcode"></text>
  27. </button>
  28. </view>
  29. </view>
  30. <view
  31. class="bind-mobile-box ss-flex ss-row-between ss-col-center"
  32. v-if="isLogin && !userInfo.verification?.mobile"
  33. >
  34. <view class="ss-flex">
  35. <text class="cicon-mobile-o"></text>
  36. <view class="mobile-title ss-m-l-20"> 点击绑定手机号确保账户安全 </view>
  37. </view>
  38. <button class="ss-reset-button bind-btn" @tap="onBind">去绑定</button>
  39. </view>
  40. </view>
  41. </template>
  42. <script setup>
  43. /**
  44. * 用户卡片
  45. *
  46. * @property {Number} leftSpace - 容器左间距
  47. * @property {Number} rightSpace - 容器右间距
  48. *
  49. * @property {String} avatar - 头像
  50. * @property {String} nickname - 昵称
  51. * @property {String} vip - 等级
  52. * @property {String} collectNum - 收藏数
  53. * @property {String} likeNum - 点赞数
  54. *
  55. *
  56. */
  57. import { computed, reactive } from 'vue';
  58. import sheep from '@/sheep';
  59. import { showShareModal, showAuthModal } from '@/sheep/hooks/useModal';
  60. // 用户信息
  61. const userInfo = computed(() => sheep.$store('user').userInfo);
  62. console.log('用户信息',userInfo)
  63. // 是否登录
  64. const isLogin = computed(() => sheep.$store('user').isLogin);
  65. // 接收参数
  66. const props = defineProps({
  67. background: {
  68. type: String,
  69. default: '',
  70. },
  71. // 头像
  72. avatar: {
  73. type: String,
  74. default: '',
  75. },
  76. nickname: {
  77. type: String,
  78. default: '请先登录',
  79. },
  80. vip: {
  81. type: [String, Number],
  82. default: '1',
  83. },
  84. collectNum: {
  85. type: [String, Number],
  86. default: '1',
  87. },
  88. likeNum: {
  89. type: [String, Number],
  90. default: '1',
  91. },
  92. });
  93. function onBind() {
  94. showAuthModal('changeMobile');
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. .ss-user-info-wrap {
  99. box-sizing: border-box;
  100. .avatar-box {
  101. width: 100rpx;
  102. height: 100rpx;
  103. border-radius: 50%;
  104. overflow: hidden;
  105. .avatar-img {
  106. width: 100%;
  107. height: 100%;
  108. }
  109. }
  110. .nick-name {
  111. font-size: 34rpx;
  112. font-weight: 400;
  113. color: #333333;
  114. line-height: normal;
  115. }
  116. .vip-img {
  117. width: 30rpx;
  118. height: 30rpx;
  119. }
  120. .sicon-qrcode {
  121. font-size: 40rpx;
  122. }
  123. }
  124. .bind-mobile-box {
  125. width: 100%;
  126. height: 84rpx;
  127. padding: 0 34rpx 0 44rpx;
  128. box-sizing: border-box;
  129. background: #ffffff;
  130. box-shadow: 0px -8rpx 9rpx 0px rgba(#e0e0e0, 0.3);
  131. .cicon-mobile-o {
  132. font-size: 30rpx;
  133. color: #ff690d;
  134. }
  135. .mobile-title {
  136. font-size: 24rpx;
  137. font-weight: 500;
  138. color: #ff690d;
  139. }
  140. .bind-btn {
  141. width: 100rpx;
  142. height: 50rpx;
  143. background: #ff6100;
  144. border-radius: 25rpx;
  145. font-size: 24rpx;
  146. font-weight: 500;
  147. color: #ffffff;
  148. }
  149. }
  150. </style>