index.vue 7.2 KB

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