couponselect.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view class="pages">
  3. <u-navbar
  4. title="选择优惠券"
  5. :placeholder="true"
  6. :autoBack="false"
  7. @leftClick="leftClick"
  8. :safeAreaInsetTop="true"
  9. >
  10. </u-navbar>
  11. <view class="page-wrap">
  12. <view class="coupon-list" v-if="dataList.length>0">
  13. <view class="item"
  14. :class="{disable:item.status==2}"
  15. :style="{backgroundImage:`url(${staticUrl}/img/coupon-active-bg-v2.png)`,filter:item.status!=1?'grayscale(100%)':''}" v-for="item in dataList" :key="item.id">
  16. <view class="content u-flex">
  17. <view class="left">
  18. <view class="quota">
  19. <text v-if="item.type == 1">¥</text>
  20. <text class="number" :class="{'small': String(item.quota).length>=3}">{{item.type==1?item.quota:item.quota/10}}</text>
  21. <text v-if="item.type == 2">折</text>
  22. </view>
  23. <view class="condition" v-if="item.useThresholdType == 2">
  24. 消费满{{item.useThresholdAmount}}可用
  25. </view>
  26. </view>
  27. <view class="center">
  28. <view class="name" :class="{'small': String(item.couponName).length>=9}">{{item.couponName}}</view>
  29. <view class="condition" v-if="item.useThresholdType == 2">
  30. 消费满{{item.useThresholdAmount}}可用
  31. </view>
  32. <!-- <view class="tip">
  33. 有效期至 {{item.endTime||''}}
  34. </view> -->
  35. </view>
  36. <view class="right">
  37. <text class="btn" @click="couponClick(item)">去使用</text>
  38. <!-- <view class="time">
  39. <view class="">{{item.startTime}}</view>
  40. <view class="">{{item.endTime}}</view>
  41. </view> -->
  42. </view>
  43. </view>
  44. <view class="bottom-time">
  45. 有效期 {{item.startTime||''}} - {{item.endTime||''}}
  46. </view>
  47. <view class="type" v-if="item.type == 1">满减券</view>
  48. <view class="type" v-else-if="item.type == 2">折扣卷</view>
  49. <image class="status-img" :src="staticUrl+'/img/coupon-status-shiyong.png'" v-if="item.status == 2"></image>
  50. <image class="status-img" :src="staticUrl+'/img/coupon-status-guoqi.png'" v-if="item.status == 3"></image>
  51. <image class="status-img" :src="staticUrl+'/img/coupon-status-guoqi.png'" v-if="item.status == 4"></image>
  52. </view>
  53. </view>
  54. <u-empty mode="list" text="暂无可用优惠券" v-else></u-empty>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. export default{
  60. name:'',
  61. components:{
  62. },
  63. props:{
  64. },
  65. data(){
  66. return{
  67. staticUrl:this.$commonConfig.staticUrl,
  68. param:{
  69. salePrice:undefined,
  70. performId:undefined,
  71. goodsId:[]
  72. },
  73. dataList:[],
  74. }
  75. },
  76. onLoad(page){
  77. console.log('page',page);
  78. this.param.salePrice = page.salePrice;
  79. this.param.performId = page.performId;
  80. this.param.goodsId = page.goodsId;
  81. },
  82. onShow() {
  83. this.findOrderCoupons()
  84. },
  85. methods:{
  86. leftClick(e){
  87. let pages = getCurrentPages();
  88. if(pages.length==1){
  89. uni.$u.route('/pages/index/index')
  90. }else{
  91. // uni.$u.route('/scenic/bookticket',{performId:this.performId})
  92. uni.navigateBack()
  93. };
  94. },
  95. findOrderCoupons(){
  96. this.$u.api.findOrderCoupons(this.param).then(res=>{
  97. this.dataList = res.data.list;
  98. }).catch(err=>{
  99. // console.log('findOrderCoupons',err.data);
  100. })
  101. },
  102. couponClick(item){
  103. let allPages = getCurrentPages(); //获取当前页面栈的实例;
  104. console.log('allPages',allPages);
  105. let prePages = allPages[allPages.length - 2].route;
  106. console.log('prePages',prePages);
  107. if(prePages=='pages/bookticket'){
  108. this.$u.vuex('coupon', item);
  109. uni.navigateBack();
  110. }else{
  111. uni.$u.route('/pages/index/index');
  112. }
  113. }
  114. }
  115. }
  116. </script>
  117. <style>
  118. page{
  119. background-color: #f5f5f5;
  120. }
  121. </style>
  122. <style lang="scss" scoped>
  123. </style>