s-user-card.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. // 是否登录
  63. const isLogin = computed(() => sheep.$store('user').isLogin);
  64. // 接收参数
  65. const props = defineProps({
  66. background: {
  67. type: String,
  68. default: '',
  69. },
  70. // 头像
  71. avatar: {
  72. type: String,
  73. default: '',
  74. },
  75. nickname: {
  76. type: String,
  77. default: '请先登录',
  78. },
  79. vip: {
  80. type: [String, Number],
  81. default: '1',
  82. },
  83. collectNum: {
  84. type: [String, Number],
  85. default: '1',
  86. },
  87. likeNum: {
  88. type: [String, Number],
  89. default: '1',
  90. },
  91. });
  92. function onBind() {
  93. showAuthModal('changeMobile');
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .ss-user-info-wrap {
  98. box-sizing: border-box;
  99. .avatar-box {
  100. width: 100rpx;
  101. height: 100rpx;
  102. border-radius: 50%;
  103. overflow: hidden;
  104. .avatar-img {
  105. width: 100%;
  106. height: 100%;
  107. }
  108. }
  109. .nick-name {
  110. font-size: 34rpx;
  111. font-weight: 400;
  112. color: #333333;
  113. line-height: normal;
  114. }
  115. .vip-img {
  116. width: 30rpx;
  117. height: 30rpx;
  118. }
  119. .sicon-qrcode {
  120. font-size: 40rpx;
  121. }
  122. }
  123. .bind-mobile-box {
  124. width: 100%;
  125. height: 84rpx;
  126. padding: 0 34rpx 0 44rpx;
  127. box-sizing: border-box;
  128. background: #ffffff;
  129. box-shadow: 0px -8rpx 9rpx 0px rgba(#e0e0e0, 0.3);
  130. .cicon-mobile-o {
  131. font-size: 30rpx;
  132. color: #ff690d;
  133. }
  134. .mobile-title {
  135. font-size: 24rpx;
  136. font-weight: 500;
  137. color: #ff690d;
  138. }
  139. .bind-btn {
  140. width: 100rpx;
  141. height: 50rpx;
  142. background: #ff6100;
  143. border-radius: 25rpx;
  144. font-size: 24rpx;
  145. font-weight: 500;
  146. color: #ffffff;
  147. }
  148. }
  149. </style>