couponselect.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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.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.quota}}</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="tip">
  30. 有效期至 {{item.endTime||''}}
  31. </view>
  32. </view>
  33. <view class="right">
  34. <text class="btn" @click="couponClick(item)">去使用</text>
  35. <!-- <view class="time">
  36. <view class="">{{item.startTime}}</view>
  37. <view class="">{{item.endTime}}</view>
  38. </view> -->
  39. </view>
  40. </view>
  41. <view class="type" v-if="item.type == 1">满减券</view>
  42. <view class="type" v-else-if="item.type == 2">折扣卷</view>
  43. <image class="status-img" :src="staticUrl+'/img/coupon-status-shiyong.png'" v-if="item.status == 2"></image>
  44. <image class="status-img" :src="staticUrl+'/img/coupon-status-guoqi.png'" v-if="item.status == 3"></image>
  45. <image class="status-img" :src="staticUrl+'/img/coupon-status-guoqi.png'" v-if="item.status == 4"></image>
  46. </view>
  47. </view>
  48. <u-empty mode="list" text="暂无可用优惠券" v-else></u-empty>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default{
  54. name:'',
  55. components:{
  56. },
  57. props:{
  58. },
  59. data(){
  60. return{
  61. staticUrl:this.$commonConfig.staticUrl,
  62. param:{
  63. salePrice:undefined,
  64. performId:undefined,
  65. goodsId:[]
  66. },
  67. dataList:[],
  68. }
  69. },
  70. onLoad(page){
  71. console.log('page',page);
  72. this.param.salePrice = page.salePrice;
  73. this.param.performId = page.performId;
  74. this.param.goodsId = page.goodsId;
  75. },
  76. onShow() {
  77. this.findOrderCoupons()
  78. },
  79. methods:{
  80. leftClick(e){
  81. let pages = getCurrentPages();
  82. if(pages.length==1){
  83. uni.$u.route('/pages/index/index')
  84. }else{
  85. // uni.$u.route('/scenic/bookticket',{performId:this.performId})
  86. uni.navigateBack()
  87. };
  88. },
  89. findOrderCoupons(){
  90. this.$u.api.findOrderCoupons(this.param).then(res=>{
  91. this.dataList = res.data.list;
  92. }).catch(err=>{
  93. // console.log('findOrderCoupons',err.data);
  94. })
  95. },
  96. couponClick(item){
  97. let allPages = getCurrentPages(); //获取当前页面栈的实例;
  98. console.log('allPages',allPages);
  99. let prePages = allPages[allPages.length - 2].route;
  100. console.log('prePages',prePages);
  101. if(prePages=='pages/bookticket'){
  102. this.$u.vuex('coupon', item);
  103. uni.navigateBack();
  104. }else{
  105. uni.$u.route('/pages/index/index');
  106. }
  107. }
  108. }
  109. }
  110. </script>
  111. <style>
  112. page{
  113. background-color: #f5f5f5;
  114. }
  115. </style>
  116. <style lang="scss" scoped>
  117. </style>