index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <view>
  3. <view class='coupon-list-window' :class='coupon.coupon==true?"on":""'>
  4. <view v-if="coupon.count" class="nav acea-row row-around">
  5. <view v-if="coupon.count[2]" :class="['acea-row', 'row-middle', coupon.type === 2 ? 'on' : '']"
  6. @click="setType(2)">{{$t(`商品券`)}}</view>
  7. <view v-if="coupon.count[1]" :class="['acea-row', 'row-middle', coupon.type === 1 ? 'on' : '']"
  8. @click="setType(1)">{{$t(`品类券`)}}</view>
  9. <view v-if="coupon.count[0]" :class="['acea-row', 'row-middle', coupon.type === 0 ? 'on' : '']"
  10. @click="setType(0)">{{$t(`通用券`)}}</view>
  11. </view>
  12. <view class='title' v-else>{{$t(`优惠券`)}}<text class='iconfont icon-guanbi' @click='close'></text></view>
  13. <view v-if="coupon.count" class="occupy"></view>
  14. <view class='coupon-list' v-if="coupon.list.length">
  15. <view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list"
  16. @click="getCouponUser(index,item.id)" :key='index' :class="{svip: item.receive_type === 4}">
  17. <view class="moneyCon acea-row row-center-wrapper">
  18. <view class='money acea-row row-column row-center-wrapper'
  19. :class='item.is_use >= item.receive_limit && coupon.count?"moneyGray":""'>
  20. <view>{{$t(`¥`)}}<text class='num'>{{item.coupon_price}}</text></view>
  21. <view class="pic-num" v-if="item.use_min_price > 0">
  22. {{$t(`满`)}}{{item.use_min_price}}{{$t(`元可用`)}}</view>
  23. <view class="pic-num" v-else>{{$t(`无门槛券`)}}</view>
  24. </view>
  25. </view>
  26. <view class='text'>
  27. <view class='condition line2' :class="coupon.count?'':'order'">
  28. <span class='line-title' :class='item.is_use >= item.receive_limit && coupon.count?"gray":""'
  29. v-if='item.type===0'>{{$t(`通用券`)}}</span>
  30. <span class='line-title' :class='item.is_use >= item.receive_limit && coupon.count?"gray":""'
  31. v-else-if='item.type===1'>{{$t(`品类券`)}}</span>
  32. <span class='line-title' :class='item.is_use >= item.receive_limit && coupon.count?"gray":""'
  33. v-else>{{$t(`商品券`)}}</span>
  34. <image src='../../static/images/fvip.png' class="pic" v-if="item.receive_type===4"></image>
  35. <span class='name'>{{$t(item.title)}}</span>
  36. </view>
  37. <view class='data acea-row row-between-wrapper'>
  38. <view v-if="item.coupon_time">{{$t(`领取后`)}}{{item.coupon_time}}{{$t(`天内可用`)}}</view>
  39. <view v-else>{{ item.start_use_time ? item.start_use_time + "-" : ""}}{{ item.end_use_time }}</view>
  40. <view v-if="coupon.count">
  41. <view class='bnt gray' v-if="item.is_use >= item.receive_limit">
  42. {{item.use_title || $t(`已领取`)}}</view>
  43. <view class='bnt bg-color' v-else>{{coupon.statusTile || $t(`立即领取`)}}</view>
  44. </view>
  45. <view v-else class="orderCou">
  46. <view class="iconfont icon-xuanzhong11"
  47. :class="item.receive_type === 4?'svip':'font-num'" v-if="item.is_use"></view>
  48. <view class="iconfont icon-weixuan" v-else></view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 无优惠券 -->
  55. <view class='pictrue' v-else>
  56. <image :src="imgHost + '/statics/images/noCoupon.png'"></image>
  57. </view>
  58. </view>
  59. <view class='mask' catchtouchmove="true" :hidden='coupon.coupon==false' @click='close'></view>
  60. </view>
  61. </template>
  62. <script>
  63. import {
  64. setCouponReceive
  65. } from '@/api/api.js';
  66. import {
  67. HTTP_REQUEST_URL
  68. } from '@/config/app';
  69. export default {
  70. props: {
  71. //打开状态 0=领取优惠券,1=使用优惠券
  72. openType: {
  73. type: Number,
  74. default: 0,
  75. },
  76. coupon: {
  77. type: Object,
  78. default: function() {
  79. return {};
  80. }
  81. }
  82. },
  83. data() {
  84. return {
  85. imgHost: HTTP_REQUEST_URL,
  86. type: 0
  87. };
  88. },
  89. methods: {
  90. close: function() {
  91. this.$emit('ChangCouponsClone');
  92. this.type = 0;
  93. },
  94. getCouponUser: function(index, id) {
  95. let that = this;
  96. let list = that.coupon.list;
  97. if (list[index].is_use >= list[index].receive_limit && this.openType == 0) return true;
  98. switch (this.openType) {
  99. case 0:
  100. //领取优惠券
  101. setCouponReceive(id).then(res => {
  102. that.$emit('ChangCouponsUseState', index);
  103. that.$util.Tips({
  104. title: "领取成功"
  105. });
  106. // that.$emit('ChangCoupons', list[index]);
  107. }).catch(err => {
  108. uni.showToast({
  109. title: err,
  110. icon: 'none'
  111. });
  112. })
  113. break;
  114. case 1:
  115. that.$emit('ChangCoupons', index);
  116. break;
  117. }
  118. },
  119. setType: function(type) {
  120. this.type = type;
  121. this.$emit('tabCouponType', type);
  122. }
  123. }
  124. }
  125. </script>
  126. <style scoped lang="scss">
  127. .orderCou {
  128. position: absolute;
  129. right: 20rpx;
  130. top: 50%;
  131. margin-top: -20rpx;
  132. }
  133. .orderCou .iconfont {
  134. font-size: 40rpx;
  135. }
  136. .orderCou .svip {
  137. color: #EDBB75;
  138. }
  139. .coupon-list .item .text {
  140. position: relative;
  141. }
  142. .coupon-list .item .text .condition.order {
  143. width: 350rpx;
  144. }
  145. .coupon-list-window .coupon-list .text .condition .pic {
  146. width: 30rpx;
  147. height: 30rpx;
  148. margin-right: 10rpx;
  149. vertical-align: middle;
  150. }
  151. .coupon-list-window .coupon-list .text .condition .name {
  152. vertical-align: middle;
  153. font-size: 26rpx;
  154. font-weight: 500;
  155. }
  156. .coupon-list-window {
  157. position: fixed;
  158. bottom: 0;
  159. left: 0;
  160. width: 100%;
  161. background-color: #FFFFFF;
  162. border-radius: 16rpx 16rpx 0 0;
  163. z-index: 999;
  164. transform: translate3d(0, 100%, 0);
  165. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  166. }
  167. .coupon-list-window.on {
  168. transform: translate3d(0, 0, 0);
  169. }
  170. .coupon-list-window .title {
  171. height: 124rpx;
  172. width: 100%;
  173. text-align: center;
  174. line-height: 124rpx;
  175. font-size: 32rpx;
  176. font-weight: bold;
  177. position: relative;
  178. }
  179. .coupon-list-window .title .iconfont {
  180. position: absolute;
  181. right: 30rpx;
  182. top: 50%;
  183. transform: translateY(-50%);
  184. font-size: 35rpx;
  185. color: #8a8a8a;
  186. font-weight: normal;
  187. }
  188. .coupon-list-window .coupon-list {
  189. margin: 0 0 50rpx 0;
  190. height: 721rpx;
  191. padding-top: 28rpx;
  192. overflow: auto;
  193. }
  194. .coupon-list-window .pictrue {
  195. width: 414rpx;
  196. height: 336rpx;
  197. margin: 192rpx auto 243rpx 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 {
  208. width: 70rpx;
  209. height: 32rpx !important;
  210. padding: 0 10rpx;
  211. line-height: 30rpx;
  212. text-align: center;
  213. background: var(--view-minorColorT);
  214. border: 1px solid var(--view-theme);
  215. opacity: 1;
  216. border-radius: 20rpx;
  217. font-size: 18rpx;
  218. color: var(--view-theme);
  219. margin-right: 12rpx;
  220. box-sizing: border-box;
  221. }
  222. .line-title.gray {
  223. border-color: #C1C1C1 !important;
  224. color: #C1C1C1 !important;
  225. background-color: #F7F7F7 !important;
  226. }
  227. .nav {
  228. position: absolute;
  229. top: 0;
  230. left: 0;
  231. width: 100%;
  232. height: 106rpx;
  233. border-bottom: 2rpx solid #F5F5F5;
  234. border-top-left-radius: 16rpx;
  235. border-top-right-radius: 16rpx;
  236. background-color: #FFFFFF;
  237. font-size: 30rpx;
  238. color: #999999;
  239. }
  240. .nav .acea-row {
  241. border-top: 5rpx solid transparent;
  242. border-bottom: 5rpx solid transparent;
  243. }
  244. .nav .acea-row.on {
  245. border-bottom-color: var(--view-theme);
  246. color: #282828;
  247. }
  248. .nav .acea-row:only-child {
  249. border-bottom-color: transparent;
  250. }
  251. .occupy {
  252. height: 106rpx;
  253. }
  254. .coupon-list .item {
  255. margin-bottom: 18rpx;
  256. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
  257. }
  258. .coupon-list .item .money {
  259. font-weight: normal;
  260. }
  261. </style>