s-user-card.vue 3.6 KB

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