index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="order">
  3. <!-- header -->
  4. <cu-custom bgColor="bg-gradual-blue" isBack><view slot="content">我的卡券</view></cu-custom>
  5. <!-- section -->
  6. <cu-nav :active="active" @onChange="onChange" :value="value" />
  7. <view v-for="(item,index) in value" :key="index" class="box">
  8. <view v-show="index==active">
  9. <view v-for="(itemB,indexB) of item.value" :key="indexB" class="bg-white padding-sm radius margin-lr margin-top">
  10. <view class="text-bold text-black">{{itemB.coupon_name}}</view>
  11. <view class="text-sm text-black padding-top-sm">{{itemB.receive_date | changeDate}} - {{itemB.end_date | changeDate}}</view>
  12. <view v-if="itemB.write_off_time" class="text-sm text-black padding-top-sm">使用时间:{{itemB.write_off_time}}</view>
  13. <view class="text-gray text-sm margin-top">{{itemB.activity_name}}</view>
  14. </view>
  15. <van-empty v-if="item.value.length==0 && item.no_more" description="暂无卡券" />
  16. <view v-else :class="!item.no_more && item.pageCount<=item.totalPage ? 'cu-load bg-grey loading margin-top' : 'cu-load bg-grey over margin-top'"></view>
  17. </view>
  18. </view>
  19. <!-- footer -->
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. active:0,
  27. value: [
  28. {
  29. id: 1,
  30. name:"待使用",
  31. no_more:false,//没有更多
  32. pageCount: 1,
  33. totalPage: 1,
  34. value: []
  35. },
  36. {
  37. id: 2,
  38. name:"已使用",
  39. no_more:false,//没有更多
  40. pageCount: 1,
  41. totalPage: 1,
  42. value: []
  43. },
  44. {
  45. id: 3,
  46. name:"已过期",
  47. no_more:false,//没有更多
  48. pageCount: 1,
  49. totalPage: 1,
  50. value: []
  51. }
  52. ]
  53. };
  54. },
  55. onLoad() {
  56. this.request();
  57. },
  58. filters:{
  59. changeDate(value){
  60. return value.replaceAll("-",".")
  61. }
  62. },
  63. methods: {
  64. // 不同状态
  65. onChange(index){
  66. this.active=index;
  67. this.request();
  68. },
  69. // 请求
  70. async request() {
  71. var $value=JSON.parse(JSON.stringify(this.value));
  72. var {name,pageCount,no_more,totalPage,value,id}=$value[this.active];
  73. if(pageCount>totalPage) return false;
  74. var res=await this.$global.request({url:"/customer/coupon/",
  75. header: {
  76. 'Content-Type': 'application/x-www-form-urlencoded',
  77. Authorization: uni.getStorageSync('token')
  78. },method:'get',data:{
  79. page:pageCount,limit:20,
  80. status:id,appid:this.$store.state.userInfo.appid,activity_id:this.$store.state.userInfo.activity_id}});
  81. pageCount++;
  82. totalPage=res.totalPage;
  83. if(pageCount>totalPage) no_more=true;
  84. value=value.concat(res.data);
  85. $value[this.active]={name,pageCount,no_more,totalPage,value,id};
  86. this.value=$value;
  87. }
  88. },
  89. watch:{
  90. }
  91. };
  92. </script>
  93. <style></style>