index.vue 6.3 KB

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