s-coupon-card.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <!-- 装修用户组件:用户卡券 -->
  2. <template>
  3. <view class="ss-coupon-menu-wrap ss-flex ss-col-center" :style="[bgStyle, { marginLeft: `${data.space}px` }]">
  4. <view class="menu-item ss-flex-col ss-row-center ss-col-center" v-for="item in props.list" :key="item.title"
  5. @tap="sheep.$router.go(item.path, { type: item.type })"
  6. :class="item.type === 'all' ? 'menu-wallet' : 'ss-flex-1'">
  7. <image class="item-icon" :src="sheep.$url.static(item.icon)" mode="aspectFit"></image>
  8. <view class="menu-title ss-m-t-28">{{ item.title }}</view>
  9. </view>
  10. </view>
  11. </template>
  12. <script setup>
  13. /**
  14. * 装修组件 - 优惠券菜单
  15. */
  16. import sheep from '@/sheep';
  17. import { computed } from 'vue';
  18. // 接收参数
  19. const props = defineProps({
  20. list: {
  21. type: Array,
  22. default () {
  23. return [{
  24. title: '已领取',
  25. value: '0',
  26. icon: '/static/img/shop/order/nouse_coupon.png',
  27. path: '/pages/coupon/list',
  28. type: 'geted',
  29. },
  30. {
  31. title: '已使用',
  32. value: '0',
  33. icon: '/static/img/shop/order/useend_coupon.png',
  34. path: '/pages/coupon/list',
  35. type: 'used',
  36. },
  37. {
  38. title: '已失效',
  39. value: '0',
  40. icon: '/static/img/shop/order/out_coupon.png',
  41. path: '/pages/coupon/list',
  42. type: 'expired',
  43. },
  44. {
  45. title: '领券中心',
  46. value: '0',
  47. icon: '/static/img/shop/order/all_coupon.png',
  48. path: '/pages/coupon/list',
  49. type: 'all',
  50. },
  51. ];
  52. },
  53. },
  54. // 装修数据
  55. data: {
  56. type: Object,
  57. default: () => ({}),
  58. },
  59. // 装修样式
  60. styles: {
  61. type: Object,
  62. default: () => ({}),
  63. },
  64. });
  65. // 设置背景样式
  66. const bgStyle = computed(() => {
  67. // 直接从 props.styles 解构
  68. const { bgType, bgImg, bgColor } = props.styles;
  69. // 根据 bgType 返回相应的样式
  70. return {
  71. background: bgType === 'img'
  72. ? `url(${bgImg}) no-repeat top center / 100% 100%`
  73. : bgColor
  74. };
  75. });
  76. </script>
  77. <style lang="scss" scoped>
  78. .ss-coupon-menu-wrap {
  79. .menu-item {
  80. height: 160rpx;
  81. .menu-title {
  82. font-size: 24rpx;
  83. line-height: 24rpx;
  84. color: #333333;
  85. }
  86. .item-icon {
  87. width: 44rpx;
  88. height: 44rpx;
  89. }
  90. }
  91. .menu-wallet {
  92. width: 144rpx;
  93. }
  94. }
  95. </style>