index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view>
  3. <view class='coupon-list-window' :class='coupon.coupon==true?"on":""'>
  4. <view v-if="!orderShow" class="nav acea-row row-around">
  5. <view :class="['acea-row', 'row-middle', type === 1 ? 'on' : '']" @click="setType(1)">通用券</view>
  6. <view :class="['acea-row', 'row-middle', type === 2 ? 'on' : '']" @click="setType(2)">商品券</view>
  7. <view :class="['acea-row', 'row-middle', type === 3 ? 'on' : '']" @click="setType(3)">品类券</view>
  8. </view>
  9. <!-- <view class="occupy" v-if="!orderShow"></view> -->
  10. <!-- <view class='title'>优惠券<text class='iconfont icon-guanbi' @click='close'></text></view> -->
  11. <view class='coupon-list' :style="{'margin-top':!orderShow?'0':'50rpx'}">
  12. <block v-if="coupon.list.length">
  13. <!-- <view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list" :key='index'> -->
  14. <view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list"
  15. @click="getCouponUser(index,item.id)" :key='index'>
  16. <view class='money acea-row row-column row-center-wrapper' :class='item.isUse?"moneyGray":""'>
  17. <view>¥<text class='num'>{{item.money?Number(item.money):''}}</text></view>
  18. <view class="pic-num">满{{item.minPrice}}元可用</view>
  19. </view>
  20. <view class='text'>
  21. <view class='condition line2'>
  22. <span class='line-title' :class='item.isUse?"gray":""' v-if='item.useType===1'>通用</span>
  23. <span class='line-title' :class='item.isUse?"gray":""'
  24. v-else-if='item.useType===3'>品类</span>
  25. <span class='line-title' :class='item.isUse?"gray":""' v-else>商品</span>
  26. <span>{{item.name}}</span>
  27. </view>
  28. <view class='data acea-row row-between-wrapper'>
  29. <view v-if="item.day>0">领取后{{item.day}}天内可用</view>
  30. <view v-else>
  31. {{ item.useStartTimeStr&& item.useEndTimeStr ? item.useStartTimeStr + " - " + item.useEndTimeStr : ""}}
  32. </view>
  33. <view class='bnt gray' v-if="item.isUse">{{item.use_title || '已领取'}}</view>
  34. <view class='bnt bg-color' v-else>{{coupon.statusTile || '立即领取'}}</view>
  35. </view>
  36. </view>
  37. </view>
  38. </block>
  39. <!-- 无优惠券 -->
  40. <view class='pictrue' v-else>
  41. <image src='../../static/images/noCoupon.png'></image>
  42. </view>
  43. </view>
  44. </view>
  45. <view class='mask' catchtouchmove="true" :hidden='coupon.coupon==false' @click='close'></view>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. setCouponReceive
  51. } from '@/api/api.js';
  52. export default {
  53. props: {
  54. //打开状态 0=领取优惠券,1=使用优惠券
  55. openType: {
  56. type: Number,
  57. default: 0,
  58. },
  59. coupon: {
  60. type: Object,
  61. default: function() {
  62. return {};
  63. }
  64. },
  65. //下单页面使用优惠券组件不展示tab切换页
  66. orderShow: {
  67. type: String,
  68. default: function() {
  69. return '';
  70. }
  71. }
  72. },
  73. data() {
  74. return {
  75. type: 1
  76. };
  77. },
  78. methods: {
  79. close: function() {
  80. this.type = 1
  81. this.$emit('ChangCouponsClone');
  82. },
  83. getCouponUser: function(index, id) {
  84. let that = this;
  85. let list = that.coupon.list;
  86. if (list[index].isUse == true && this.openType == 0) return true;
  87. switch (this.openType) {
  88. case 0:
  89. //领取优惠券
  90. let ids = [];
  91. ids.push(id);
  92. setCouponReceive(id).then(res => {
  93. that.$emit('ChangCouponsUseState', index);
  94. that.$util.Tips({
  95. title: "领取成功"
  96. });
  97. that.$emit('ChangCoupons', list[index]);
  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. .coupon-list-window {
  114. position: fixed;
  115. bottom: 0;
  116. left: 0;
  117. width: 100%;
  118. background-color: #f5f5f5;
  119. border-radius: 16rpx 16rpx 0 0;
  120. z-index: 555;
  121. transform: translate3d(0, 100%, 0);
  122. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  123. }
  124. .coupon-list-window.on {
  125. transform: translate3d(0, 0, 0);
  126. }
  127. .coupon-list-window .title {
  128. height: 124rpx;
  129. width: 100%;
  130. text-align: center;
  131. line-height: 124rpx;
  132. font-size: 32rpx;
  133. font-weight: bold;
  134. position: relative;
  135. }
  136. .coupon-list-window .title .iconfont {
  137. position: absolute;
  138. right: 30rpx;
  139. top: 50%;
  140. transform: translateY(-50%);
  141. font-size: 35rpx;
  142. color: #8a8a8a;
  143. font-weight: normal;
  144. }
  145. .coupon-list-window .coupon-list {
  146. margin: 0 0 30rpx 0;
  147. height: 823rpx;
  148. overflow: auto;
  149. padding-top: 30rpx;
  150. }
  151. .coupon-list-window .pictrue {
  152. width: 414rpx;
  153. height: 336rpx;
  154. margin: 208rpx auto;
  155. }
  156. .coupon-list-window .pictrue image {
  157. width: 100%;
  158. height: 100%;
  159. }
  160. .pic-num {
  161. color: #fff;
  162. font-size: 24rpx;
  163. }
  164. .line-title {
  165. width: 90rpx;
  166. padding: 0 10rpx;
  167. box-sizing: border-box;
  168. background: rgba(255, 247, 247, 1);
  169. border: 1px solid rgba(232, 51, 35, 1);
  170. opacity: 1;
  171. border-radius: 20rpx;
  172. font-size: 20rpx;
  173. color: #E83323;
  174. margin-right: 12rpx;
  175. }
  176. .line-title.gray {
  177. border-color: #BBB;
  178. color: #bbb;
  179. background-color: #F5F5F5;
  180. }
  181. .nav {
  182. // position: absolute;
  183. // top: 0;
  184. // left: 0;
  185. width: 100%;
  186. height: 96rpx;
  187. border-bottom: 2rpx solid #F5F5F5;
  188. border-top-left-radius: 16rpx;
  189. border-top-right-radius: 16rpx;
  190. background-color: #FFFFFF;
  191. font-size: 30rpx;
  192. color: #999999;
  193. }
  194. .nav .acea-row {
  195. border-top: 5rpx solid transparent;
  196. border-bottom: 5rpx solid transparent;
  197. }
  198. .nav .acea-row.on {
  199. border-bottom-color: #E93323;
  200. color: #282828;
  201. }
  202. .nav .acea-row:only-child {
  203. border-bottom-color: transparent;
  204. }
  205. .occupy {
  206. height: 106rpx;
  207. }
  208. .coupon-list .item {
  209. margin-bottom: 20rpx;
  210. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
  211. }
  212. .coupon-list .item .money {
  213. font-weight: normal;
  214. }
  215. </style>