s-activity-pop.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. <view v-if="state.rewardActivity && state.rewardActivity.id > 0">
  7. <view class="titleLi">促销</view>
  8. <scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
  9. <view class="actBox" v-for="(item, index) in state.handeActivity" :key="index">
  10. <view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.rewardActivity)">
  11. <view class="model-content-tag ss-flex ss-row-center">{{item.name}}</view>
  12. <view class="model-content-title">
  13. <view class="contBu">
  14. <text v-for="(items,indexs) in item.value" :key="indexs">{{ items }};</text>
  15. </view>
  16. <view class="ss-m-b-24 cotBu-txt">
  17. {{ sheep.$helper.timeFormat(state.rewardActivity.startTime, 'yyyy.mm.dd') }}
  18. -
  19. {{ sheep.$helper.timeFormat(state.rewardActivity.endTime, 'yyyy.mm.dd') }}
  20. </view>
  21. </view>
  22. <text class="cicon-forward" />
  23. </view>
  24. </view>
  25. </scroll-view>
  26. </view>
  27. <view class="titleLi">可领优惠券</view>
  28. <scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true" v-if="state.couponInfo.length">
  29. <view class="actBox" v-for="item in state.couponInfo" :key="item.id">
  30. <view class="boxCont ss-flex ss-col-top ss-m-b-40">
  31. <view class="model-content-tag2">
  32. <view class="usePrice"> ¥{{ fen2yuan(item.discountPrice) }} </view>
  33. <view class="impose"> 满¥{{ fen2yuan(item.usePrice) }}可用 </view>
  34. </view>
  35. <view class="model-content-title2">
  36. <view class="contBu">
  37. {{ item.name }}
  38. </view>
  39. <view class="ss-m-b-24 cotBu-txt">
  40. {{
  41. item.validityType == 1
  42. ? sheep.$helper.timeFormat(item.validStartTime, 'yyyy.mm.dd') -
  43. sheep.$helper.timeFormat(item.validEndTime, 'yyyy.mm.dd')
  44. : '领取后' + item.fixedStartTerm + '-' + item.fixedEndTerm + '天可用'
  45. }}
  46. </view>
  47. </view>
  48. <view class="coupon" @click.stop="getBuy(item.id)" v-if="item.canTake"> 立即领取 </view>
  49. <view class="coupon2" v-else> 已领取 </view>
  50. </view>
  51. </view>
  52. </scroll-view>
  53. <view class="nullBox" v-else>
  54. 暂无可领优惠券
  55. </view>
  56. </view>
  57. </su-popup>
  58. </template>
  59. <script setup>
  60. import sheep from '@/sheep';
  61. import {
  62. handeleData
  63. } from '@/sheep/hooks/useGoods';
  64. import {
  65. computed,
  66. reactive,
  67. watch,
  68. ref
  69. } from 'vue';
  70. import {
  71. fen2yuan
  72. } from '@/sheep/hooks/useGoods';
  73. const props = defineProps({
  74. modelValue: {
  75. type: Object,
  76. default () {},
  77. },
  78. show: {
  79. type: Boolean,
  80. default: false,
  81. },
  82. });
  83. const emits = defineEmits(['close']);
  84. const state = reactive({
  85. rewardActivity: computed(() => props.modelValue.rewardActivity),
  86. couponInfo: computed(() => props.modelValue.couponInfo),
  87. });
  88. // setTimeout(()=>{
  89. // console.log('历程数据',state.rewardActivity.ruleDescriptions)
  90. // console.log('处理数据',handeleData(props.modelValue.rewardActivity.ruleDescriptions))
  91. // },5000)
  92. // 领取优惠劵
  93. const getBuy = (id) => {
  94. emits('get', id);
  95. };
  96. function onGoodsList(e) {
  97. sheep.$router.go('/pages/activity/index', {
  98. activityId: e.id,
  99. });
  100. }
  101. //监听获取到数据后再执行且只执行一次
  102. let flag = ref(true)
  103. watch(state, (newValue, oldValue) => {
  104. if (flag.value) {
  105. flag.value = false
  106. state.handeActivity = handeleData(state.rewardActivity.ruleDescriptions)
  107. }
  108. });
  109. </script>
  110. <style lang="scss" scoped>
  111. .model-box {
  112. height: 60vh;
  113. .title {
  114. justify-content: center;
  115. font-size: 36rpx;
  116. height: 80rpx;
  117. font-weight: bold;
  118. color: #333333;
  119. }
  120. }
  121. .model-content {
  122. height: fit-content;
  123. max-height: 380rpx;
  124. padding: 0 20rpx;
  125. box-sizing: border-box;
  126. margin-top: 20rpx;
  127. .model-content-tag {
  128. // background: rgba(#ff6911, 0.1);
  129. font-size: 35rpx;
  130. font-weight: 500;
  131. color: #ff6911;
  132. line-height: 150rpx;
  133. width: 200rpx;
  134. height: 150rpx;
  135. text-align: center;
  136. // border-radius: 5rpx;
  137. }
  138. .model-content-title {
  139. width: 450rpx;
  140. height: 150rpx;
  141. font-size: 26rpx;
  142. font-weight: 500;
  143. color: #333333;
  144. overflow: hidden;
  145. }
  146. .cicon-forward {
  147. font-size: 28rpx;
  148. color: #999999;
  149. margin: 0 auto;
  150. }
  151. }
  152. // 新增的
  153. .titleLi {
  154. margin: 10rpx 0 10rpx 20rpx;
  155. font-size: 26rpx;
  156. }
  157. .actBox {
  158. width: 700rpx;
  159. height: 150rpx;
  160. background-color: #fff2f2;
  161. margin: 10rpx auto;
  162. border-radius: 10rpx;
  163. }
  164. .boxCont {
  165. width: 700rpx;
  166. height: 150rpx;
  167. align-items: center;
  168. }
  169. .contBu {
  170. height: 80rpx;
  171. line-height: 80rpx;
  172. overflow: hidden;
  173. font-size: 30rpx;
  174. white-space: nowrap;
  175. text-overflow: ellipsis;
  176. -o-text-overflow: ellipsis;
  177. }
  178. .cotBu-txt {
  179. height: 70rpx;
  180. line-height: 70rpx;
  181. font-size: 25rpx;
  182. color: #999999;
  183. }
  184. .model-content-tag2 {
  185. font-size: 35rpx;
  186. font-weight: 500;
  187. color: #ff6911;
  188. width: 200rpx;
  189. height: 150rpx;
  190. text-align: center;
  191. }
  192. .usePrice {
  193. width: 200rpx;
  194. height: 90rpx;
  195. line-height: 100rpx;
  196. // background-color: red;
  197. }
  198. .impose {
  199. width: 200rpx;
  200. height: 50rpx;
  201. // line-height: 75rpx;
  202. font-size: 23rpx;
  203. // background-color: gold;
  204. }
  205. .model-content-title2 {
  206. width: 330rpx;
  207. height: 150rpx;
  208. font-size: 26rpx;
  209. font-weight: 500;
  210. color: #333333;
  211. overflow: hidden;
  212. }
  213. .coupon {
  214. width: 150rpx;
  215. height: 50rpx;
  216. line-height: 50rpx;
  217. background-color: rgb(255, 68, 68);
  218. color: white;
  219. border-radius: 30rpx;
  220. text-align: center;
  221. font-size: 25rpx;
  222. }
  223. .coupon2 {
  224. width: 150rpx;
  225. height: 50rpx;
  226. line-height: 50rpx;
  227. background-color: rgb(203, 192, 191);
  228. color: white;
  229. border-radius: 30rpx;
  230. text-align: center;
  231. font-size: 25rpx;
  232. }
  233. .nullBox{
  234. width: 100%;
  235. height: 300rpx;
  236. font-size: 25rpx;
  237. line-height: 300rpx;
  238. text-align: center;
  239. color: #999999;
  240. }
  241. </style>