index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <script>
  2. import { setCouponReceive } from '@/api/api.js';
  3. import baseDrawer from '@/components/tui-drawer/tui-drawer.vue';
  4. export default {
  5. props: {
  6. visible: {
  7. type: Boolean,
  8. default: false
  9. },
  10. discountInfo: {
  11. type: Object,
  12. default: () => {}
  13. },
  14. coupon: {
  15. type: Object,
  16. default: () => {}
  17. },
  18. computedPrice: {
  19. type: Object,
  20. default: () => {}
  21. }
  22. },
  23. data() {
  24. return {
  25. ruleshow: false
  26. };
  27. },
  28. filters: {
  29. typeFilter(val) {
  30. let obj = {
  31. 0: '通用券',
  32. 1: '品类券',
  33. 2: '商品券',
  34. 3: '品牌券'
  35. };
  36. return obj[val];
  37. }
  38. },
  39. components: {
  40. baseDrawer
  41. },
  42. methods: {
  43. closeDrawer() {
  44. this.$emit('closeDrawer');
  45. },
  46. getCouponUser(item, index) {
  47. if (item.is_use) {
  48. this.$emit('closeDrawer');
  49. return;
  50. }
  51. setCouponReceive(item.id)
  52. .then((res) => {
  53. this.$emit('ChangCouponsUseState', index);
  54. this.$util.Tips({
  55. title: '领取成功'
  56. });
  57. })
  58. .catch((err) => {
  59. this.$util.Tips({
  60. title: err
  61. });
  62. });
  63. },
  64. toggleRule(index) {
  65. this.$emit('ruleToggle', index);
  66. }
  67. }
  68. };
  69. </script>
  70. <template>
  71. <view>
  72. <base-drawer mode="bottom" :visible="visible" background-color="transparent" mask maskClosable @close="closeDrawer">
  73. <view class="w-full bg--w111-f5f5f5 rd-t-40rpx py-32">
  74. <view class="text-center fs-32 text--w111-333 fw-500">优惠</view>
  75. <view class="mt-48 px-20">
  76. <scroll-view scroll-y="true" style="height: 800rpx;">
  77. <view v-if="computedPrice.deduction && computedPrice.deduction.sum_price > computedPrice.deduction.pay_price">
  78. <view class="flex-center">
  79. <view class="inline-block p-14 rd-16rpx bg-primary-light text-center">
  80. <view class="text-primary-con fs-32 lh-32rpx Regular fw-600">¥{{ computedPrice.deduction.pay_price }}</view>
  81. <view class="fs-20 lh-28rpx text-primary-con pt-6">预估到手</view>
  82. </view>
  83. </view>
  84. <view class="border_bg relative mt-20 flex-center">
  85. <view class="w-132 h-88 rd-16rpx bg-primary-light flex-col flex-center relative z-10">
  86. <view class="text-primary-con fs-32 lh-32rpx fw-600 Regular">¥{{ computedPrice.deduction.sum_price }}</view>
  87. <view class="fs-20 lh-28rpx text-primary-con">商品原价</view>
  88. </view>
  89. <view class="reduce" v-if="computedPrice.deduction.first_order_price > 0"></view>
  90. <view class="w-132 h-88 rd-16rpx bg-primary-light flex-col flex-center relative z-10" v-if="computedPrice.deduction.first_order_price > 0">
  91. <view class="text-primary-con fs-32 lh-32rpx fw-600 Regular">¥{{ computedPrice.deduction.first_order_price }}</view>
  92. <view class="fs-20 lh-28rpx text-primary-con">首单优惠</view>
  93. </view>
  94. <view class="reduce" v-if="computedPrice.deduction.vip_price > 0"></view>
  95. <view class="w-132 h-88 rd-16rpx bg-primary-light flex-col flex-center relative z-10" v-if="computedPrice.deduction.vip_price > 0">
  96. <view class="text-primary-con fs-32 lh-32rpx fw-600 Regular">¥{{ computedPrice.deduction.vip_price }}</view>
  97. <view class="fs-20 lh-28rpx text-primary-con">会员优惠</view>
  98. </view>
  99. <view class="reduce" v-if="computedPrice.deduction.promotions_price > 0"></view>
  100. <view class="w-132 h-88 rd-16rpx bg-primary-light flex-col flex-center relative z-10" v-if="computedPrice.deduction.promotions_price > 0">
  101. <view class="text-primary-con fs-32 lh-32rpx fw-600 Regular">¥{{ computedPrice.deduction.promotions_price }}</view>
  102. <view class="fs-20 lh-28rpx text-primary-con">活动优惠</view>
  103. </view>
  104. <view class="reduce" v-if="computedPrice.deduction.coupon_price > 0"></view>
  105. <view class="w-132 h-88 rd-16rpx bg-primary-light flex-col flex-center relative z-10" v-if="computedPrice.deduction.coupon_price > 0">
  106. <view class="text-primary-con fs-32 lh-32rpx fw-600 Regular">¥{{ computedPrice.deduction.coupon_price }}</view>
  107. <view class="fs-20 lh-28rpx text-primary-con">优惠券</view>
  108. </view>
  109. </view>
  110. </view>
  111. <view v-if="discountInfo.discount.length">
  112. <view class="text--w111-333 fs-24 mt-48 lh-34rpx">商品可参与以下优惠促销活动</view>
  113. <view class="bg--w111-fff rd-24rpx px-24 mt-24">
  114. <view class="py-24 card-cell" v-for="(item, index) in discountInfo.discount" :key="index">
  115. <view class="inline-block px-8 h-38 lh-36rpx rd-8rpx fs-20 con-border text-primary-con">
  116. {{ item.title }}
  117. </view>
  118. <view class="fs-20 lh-28rpx text--w111-666 mt-14">有效期至{{ item.stop_time }}</view>
  119. </view>
  120. </view>
  121. </view>
  122. <view v-if="coupon.list.length">
  123. <view class="text--w111-333 fs-24 mt-48 lh-34rpx">可领取优惠券</view>
  124. <view v-for="(item, index) in coupon.list" :key="index">
  125. <view class="mt-24 h-170 bg--w111-fff text-center rd-16rpx flex">
  126. <view class="left-bg bg-gradient">
  127. <view class="left-container w-full h-full relative flex-col flex-between-center py-32">
  128. <baseMoney
  129. :money="item.coupon_price"
  130. symbolSize="28"
  131. integerSize="52"
  132. decimalSize="28"
  133. color="#ffffff"
  134. isCoupon
  135. v-if="item.coupon_type == 1"></baseMoney>
  136. <view v-else class="text--w111-fff fs-44 SemiBold">{{ parseFloat(item.coupon_price) / 10 }} <text class="pingfang fs-28 pl-4">折</text></view>
  137. <text class="fs-24 text--w111-fff">满{{ item.use_min_price }}元可用</text>
  138. </view>
  139. </view>
  140. <view class="right-box pt-24 pl-24 pr-14 pb-22 flex-1 flex-col justify-between bg--w111-fff">
  141. <view class="flex-y-center">
  142. <view class="fs-28 fw-500 text--w111-333 lh-40rpx">{{ item.coupon_title }}</view>
  143. </view>
  144. <view class="flex-between-center">
  145. <view class="fs-20 text--w111-666 lh-28rpx" v-if="item.coupon_time">领取后{{ item.coupon_time }}天内可用</view>
  146. <view class="fs-20 text--w111-666 lh-28rpx" v-else>{{ item.start_time ? item.start_time + '-' : '' }}{{ item.end_time }}</view>
  147. <view class="con_btn bg-primary-light text-primary-con w-136 h-52 rd-28rpx fs-22 flex-center" @tap="getCouponUser(item, index)">
  148. {{ item.is_use ? '去使用' : '立即领取' }}
  149. </view>
  150. </view>
  151. <view class="flex-y-center fs-20 text--w111-999 lh-28rpx mt-20">
  152. <text>{{item.type | typeFilter}}</text>
  153. <view v-show="item.rule" @tap.stop="toggleRule(index)">
  154. <text class="pl-8"> | 查看用券规则</text>
  155. <text class="iconfont icon-ic_downarrow fs-20 ml-4"></text>
  156. </view>
  157. </view>
  158. </view>
  159. </view>
  160. <view class="rule-desc" v-show="item.ruleshow" v-html="item.rule"></view>
  161. </view>
  162. </view>
  163. </scroll-view>
  164. </view>
  165. <view class="mx-20 pb-safe">
  166. <view class="mt-52 h-72 flex-center rd-36px bg-color fs-26 text--w111-fff" @tap="closeDrawer">确定</view>
  167. </view>
  168. </view>
  169. </base-drawer>
  170. </view>
  171. </template>
  172. <style lang="scss">
  173. .border_bg {
  174. width: 100%;
  175. height: 130rpx;
  176. border: 1rpx solid var(--view-theme);
  177. border-radius: 16rpx;
  178. background-size: 100%;
  179. &:before {
  180. content: '';
  181. position: absolute;
  182. top: -1rpx;
  183. left: 50%;
  184. width: 18rpx;
  185. height: 18rpx;
  186. border: 1rpx solid var(--view-theme);
  187. background-color: #f5f5f5;
  188. box-sizing: border-box;
  189. transform: rotate(45deg) translate(-50%);
  190. }
  191. }
  192. .border_bg:after {
  193. content: '';
  194. position: absolute;
  195. top: 0;
  196. left: 50%;
  197. width: 36rpx;
  198. height: 36rpx;
  199. background-color: #f5f5f5;
  200. transform: translateX(-50%);
  201. // border-bottom-color: #f5f5f5;
  202. // top: -9px;
  203. }
  204. .left-bg {
  205. width: 190rpx;
  206. height: 170rpx;
  207. background-size: 100%;
  208. background-repeat: no-repeat;
  209. border-radius: 24rpx 0 0 24rpx;
  210. }
  211. .right-box {
  212. border-radius: 0 24rpx 24rpx 0;
  213. }
  214. .left-container {
  215. background: radial-gradient(circle at 0px 84rpx, #f5f5f5 12rpx, transparent 0px) top;
  216. &:after {
  217. content: '';
  218. position: absolute;
  219. top: 0;
  220. right: 0px;
  221. width: 6rpx;
  222. height: 100%;
  223. background-image: radial-gradient(circle at 6rpx 12rpx, #ffffff 6rpx, transparent 6rpx);
  224. background-size: 6rpx 18rpx;
  225. }
  226. }
  227. .text-primary-con {
  228. color: var(--view-theme);
  229. }
  230. .bg-primary-light {
  231. background: var(--view-minorColorT);
  232. }
  233. .con-border {
  234. border: 1rpx solid var(--view-theme);
  235. }
  236. .scroll-content {
  237. }
  238. .reduce {
  239. width: 18rpx;
  240. height: 4rpx;
  241. background-color: var(--view-theme);
  242. margin: 0 10rpx;
  243. }
  244. .card-cell ~ .card-cell {
  245. border-top: 1px solid #eee;
  246. }
  247. .rule-desc {
  248. margin-top: -16rpx;
  249. padding: 40rpx 24rpx 24rpx;
  250. white-space: pre-wrap;
  251. font-size: 20rpx;
  252. line-height: 28rpx;
  253. background: linear-gradient(180deg, #f7f7f7 0%, #ffffff 100%);
  254. border-radius: 0 0 16rpx 16rpx;
  255. color: #999;
  256. }
  257. .Regular {
  258. font-family: 'Regular';
  259. }
  260. </style>