order.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="ezy-order-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="handleBack" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">订单</text>
  6. </view>
  7. <view class="ezy-page-body order-body">
  8. <scroll-view scroll-y="true" refresher-enabled="true" @scrolltolower="onScrolltolower"
  9. class="order-scroll-view" :refresher-triggered="data.loading" :refresher-threshold="50"
  10. refresher-background="transparent" @refresherrefresh="onRefresh">
  11. <view class="order-card-box" v-for="(item,index) in data.list" :key="index">
  12. <view class="card-head-box">
  13. <view class="head-name">鹅状元自营课程</view>
  14. <view class="head-status">{{item.status}}</view>
  15. </view>
  16. <view class="card-body-box">
  17. <!-- 封面 -->
  18. <image :src="item.chanpinCover" class="order-img"></image>
  19. <view class="body-right-box">
  20. <!-- 名称 -->
  21. <view class="body-title">{{item.chanpinName}}</view>
  22. <!-- 简介 -->
  23. <view class="taocan-text">{{item.taocanName}}</view>
  24. <view class="tip-text">不支持7天无理由</view>
  25. <!-- 共计 -->
  26. <view class="money-text">¥{{item.money}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. <uni-load-more :status="data.state" @click="getMore"
  31. :contentText="data.contentText">
  32. </uni-load-more>
  33. </scroll-view>
  34. <!-- <view @click="bangdingPhone">绑定手机号</view> -->
  35. </view>
  36. </view>
  37. </template>
  38. <script setup>
  39. import { reactive, ref } from "vue";
  40. import {orderList} from '@/api/shop.js'
  41. import { onLoad, onShow } from "@dcloudio/uni-app"
  42. const data = reactive({
  43. page: 0,
  44. list: [],
  45. loading: false,
  46. state: 'more',
  47. contentText: {
  48. contentdown: '查看更多',
  49. contentrefresh: '加载中',
  50. contentnomore: '没有更多'
  51. }
  52. })
  53. function handleBack() {
  54. uni.switchTab({
  55. url: '/pages/chanpinMy/my'
  56. })
  57. }
  58. function onScrolltolower() {
  59. getMore()
  60. }
  61. function getMore(code) {
  62. const opt = {
  63. page: 1,
  64. size: 10,
  65. }
  66. if (data.state == 'no-more') return;
  67. // 数学
  68. data.state = 'loading';
  69. data.page++;
  70. opt.page = data.page;
  71. orderList(opt).then(res => {
  72. data.list = data.list.concat(res.data.data);
  73. data.loading = false;
  74. if (res.data.total > data.list.length) {
  75. data.state = 'more';
  76. data.loading = false;
  77. } else {
  78. data.state = 'no-more';
  79. data.loading = false;
  80. }
  81. }).catch(err => {
  82. data.state = 'more';
  83. data.loading = false;
  84. })
  85. }
  86. function onRefresh(){
  87. data.page = 0;
  88. data.list = [];
  89. data.loading = true;
  90. refreshData(data.current);
  91. }
  92. function refreshData(code) {
  93. const opt = {
  94. page: 1,
  95. size: 10, // 固定查询10条
  96. }
  97. data.list = [];
  98. data.state = 'loading';
  99. data.page++;
  100. opt.page = data.page;
  101. orderList(opt).then(res => {
  102. data.list = data.list.concat(res.data.data);
  103. data.loading = false;
  104. if (res.data.total > data.list.length) {
  105. data.state = 'more';
  106. data.loading = false;
  107. } else {
  108. data.state = 'no-more';
  109. data.loading = false;
  110. }
  111. }).catch(err => {
  112. data.state = 'more';
  113. data.loading = false;
  114. })
  115. }
  116. onLoad(() => {
  117. getMore();
  118. // 判断游客 如果是弹出弹窗,忽略和绑定, 忽略删除缓存,绑定更新用户userName 删除缓存
  119. })
  120. </script>
  121. <style>
  122. </style>