order.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 v-if="data.list.length >0" 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" :contentText="data.contentText">
  31. </uni-load-more>
  32. </scroll-view>
  33. <view class="ezy-no-sj" v-else>
  34. <icon></icon>
  35. <text>暂无数据</text>
  36. </view>
  37. <tip-small-dialog ref="goBindDialogRef" @confirm-btn="goBindPhone" :content="tipContent"></tip-small-dialog>
  38. <!-- <view @click="bangdingPhone">绑定手机号</view> -->
  39. </view>
  40. </view>
  41. </template>
  42. <script setup>
  43. import {
  44. reactive,
  45. ref,
  46. onMounted
  47. } from "vue";
  48. import {
  49. orderList
  50. } from '@/api/shop.js'
  51. import {
  52. onLoad,
  53. onShow
  54. } from "@dcloudio/uni-app"
  55. import {
  56. getUserIsYouke
  57. } from "@/utils/common.js"
  58. import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue';
  59. const data = reactive({
  60. page: 0,
  61. list: [],
  62. loading: false,
  63. state: 'more',
  64. contentText: {
  65. contentdown: '查看更多',
  66. contentrefresh: '加载中',
  67. contentnomore: '没有更多'
  68. }
  69. })
  70. let pageOptions = {};
  71. const tipContent = '请绑定手机号';
  72. const goBindDialogRef = ref(null);
  73. function goBindPhone() {
  74. uni.navigateTo({
  75. url: '/pages/bindPhone/bindPhone?from=order'
  76. })
  77. }
  78. function handleBack() {
  79. uni.switchTab({
  80. url: '/pages/chanpinMy/my'
  81. })
  82. }
  83. function onScrolltolower() {
  84. getMore()
  85. }
  86. function getMore(code) {
  87. const opt = {
  88. page: 1,
  89. size: 10,
  90. }
  91. if (data.state == 'no-more') return;
  92. // 数学
  93. data.state = 'loading';
  94. data.page++;
  95. opt.page = data.page;
  96. orderList(opt).then(res => {
  97. data.list = data.list.concat(res.data.data);
  98. data.loading = false;
  99. if (res.data.total > data.list.length) {
  100. data.state = 'more';
  101. data.loading = false;
  102. } else {
  103. data.state = 'no-more';
  104. data.loading = false;
  105. }
  106. }).catch(err => {
  107. data.state = 'more';
  108. data.loading = false;
  109. })
  110. }
  111. function onRefresh() {
  112. data.page = 0;
  113. data.list = [];
  114. data.loading = true;
  115. refreshData(data.current);
  116. }
  117. function refreshData(code) {
  118. const opt = {
  119. page: 1,
  120. size: 10, // 固定查询10条
  121. }
  122. data.list = [];
  123. data.state = 'loading';
  124. data.page++;
  125. opt.page = data.page;
  126. orderList(opt).then(res => {
  127. data.list = data.list.concat(res.data.data);
  128. data.loading = false;
  129. if (res.data.total > data.list.length) {
  130. data.state = 'more';
  131. data.loading = false;
  132. } else {
  133. data.state = 'no-more';
  134. data.loading = false;
  135. }
  136. }).catch(err => {
  137. data.state = 'more';
  138. data.loading = false;
  139. })
  140. }
  141. onLoad((options) => {
  142. getMore();
  143. pageOptions = options
  144. // 判断游客 如果是弹出弹窗,忽略和绑定, 忽略删除缓存,绑定更新用户userName 删除缓存
  145. // 此时支付成功+游客模式支付进来的情况
  146. })
  147. onMounted(() => {
  148. // 组件已挂载,ref可正常使用
  149. if (pageOptions.zhifu === 'success' && getUserIsYouke()) {
  150. goBindDialogRef.value.handleShow();
  151. }
  152. })
  153. </script>
  154. <style>
  155. </style>