index.vue 6.8 KB

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