index.vue 7.1 KB

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