s-activity-pop.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <!-- 商品信息:满减送等营销活动的弹窗 -->
  2. <template>
  3. <su-popup :show="show" type="bottom" round="20" @close="emits('close')" showClose>
  4. <view class="model-box">
  5. <view class="title ss-m-t-16 ss-m-l-20 ss-flex">营销活动</view>
  6. <scroll-view
  7. class="model-content ss-m-t-50"
  8. scroll-y
  9. :scroll-with-animation="false"
  10. :enable-back-to-top="true"
  11. >
  12. <view v-for="item in state.activityInfo" :key="item.id">
  13. <view class="ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(item)">
  14. <view class="model-content-tag ss-flex ss-row-center">满减</view>
  15. <view class="ss-m-l-20 model-content-title ss-flex-1">
  16. <view class="ss-m-b-24" v-for="rule in state.activityMap[item.id]?.rules" :key="rule">
  17. {{ formatRewardActivityRule(state.activityMap[item.id], rule) }}
  18. </view>
  19. </view>
  20. <text class="cicon-forward" />
  21. </view>
  22. </view>
  23. </scroll-view>
  24. </view>
  25. </su-popup>
  26. </template>
  27. <script setup>
  28. import sheep from '@/sheep';
  29. import { computed, reactive, watch } from 'vue';
  30. import RewardActivityApi from '@/sheep/api/promotion/rewardActivity';
  31. import { formatRewardActivityRule } from '@/sheep/hooks/useGoods';
  32. const props = defineProps({
  33. modelValue: {
  34. type: Object,
  35. default() {},
  36. },
  37. show: {
  38. type: Boolean,
  39. default: false,
  40. },
  41. });
  42. const emits = defineEmits(['close']);
  43. const state = reactive({
  44. activityInfo: computed(() => props.modelValue),
  45. activityMap: {}
  46. });
  47. watch(
  48. () => props.show,
  49. () => {
  50. // 展示的情况下,加载每个活动的详细信息
  51. if (props.show) {
  52. state.activityInfo?.forEach(activity => {
  53. RewardActivityApi.getRewardActivity(activity.id).then(res => {
  54. if (res.code !== 0) {
  55. return;
  56. }
  57. state.activityMap[activity.id] = res.data;
  58. })
  59. });
  60. }
  61. },
  62. );
  63. function onGoodsList(e) {
  64. sheep.$router.go('/pages/activity/index', {
  65. activityId: e.id,
  66. });
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .model-box {
  71. height: 60vh;
  72. .title {
  73. font-size: 36rpx;
  74. height: 80rpx;
  75. font-weight: bold;
  76. color: #333333;
  77. }
  78. }
  79. .model-content {
  80. padding: 0 20rpx;
  81. box-sizing: border-box;
  82. .model-content-tag {
  83. background: rgba(#ff6911, 0.1);
  84. font-size: 24rpx;
  85. font-weight: 500;
  86. color: #ff6911;
  87. line-height: 42rpx;
  88. width: 68rpx;
  89. height: 32rpx;
  90. border-radius: 5rpx;
  91. }
  92. .model-content-title {
  93. font-size: 26rpx;
  94. font-weight: 500;
  95. color: #333333;
  96. }
  97. .cicon-forward {
  98. font-size: 28rpx;
  99. color: #999999;
  100. }
  101. }
  102. </style>