order.vue 3.8 KB

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