index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view>
  3. <view class='coupon-list-window' :class='coupon.coupon==true?"on":""'>
  4. <view class="bottom_close" @click="close" style="top: auto"><view class="iconfont icon-ic_close f-s-24"></view></view>
  5. <!-- <text class="iconfont icon-guanbi5" @click="close"></text>-->
  6. <view class="_tit text-center">领取优惠券</view>
  7. <view class='coupon-list borderPad' :style="{'margin-top':!orderShow?'0':'0'}">
  8. <block v-if="coupon.list.length">
  9. <view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list"
  10. @click="getCouponUser(index,item.id)" :key='index'>
  11. <view class='money acea-row row-column row-center-wrapper main_bg'>
  12. <view>¥<text class='num'>{{item.money?Number(item.money):''}}</text></view>
  13. <view class="pic-num">满{{item.minPrice}}{{$store.getters.priceUnit}}可用</view>
  14. </view>
  15. <view class='text'>
  16. <view class='acea-row condition'>
  17. <span v-if='item.merId===0' class='line-title select'>平台</span>
  18. <span v-else class='line-title select'>店铺</span>
  19. <span class="line2">{{item.name}}</span>
  20. </view>
  21. <view class='data acea-row row-between-wrapper'>
  22. <view class="width">
  23. <view v-if="item.isFixedTime" class="_end">
  24. {{ $util.getTime(item.useStartTimeStr) + ' - ' + $util.getTime(item.useEndTimeStr) + ' 可用' }}
  25. </view>
  26. <view v-else class="_end">{{ '领取后' + item.day + '天内可用' }}</view>
  27. </view>
  28. <view class='bnt main_bg' v-if="!item.isUse">{{coupon.statusTile || '立即领取'}}</view>
  29. </view>
  30. <span v-if="item.isUse" class="iconfont icon-ic_yilingqu font-color"></span>
  31. </view>
  32. </view>
  33. </block>
  34. <!-- 无优惠券 -->
  35. <view class='pictrue' v-else>
  36. <image :src="urlDomain+'crmebimage/presets/noCoupon.png'"></image>
  37. <view class="default_txt">暂无优惠券哦~</view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class='mask' catchtouchmove="true" :hidden='coupon.coupon==false' @click='close'></view>
  42. </view>
  43. </template>
  44. <script>
  45. // +----------------------------------------------------------------------
  46. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  47. // +----------------------------------------------------------------------
  48. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  49. // +----------------------------------------------------------------------
  50. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  51. // +----------------------------------------------------------------------
  52. // | Author: CRMEB Team <admin@crmeb.com>
  53. // +----------------------------------------------------------------------
  54. import {
  55. setCouponReceive
  56. } from '@/api/api.js';
  57. export default {
  58. props: {
  59. //打开状态 0=领取优惠券,1=使用优惠券
  60. openType: {
  61. type: Number,
  62. default: 0,
  63. },
  64. coupon: {
  65. type: Object,
  66. default: function() {
  67. return {};
  68. }
  69. },
  70. //下单页面使用优惠券组件不展示tab切换页
  71. orderShow: {
  72. type: String,
  73. default: function() {
  74. return '';
  75. }
  76. },
  77. typeNum: {
  78. type: Number,
  79. default: 0
  80. }
  81. },
  82. data() {
  83. return {
  84. type: 1,
  85. urlDomain: this.$Cache.get("imgHost")
  86. };
  87. },
  88. watch: {
  89. 'coupon.type': function(val) { //监听props中的属性
  90. this.type = val;
  91. }
  92. },
  93. methods: {
  94. close: function() {
  95. this.type = this.typeNum;
  96. this.$emit('ChangCouponsClone');
  97. },
  98. getCouponUser: function(index, id) {
  99. let that = this;
  100. let list = that.coupon.list;
  101. if (list[index].isUse == true && this.openType == 0) return true;
  102. switch (this.openType) {
  103. case 0:
  104. //领取优惠券
  105. let ids = [];
  106. ids.push(id);
  107. setCouponReceive(id).then(res => {
  108. that.$emit('ChangCouponsUseState', index);
  109. that.$util.Tips({
  110. title: "领取成功"
  111. }, function(res) {
  112. return that.$util.Tips({
  113. title: res
  114. });
  115. });
  116. that.$emit('ChangCoupons', list[index]);
  117. })
  118. break;
  119. case 1:
  120. that.$emit('ChangCoupons', index);
  121. break;
  122. }
  123. },
  124. setType: function(type) {
  125. this.$emit('tabCouponType', type);
  126. this.type = type;
  127. }
  128. }
  129. }
  130. </script>
  131. <style scoped lang="scss">
  132. .icon-ic_yilingqu {
  133. position: absolute;
  134. opacity: 0.1;
  135. font-size: 160rpx;
  136. top: 50rpx;
  137. right: -20rpx;
  138. }
  139. ._tit {
  140. font-size: 32rpx;
  141. font-weight: 600;
  142. color: #282828;
  143. margin-bottom: 43rpx;
  144. }
  145. .icon-guanbi5 {
  146. position: absolute;
  147. font-size: 28rpx;
  148. color: #aaa;
  149. top: 30rpx;
  150. right: 30rpx;
  151. z-index: 1;
  152. }
  153. .coupon-list-window {
  154. padding-top: 46rpx;
  155. position: fixed;
  156. bottom: 0;
  157. left: 0;
  158. width: 100%;
  159. background-color: #f5f5f5;
  160. border-radius: 40rpx 40rpx 0 0;
  161. z-index: 555;
  162. transform: translate3d(0, 100%, 0);
  163. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  164. }
  165. .coupon-list-window.on {
  166. transform: translate3d(0, 0, 0);
  167. }
  168. .coupon-list-window .title {
  169. height: 124rpx;
  170. width: 100%;
  171. text-align: center;
  172. line-height: 124rpx;
  173. font-size: 32rpx;
  174. font-weight: bold;
  175. position: relative;
  176. }
  177. .coupon-list-window .title .iconfont {
  178. position: absolute;
  179. right: 30rpx;
  180. top: 50%;
  181. transform: translateY(-50%);
  182. font-size: 35rpx;
  183. color: #8a8a8a;
  184. font-weight: normal;
  185. }
  186. .coupon-list-window .coupon-list {
  187. margin: 0 0 30rpx 0;
  188. height: 823rpx;
  189. overflow: auto;
  190. .text {
  191. position: relative;
  192. overflow: hidden;
  193. }
  194. }
  195. .coupon-list-window .pictrue {
  196. width: 414rpx;
  197. height: 336rpx;
  198. margin: 208rpx auto;
  199. }
  200. .coupon-list-window .pictrue image {
  201. width: 100%;
  202. height: 100%;
  203. }
  204. .pic-num {
  205. color: #fff;
  206. font-size: 24rpx;
  207. }
  208. .line-title.gray {
  209. border-color: #BBB;
  210. color: #bbb;
  211. background-color: #F5F5F5;
  212. }
  213. .nav {
  214. width: 100%;
  215. height: 96rpx;
  216. border-bottom: 2rpx solid #F5F5F5;
  217. border-top-left-radius: 16rpx;
  218. border-top-right-radius: 16rpx;
  219. background-color: #FFFFFF;
  220. font-size: 30rpx;
  221. color: #999999;
  222. }
  223. .nav .acea-row {
  224. border-top: 5rpx solid transparent;
  225. border-bottom: 5rpx solid transparent;
  226. }
  227. .nav .acea-row.on {
  228. @include tab_border_bottom(theme);
  229. color: #282828;
  230. }
  231. .nav .acea-row:only-child {
  232. border-bottom-color: transparent;
  233. }
  234. .coupon-list .item {
  235. margin-bottom: 20rpx;
  236. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
  237. }
  238. .coupon-list .item .money {
  239. font-weight: normal;
  240. }
  241. .select {
  242. @include main_color(theme);
  243. @include coupons_border_color(theme);
  244. }
  245. .default_txt {
  246. font-size: 26rpx;
  247. color: #999;
  248. text-align: center;
  249. }
  250. </style>