s-user-card.vue 4.2 KB

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