order.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. <bindPhone ref="bindPhoneRef" @success="bindSuccess"></bindPhone>
  38. </template>
  39. <script setup>
  40. import { reactive, ref } from "vue";
  41. import {orderList} from '@/api/shop.js'
  42. import { onLoad, onShow } from "@dcloudio/uni-app"
  43. import bindPhone from "@/components/bindPhone/bindPhone.vue"
  44. const bindPhoneRef = ref(null);
  45. const data = reactive({
  46. page: 0,
  47. list: [],
  48. loading: false,
  49. state: 'more',
  50. contentText: {
  51. contentdown: '查看更多',
  52. contentrefresh: '加载中',
  53. contentnomore: '没有更多'
  54. }
  55. })
  56. function handleBack() {
  57. uni.switchTab({
  58. url: '/pages/chanpinMy/my'
  59. })
  60. }
  61. function bindSuccess(){
  62. }
  63. function onScrolltolower() {
  64. getMore()
  65. }
  66. function getMore(code) {
  67. const opt = {
  68. page: 1,
  69. size: 10,
  70. }
  71. if (data.state == 'no-more') return;
  72. // 数学
  73. data.state = 'loading';
  74. data.page++;
  75. opt.page = data.page;
  76. orderList(opt).then(res => {
  77. data.list = data.list.concat(res.data.data);
  78. data.loading = false;
  79. if (res.data.total > data.list.length) {
  80. data.state = 'more';
  81. data.loading = false;
  82. } else {
  83. data.state = 'no-more';
  84. data.loading = false;
  85. }
  86. }).catch(err => {
  87. data.state = 'more';
  88. data.loading = false;
  89. })
  90. }
  91. function onRefresh(){
  92. data.page = 0;
  93. data.list = [];
  94. data.loading = true;
  95. refreshData(data.current);
  96. }
  97. function refreshData(code) {
  98. const opt = {
  99. page: 1,
  100. size: 10, // 固定查询10条
  101. }
  102. data.list = [];
  103. data.state = 'loading';
  104. data.page++;
  105. opt.page = data.page;
  106. orderList(opt).then(res => {
  107. data.list = data.list.concat(res.data.data);
  108. data.loading = false;
  109. if (res.data.total > data.list.length) {
  110. data.state = 'more';
  111. data.loading = false;
  112. } else {
  113. data.state = 'no-more';
  114. data.loading = false;
  115. }
  116. }).catch(err => {
  117. data.state = 'more';
  118. data.loading = false;
  119. })
  120. }
  121. function bangdingPhone() {
  122. bindPhoneRef.value.showDl();
  123. }
  124. onLoad(() => {
  125. getMore();
  126. })
  127. </script>
  128. <style>
  129. </style>