s-user-card.vue 6.1 KB

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