s-user-card.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <!-- 装修用户组件:用户卡片 -->
  2. <template>
  3. <view class="ss-user-info-wrap ss-p-t-50" :style="[bgStyle, { marginLeft: `${data.space}px` }]">
  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="isLogin
  8. ? sheep.$url.cdn(userInfo.avatar)
  9. : sheep.$url.static('/static/img/shop/default_avatar.png')" mode="aspectFill"
  10. @tap="sheep.$router.go('/pages/user/info')">
  11. </image>
  12. </view>
  13. <view>
  14. <view class="nickname-box ss-flex ss-col-center"
  15. @tap="!userInfo?.nickname && sheep.$router.go('/pages/app/sign')">
  16. <view class="nick-name ss-m-r-20">{{ userInfo?.nickname || nickname }}</view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="right-box ss-m-r-52">
  21. <button class="ss-reset-button" @tap="showShareModal">
  22. <text class="sicon-qrcode"></text>
  23. </button>
  24. </view>
  25. </view>
  26. <view class="sign-card">
  27. <image class="sign-card__bg-img"
  28. src="https://seal-img.nos-jd.163yun.com/obj/w5rCgMKVw6DCmGzCmsK-/60938586057/a6c7/0b14/00ec/e47d6346bcc8c5764ca7a85c4da7736f.png" />
  29. <view class="sign-card__content">
  30. <view class="sign-card__info">
  31. <view class="sign-card__title">
  32. <image class="sign-card__icon" :src="sheep.$url.static('/static/user/qd.png')" />
  33. <text class="sign-card__text">每日签到</text>
  34. </view>
  35. <text class="sign-card__desc">积分可在购物时抵扣现金结算</text>
  36. </view>
  37. <text class="sign-card__btn" @tap="sheep.$router.go('/pages/app/sign')">立即签到</text>
  38. </view>
  39. </view>
  40. <!-- 提示绑定手机号 先隐藏 yudao 需要再修改 -->
  41. <view class="bind-mobile-box ss-flex ss-row-between ss-col-center" v-if="isLogin && !userInfo.mobile">
  42. <view class="ss-flex">
  43. <text class="cicon-mobile-o" />
  44. <view class="mobile-title ss-m-l-20"> 点击绑定手机号确保账户安全</view>
  45. </view>
  46. <button class="ss-reset-button bind-btn" @tap="onBind">去绑定</button>
  47. </view>
  48. </view>
  49. </template>
  50. <script setup>
  51. /**
  52. * 用户卡片
  53. *
  54. * @property {Number} leftSpace - 容器左间距
  55. * @property {Number} rightSpace - 容器右间距
  56. *
  57. * @property {String} avatar - 头像
  58. * @property {String} nickname - 昵称
  59. * @property {String} vip - 等级
  60. * @property {String} collectNum - 收藏数
  61. * @property {String} likeNum - 点赞数
  62. *
  63. *
  64. */
  65. import { computed } from 'vue';
  66. import sheep from '@/sheep';
  67. import {
  68. showShareModal,
  69. showAuthModal,
  70. } from '@/sheep/hooks/useModal';
  71. // 用户信息
  72. const userInfo = computed(() => sheep.$store('user').userInfo);
  73. console.log('用户信息', userInfo);
  74. // 是否登录
  75. const isLogin = computed(() => sheep.$store('user').isLogin);
  76. // 接收参数
  77. const props = defineProps({
  78. // 装修数据
  79. data: {
  80. type: Object,
  81. default: () => ({}),
  82. },
  83. // 装修样式
  84. styles: {
  85. type: Object,
  86. default: () => ({}),
  87. },
  88. // 头像
  89. avatar: {
  90. type: String,
  91. default: '',
  92. },
  93. nickname: {
  94. type: String,
  95. default: '请先登录',
  96. },
  97. vip: {
  98. type: [String, Number],
  99. default: '1',
  100. },
  101. collectNum: {
  102. type: [String, Number],
  103. default: '1',
  104. },
  105. likeNum: {
  106. type: [String, Number],
  107. default: '1',
  108. },
  109. });
  110. // 设置背景样式
  111. const bgStyle = computed(() => {
  112. // 直接从 props.styles 解构
  113. const { bgType, bgImg, bgColor } = props.styles;
  114. // 根据 bgType 返回相应的样式
  115. return {
  116. background: bgType === 'img'
  117. ? `url(${bgImg}) no-repeat top center / 100% 100%`
  118. : bgColor,
  119. };
  120. });
  121. // 绑定手机号
  122. function onBind() {
  123. showAuthModal('changeMobile');
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. .sign-card {
  128. position: relative;
  129. width: calc(100% - 32px);
  130. height: auto;
  131. overflow: hidden;
  132. border-radius: 8px;
  133. background: linear-gradient(268.29deg, #2d3057 5.97%, #3f446f 87.85%);
  134. display: flex;
  135. flex-direction: column;
  136. align-items: flex-start;
  137. min-height: 85px;
  138. margin: 0 16px;
  139. &__bg-img {
  140. width: 230px;
  141. height: 225px;
  142. position: absolute;
  143. transform: rotate(34deg);
  144. object-fit: cover;
  145. right: -124px;
  146. bottom: -131px;
  147. }
  148. &__content {
  149. position: absolute;
  150. top: 6px;
  151. left: 0;
  152. right: 0;
  153. bottom: 0;
  154. display: flex;
  155. align-items: center;
  156. gap: 83px;
  157. width: max-content;
  158. height: max-content;
  159. margin: auto;
  160. }
  161. &__info {
  162. display: flex;
  163. flex-direction: column;
  164. gap: 8px;
  165. }
  166. &__desc {
  167. font-size: 12px;
  168. font-family: 'PingFang SC';
  169. line-height: 17px;
  170. color: rgba(255, 255, 255, 0.4);
  171. white-space: pre;
  172. }
  173. &__title {
  174. display: flex;
  175. align-items: center;
  176. gap: 6px;
  177. font-size: 16px;
  178. font-family: 'PingFang SC';
  179. line-height: 22px;
  180. color: #ffffff;
  181. white-space: pre;
  182. }
  183. &__icon {
  184. width: 25px;
  185. height: 25px;
  186. // margin: -34px 0 4px 0;
  187. }
  188. &__btn {
  189. padding: 4px 12px;
  190. border-radius: 286px;
  191. background-color: #ffffff;
  192. font-size: 12px;
  193. font-family: 'PingFang SC';
  194. line-height: 16px;
  195. color: #31345c;
  196. white-space: pre;
  197. }
  198. }
  199. .ss-user-info-wrap {
  200. box-sizing: border-box;
  201. .avatar-box {
  202. width: 100rpx;
  203. height: 100rpx;
  204. border-radius: 50%;
  205. overflow: hidden;
  206. .avatar-img {
  207. width: 100%;
  208. height: 100%;
  209. }
  210. }
  211. .nick-name {
  212. font-size: 34rpx;
  213. font-weight: 400;
  214. color: #333333;
  215. line-height: normal;
  216. }
  217. .vip-img {
  218. width: 30rpx;
  219. height: 30rpx;
  220. }
  221. .sicon-qrcode {
  222. font-size: 40rpx;
  223. }
  224. }
  225. .bind-mobile-box {
  226. width: 100%;
  227. height: 84rpx;
  228. padding: 0 34rpx 0 44rpx;
  229. box-sizing: border-box;
  230. background: #ffffff;
  231. box-shadow: 0px -8rpx 9rpx 0px rgba(#e0e0e0, 0.3);
  232. .cicon-mobile-o {
  233. font-size: 30rpx;
  234. color: #ff690d;
  235. }
  236. .mobile-title {
  237. font-size: 24rpx;
  238. font-weight: 500;
  239. color: #ff690d;
  240. }
  241. .bind-btn {
  242. width: 100rpx;
  243. height: 50rpx;
  244. background: #ff6100;
  245. border-radius: 25rpx;
  246. font-size: 24rpx;
  247. font-weight: 500;
  248. color: #ffffff;
  249. }
  250. }
  251. </style>