index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view :style="viewColor">
  3. <view class='coupon-list-window animated' :class='coupon.status==true?"slideInUp":""'>
  4. <view class='title'>
  5. <view class="item">{{couponTitle}}<text class='iconfont icon-guanbi' @tap='close'></text></view>
  6. </view>
  7. <block v-if="couponArr.length">
  8. <view class='coupon-list'>
  9. <view class='item acea-row row-center-wrapper' :class="item.disabled ? 'disabled' : ''"
  10. v-for="(item,index) in couponArr" @click="getCouponUser(index,item)" :key='index'>
  11. <view v-if="item.coupon.send_type == 5" class='money acea-row row-column row-center-wrapper vip-coupon'>
  12. <view><text class='num'>{{item.coupon_price}}</text></view>
  13. <view class="pic-num">{{item.use_min_price}}元可用</view>
  14. </view>
  15. <view v-else class='money acea-row row-column row-center-wrapper' :style="{ 'background-image': `url(${domain}/static/diy/couponBg${keyColor}.png)` }">
  16. <view><text class='num'>{{item.coupon_price}}</text></view>
  17. <view class="pic-num">{{item.use_min_price}}元可用</view>
  18. </view>
  19. <view class='text'>
  20. <view class='condition line1'>
  21. <span class='line-title' v-if='item.coupon.type===0'>店铺券</span>
  22. <span class='line-title' v-else-if='item.coupon.type===1'>商品券</span>
  23. <span>{{item.coupon_title}}</span>
  24. </view>
  25. <view class='data acea-row row-between-wrapper'>
  26. <view>{{ item.start_time | timeYMD }} ~ {{ item.end_time | timeYMD}}</view>
  27. <view class="iconfont icon-weixuanzhong" v-if="!item.checked"></view>
  28. <view class='iconfont icon-xuanzhong1' v-else></view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="foot-box">
  34. <view class="left">
  35. 已选择{{coupon_number}}张,可优惠<text>{{coupon_amount}}</text>
  36. </view>
  37. </view>
  38. </block>
  39. <!-- 无优惠券 -->
  40. <view class='pictrue' v-else>
  41. <image :src="`${domain}/static/images/noCoupon.png`"></image>
  42. </view>
  43. </view>
  44. <view class='mask' catchtouchmove="true" :hidden='coupon.status==false' @click='close'></view>
  45. </view>
  46. </template>
  47. <script>
  48. // +----------------------------------------------------------------------
  49. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  50. // +----------------------------------------------------------------------
  51. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  52. // +----------------------------------------------------------------------
  53. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  54. // +----------------------------------------------------------------------
  55. // | Author: CRMEB Team <admin@crmeb.com>
  56. // +----------------------------------------------------------------------
  57. import { setCouponReceive } from '@/api/api.js';
  58. import { mapGetters } from "vuex";
  59. import { HTTP_REQUEST_URL } from '@/config/app';
  60. export default {
  61. props: {
  62. //打开状态 0=领取优惠券,1=使用优惠券
  63. openType: {
  64. type: Number,
  65. default: 0,
  66. },
  67. coupon: {
  68. type: Object,
  69. default: function() {
  70. return {};
  71. }
  72. },
  73. coupon_amount: {
  74. type: Number
  75. },
  76. coupon_number: {
  77. type: Number
  78. },
  79. couponTitle: {
  80. type: String,
  81. default: '优惠券',
  82. }
  83. },
  84. filters: {
  85. timeYMD: function(value) {
  86. if(value){
  87. var newDate=/\d{4}-(\d{1,2}\d{1,2}-\d{1,2}\d{1,2})/g.exec(value)
  88. return newDate?.[0]||''
  89. }
  90. }
  91. },
  92. computed: mapGetters(['viewColor','keyColor']),
  93. data() {
  94. return {
  95. domain: HTTP_REQUEST_URL,
  96. couponArr: [],
  97. couponData: {},
  98. // 选中的数据存放
  99. active: {},
  100. allNum: 0,
  101. allCouponNum: 0,
  102. // 选中店铺优惠券id
  103. use_store_coupon: 0,
  104. // 单个店铺总价
  105. pay_price: 0,
  106. // 商品有优惠订单
  107. goodsOrder: '',
  108. moneyBg: '/static/images/couponBg',
  109. };
  110. },
  111. watch: {
  112. coupon:{
  113. handler(nVal,oVal){
  114. this.couponArr = JSON.parse(JSON.stringify(nVal.coupon))
  115. },
  116. immediate: true,
  117. deep:true
  118. }
  119. },
  120. mounted() {
  121. this.couponData = this.coupon
  122. // 深拷贝数据 不影响原来数据使用
  123. this.couponArr = JSON.parse(JSON.stringify(this.coupon.coupon))
  124. // 深拷贝数据 不影响原来数据使用
  125. // this.goodsOrder = JSON.parse(JSON.stringify(this.coupon.order))
  126. let tempObj = this.active[this.couponData.mer_id] = {}
  127. tempObj.product = []
  128. tempObj.store = ''
  129. },
  130. methods: {
  131. close: function() {
  132. this.$emit('ChangCouponsClose');
  133. },
  134. // 使用优惠券
  135. getCouponUser: function(index, item) {
  136. this.$emit('getCoupon',item);
  137. }
  138. }
  139. }
  140. </script>
  141. <style scoped lang="scss">
  142. .animated {
  143. animation-duration: .3s
  144. }
  145. .title {
  146. display: flex;
  147. .item {
  148. position: relative;
  149. flex: 1;
  150. font-size: 28rpx;
  151. color: #999999;
  152. &::after {
  153. content: ' ';
  154. position: absolute;
  155. left: 50%;
  156. bottom: 18rpx;
  157. width: 50rpx;
  158. height: 5rpx;
  159. background: transparent;
  160. border-radius: 3px;
  161. transform: translateX(-50%);
  162. }
  163. &.on {
  164. color: #282828;
  165. &::after {
  166. background: var(--view-theme);
  167. }
  168. }
  169. }
  170. }
  171. .coupon-list {
  172. padding: 30rpx;
  173. .item {
  174. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.06);
  175. &.disabled{
  176. pointer-events:none;
  177. opacity: .6;
  178. .iconfont{
  179. background-color: #eee;
  180. border-radius: 100%;
  181. }
  182. }
  183. }
  184. }
  185. .coupon-list-window {
  186. position: fixed;
  187. bottom: 0;
  188. left: 0;
  189. width: 100%;
  190. background-color: #fff;
  191. border-radius: 16rpx 16rpx 0 0;
  192. z-index: 555;
  193. transform: translate3d(0, 100%, 0);
  194. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  195. }
  196. .coupon-list-window.on {
  197. animation: aminup;
  198. }
  199. .coupon-list-window .title {
  200. height: 106rpx;
  201. width: 100%;
  202. text-align: center;
  203. line-height: 106rpx;
  204. font-size: 32rpx;
  205. font-weight: bold;
  206. position: relative;
  207. }
  208. .coupon-list-window .title .iconfont {
  209. position: absolute;
  210. right: 30rpx;
  211. top: 50%;
  212. transform: translateY(-50%);
  213. font-size: 35rpx;
  214. color: #8a8a8a;
  215. font-weight: normal;
  216. }
  217. .coupon-list-window .coupon-list {
  218. margin: 0 0 0rpx 0;
  219. height: 550rpx;
  220. overflow: auto;
  221. }
  222. .coupon-list-window .pictrue {
  223. width: 414rpx;
  224. height: 336rpx;
  225. margin: 0 auto 50rpx auto;
  226. }
  227. .coupon-list-window .pictrue image {
  228. width: 100%;
  229. height: 100%;
  230. }
  231. .pic-num {
  232. color: #fff;
  233. font-size: 24rpx;
  234. }
  235. .line-title {
  236. width: 90rpx;
  237. padding: 0 10rpx;
  238. box-sizing: border-box;
  239. background: rgba(255, 247, 247, 1);
  240. border: 1px solid var(--view-theme);
  241. opacity: 1;
  242. border-radius: 20rpx;
  243. font-size: 20rpx;
  244. color: var(--view-theme);
  245. margin-right: 12rpx;
  246. }
  247. .line-title.gray {
  248. border-color: #BBB;
  249. color: #bbb;
  250. background-color: #F5F5F5;
  251. }
  252. .foot-box {
  253. display: flex;
  254. align-items: center;
  255. justify-content: space-between;
  256. height: 100rpx;
  257. padding: 0 30rpx;
  258. border-top: 1px solid #F5F5F5;
  259. .btn {
  260. width: 240rpx;
  261. height: 70rpx;
  262. line-height: 70rpx;
  263. text-align: center;
  264. background: var(--view-theme);;
  265. border-radius: 35rpx;
  266. color: #fff;
  267. font-size: 30rpx;
  268. }
  269. .left {
  270. text {
  271. color: var(--view-priceColor);
  272. }
  273. }
  274. }
  275. .coupon-list .item .text .data .iconfont {
  276. font-size: 36rpx;
  277. &.icon-weixuanzhong {
  278. color: #BFBFBF;
  279. }
  280. &.icon-xuanzhong1 {
  281. color: var(--view-theme);;
  282. }
  283. }
  284. </style>