s-user-card.vue 3.8 KB

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