order.vue 3.9 KB

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