index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <view>
  3. <view class='coupon-list-window animated' :class='coupon.coupon==true?"slideInUp":""'>
  4. <view class='title'>
  5. <view class="item" :class="{'on':tabIndex == index}" v-for="(item,index) in tabList" :key="index" @click="bindTab(item,index)">{{item}}</view>
  6. </view>
  7. <view class='coupon-list' v-if="couponArr.length">
  8. <view class='item acea-row row-center-wrapper' v-for="(item,index) in couponArr" @click="getCouponUser(index,item)"
  9. :key='index'>
  10. <view class='money acea-row row-column row-center-wrapper' :class='item.issue?"moneyGray":""'>
  11. <view>¥<text class='num'>{{item.coupon_price}}</text></view>
  12. <view class="pic-num">满{{item.use_min_price}}元可用</view>
  13. </view>
  14. <view class='text'>
  15. <view class='condition line1'>
  16. <span class='line-title' :class='item.issue ? "gray":""' v-if='item.type===0'>店铺券</span>
  17. <span class='line-title' :class='item.issue ? "gray":""' v-else-if='item.type===1'>商品券</span>
  18. <span>{{item.title}}</span>
  19. </view>
  20. <view class='data acea-row row-between-wrapper'>
  21. <block v-if="item.coupon_type == 1">
  22. <view>{{ item.use_start_time |timeYMD }}-{{ item.use_end_time |timeYMD}}</view>
  23. </block>
  24. <block v-if="item.coupon_type == 0">
  25. <view>领取后{{ item.coupon_time}}天内可用</view>
  26. </block>
  27. <view class='bnt gray' v-if="item.issue">{{item.use_title || '已领取'}}</view>
  28. <view class='bnt bg-color' v-else>{{coupon.statusTile || '立即领取'}}</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 无优惠券 -->
  34. <view class='pictrue' v-else>
  35. <image src='../../static/images/noCoupon.png'></image>
  36. </view>
  37. </view>
  38. <view class='mask' catchtouchmove="true" :hidden='coupon.coupon==false' @click='close'></view>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. setCouponReceive
  44. } from '@/api/api.js';
  45. export default {
  46. props: {
  47. //打开状态 0=领取优惠券,1=使用优惠券
  48. openType: {
  49. type: Number,
  50. default: 0,
  51. },
  52. coupon: {
  53. type: Object,
  54. default: function() {
  55. return {};
  56. }
  57. }
  58. },
  59. filters: {
  60. timeYMD: function (value) {
  61. if(value){
  62. var newDate=/\d{4}-\d{1,2}-\d{1,2}/g.exec(value)
  63. return newDate[0]
  64. }
  65. }
  66. },
  67. data() {
  68. return {
  69. tabList:['商品券','店铺券'],
  70. tabIndex:0,
  71. couponArr:[]
  72. };
  73. },
  74. mounted() {
  75. this.$nextTick(function(){
  76. this.couponArr = this.coupon.list
  77. this.filterArray();
  78. })
  79. },
  80. methods: {
  81. close: function() {
  82. this.$emit('ChangCouponsClone');
  83. },
  84. getCouponUser: function(index, item) {
  85. let that = this;
  86. let list = this.couponArr;
  87. if (list[index].issue) return true;
  88. switch (this.openType) {
  89. case 0:
  90. //领取优惠券
  91. setCouponReceive(item.coupon_id).then(res => {
  92. item.issue = true
  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. // 过滤优惠券
  106. filterArray(){
  107. if(this.tabIndex == 0){
  108. this.couponArr = this.coupon.list.filter(item=>{
  109. return item.type == 1
  110. })
  111. }else{
  112. this.couponArr = this.coupon.list.filter(item=>{
  113. return item.type == 0
  114. })
  115. }
  116. },
  117. bindTab(item,index){
  118. this.tabIndex = index
  119. this.filterArray()
  120. }
  121. }
  122. }
  123. </script>
  124. <style scoped lang="scss">
  125. .animated{
  126. animation-duration:.3s
  127. }
  128. .title{
  129. display: flex;
  130. .item{
  131. position: relative;
  132. flex: 1;
  133. font-size: 28rpx;
  134. color: #999999;
  135. &::after{
  136. content: ' ';
  137. position: absolute;
  138. left: 50%;
  139. bottom: 18rpx;
  140. width:50rpx;
  141. height:5rpx;
  142. background:transparent;
  143. border-radius:3px;
  144. transform: translateX(-50%);
  145. }
  146. &.on{
  147. color: #282828;
  148. &::after{
  149. background:$theme-color;
  150. }
  151. }
  152. }
  153. }
  154. .coupon-list{
  155. padding: 30rpx;
  156. .item{
  157. box-shadow:0px 2px 10px 0px rgba(0, 0, 0, 0.06);
  158. }
  159. }
  160. .coupon-list-window {
  161. position: fixed;
  162. bottom: 0;
  163. left: 0;
  164. width: 100%;
  165. background-color: #fff;
  166. border-radius: 16rpx 16rpx 0 0;
  167. z-index: 555;
  168. transform: translate3d(0, 100%, 0);
  169. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  170. }
  171. .coupon-list-window.on {
  172. // transform: translate3d(0, 0, 0);
  173. animation: aminup ;
  174. }
  175. .coupon-list-window .title {
  176. height: 106rpx;
  177. width: 100%;
  178. text-align: center;
  179. line-height: 106rpx;
  180. font-size: 32rpx;
  181. font-weight: bold;
  182. position: relative;
  183. border: 1px solid #f5f5f5;
  184. }
  185. .coupon-list-window .title .iconfont {
  186. position: absolute;
  187. right: 30rpx;
  188. top: 50%;
  189. transform: translateY(-50%);
  190. font-size: 35rpx;
  191. color: #8a8a8a;
  192. font-weight: normal;
  193. }
  194. .coupon-list-window .coupon-list {
  195. margin: 0 0 50rpx 0;
  196. height: 550rpx;
  197. overflow: auto;
  198. }
  199. .coupon-list-window .pictrue {
  200. width: 414rpx;
  201. height: 336rpx;
  202. margin: 0 auto 50rpx auto;
  203. }
  204. .coupon-list-window .pictrue image {
  205. width: 100%;
  206. height: 100%;
  207. }
  208. .pic-num {
  209. color: #fff;
  210. font-size: 24rpx;
  211. }
  212. .line-title {
  213. width: 90rpx;
  214. padding: 0 10rpx;
  215. box-sizing: border-box;
  216. background: rgba(255, 247, 247, 1);
  217. border: 1px solid rgba(232, 51, 35, 1);
  218. opacity: 1;
  219. border-radius: 20rpx;
  220. font-size: 20rpx;
  221. color: #E83323;
  222. margin-right: 12rpx;
  223. }
  224. .line-title.gray {
  225. border-color: #BBB;
  226. color: #bbb;
  227. background-color: #F5F5F5;
  228. }
  229. </style>