index.vue 6.7 KB

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