computat.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="container">
  3. <view class="swiper-box">
  4. <scroll-view scroll-y class="cate-list" @scrolltolower="loadData">
  5. <view v-for="(item, index) in orderList" class="content-box">
  6. <view class="list-box">
  7. <view class="list-item">订单号:{{item.order_id}}</view>
  8. <view class="list-item">产品名称:{{item.body}}</view>
  9. <view class="list-item">购买数量:{{item.num}}</view>
  10. <view class="list-item">状态:{{item.status}}</view>
  11. <view class="list-item grey">购买时间:{{item.add_time}}</view>
  12. <view class="list-item grey">到期倒计时:{{item.end_time}}</view>
  13. </view>
  14. </view>
  15. <uni-load-more :status="loadingType"></uni-load-more>
  16. </scroll-view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import { order } from '@/api/quotation.js';
  22. import { getTime } from '@/utils/rocessor.js';
  23. export default {
  24. data() {
  25. return {
  26. loadingType:'',
  27. loading:'',
  28. page:1,
  29. limit:3,
  30. orderList:[],
  31. };
  32. },
  33. onShow: function() {
  34. this.loadData();
  35. },
  36. methods: {
  37. // 请求载入数据
  38. async loadData(type) {
  39. //这里是将订单挂载到tab列表下
  40. let obj = this;
  41. if (type != 'refresh') {
  42. //没有更多数据直接跳出方法
  43. if (obj.loadingType === 'nomore') {
  44. return;
  45. } else {
  46. // 设置当前为数据载入中
  47. obj.loadingType = 'loading';
  48. }
  49. } else {
  50. //当重新加载数据时更新状态为可继续添加数据
  51. obj.loadingType = 'more';
  52. }
  53. order({
  54. page: obj.page,
  55. limit: obj.limit
  56. })
  57. .then(({ data }) => {
  58. if (type === 'refresh') {
  59. obj.orderList = [];
  60. }
  61. let arr = data.list.map(e => {
  62. let now = new Date();
  63. //现在时间转换成时间戳
  64. let nowTime = now.getTime();
  65. let data = e.end_time;
  66. data = data.replace(/-/g, '/');
  67. let time = new Date(data);
  68. let end_time = time.getTime();
  69. if(nowTime > end_time){
  70. e.status = '过期了'
  71. }else{
  72. e.status = '正常'
  73. }
  74. return e;
  75. });
  76. obj.orderList = obj.orderList.concat(arr);
  77. //判断是否还有下一页,有是more 没有是nomore
  78. if (obj.limit == arr.length) {
  79. obj.page++;
  80. obj.loadingType = 'more';
  81. } else {
  82. obj.loadingType = 'nomore';
  83. }
  84. // 判断是否为刷新数据
  85. if (type == 'refresh') {
  86. // 判断是否为点击搜索按钮跳转加载
  87. if (obj.loading == 1) {
  88. uni.hideLoading();
  89. } else {
  90. uni.stopPullDownRefresh();
  91. }
  92. }
  93. })
  94. .catch(e => {
  95. obj.loadingType = 'nomore';
  96. uni.stopPullDownRefresh();
  97. uni.hideLoading();
  98. });
  99. },
  100. }
  101. };
  102. </script>
  103. <style lang="scss">
  104. page {
  105. min-height: 100%;
  106. background-color: #F7F7F7;
  107. .container {
  108. width: 100%;
  109. background-color: #FFFFFF;
  110. font-size: 30rpx;
  111. }
  112. }
  113. .swiper-box {
  114. height: 90vh;
  115. .cate-list {
  116. height: 90vh;
  117. }
  118. }
  119. .list-box{
  120. padding: 25rpx 25rpx;
  121. border-bottom: 2rpx solid #EAEAEA;
  122. .list-item{
  123. padding-bottom: 25rpx;
  124. }
  125. }
  126. .grey{
  127. color: #A8A8A8;
  128. font-size: 26rpx;
  129. }
  130. </style>