Browse Source

fix(订单列表): 修复订单状态显示错误并优化加载体验

修复订单状态显示索引错误问题,增加加载动画和防抖处理
优化地址选择逻辑,修复空地址处理问题
调整默认环境变量为develop
master
前端-胡立永 5 days ago
parent
commit
eee24cf3fc
5 changed files with 235 additions and 43 deletions
  1. +30
    -8
      pages/newOrder/address.vue
  2. +1
    -1
      pages/newOrder/petList.vue
  3. +57
    -25
      pages/personalCenter/addressInfo.vue
  4. +146
    -8
      pages_order/order/orderList.vue
  5. +1
    -1
      utils/getUrl.js

+ 30
- 8
pages/newOrder/address.vue View File

@ -137,24 +137,46 @@
selectAddress(){
uni.chooseLocation({
success: res => {
console.log(res);
this.addressInfo.latitude = res.latitude
this.addressInfo.longitude = res.longitude
var reg = /.+?(省|市|自治区|自治州|县|区)/g;
let arr = res.address.match(reg)
this.addressInfo.province = arr[0]
this.addressInfo.city = arr[1]
this.addressInfo.district = arr[2]
let address = ''
if (!res.address && res.name) { //
return this.addressInfo.selectAddress = res.name
address = res.name
}
if (res.address || res.name) {
return this.addressInfo.selectAddress = res.address + res.name
address = res.address + res.name
}
this.addressInfo.selectAddress = '' //
if(!address){
return
}
let arr = address.match(reg)
this.addressInfo.province = arr[0] || ''
this.addressInfo.city = arr[1] || ''
this.addressInfo.district = arr[2] || ''
let detail = arr[2] || arr[1] || arr[0] || ''
this.addressInfo.detailAddress = address.substring(address.indexOf(detail) + detail.length)
this.addressInfo.selectAddress = `${arr[0] || ''}${arr[1] || ''}${arr[2] || ''}`
// if (!res.address && res.name) { //
// return this.addressInfo.selectAddress = res.name
// }
// if (res.address || res.name) {
// return this.addressInfo.selectAddress = res.address + res.name
// }
// this.addressInfo.selectAddress = '' //
},
fail(e) {
console.log("获取位置信息失败!", e)


+ 1
- 1
pages/newOrder/petList.vue View File

@ -276,7 +276,7 @@ export default {
},
getCalendarDate() {
let tomorrow = new Date()
tomorrow.setDate(tomorrow.getDate());
tomorrow.setDate(tomorrow.getDate() + 2);
this.startDate = this.formatDate(tomorrow);
//


+ 57
- 25
pages/personalCenter/addressInfo.vue View File

@ -136,40 +136,72 @@
uni.chooseLocation({
success: res => {
console.log(res);
this.addressInfo.latitude = res.latitude
this.addressInfo.longitude = res.longitude
// this.addressInfo.district = ''
// this.addressInfo.province = ''
var reg = /.+?(省|市|自治区|自治州|县|区)/g;
let arr = res.address.match(reg)
// var add1 = '34';
// var add2 = '1'
// var add3 = '479';
// var add4 = '23';
// var add5 = '西';
// console.log(add1 + ': ', add1.match(reg));
// console.log(add2 + ': ', add2.match(reg));
// console.log(add3 + ': ', add3.match(reg));
// console.log(add4 + ': ', add4.match(reg));
// console.log(add5 + ': ', add5.match(reg));
this.addressInfo.province = arr[0]
this.addressInfo.city = arr[1]
this.addressInfo.district = arr[2]
let address = ''
if (!res.address && res.name) { //
return this.addressInfo.selectAddress = res.name
address = res.name
}
if (res.address || res.name) {
return this.addressInfo.selectAddress = res.address + res.name
address = res.address + res.name
}
this.addressInfo.selectAddress = '' //
if(!address){
return
}
let arr = address.match(reg)
this.addressInfo.province = arr[0] || ''
this.addressInfo.city = arr[1] || ''
this.addressInfo.district = arr[2] || ''
let detail = arr[2] || arr[1] || arr[0] || ''
this.addressInfo.detailAddress = address.substring(address.indexOf(detail) + detail.length)
this.addressInfo.selectAddress = `${arr[0] || ''}${arr[1] || ''}${arr[2] || ''}`
return
// console.log(res);
// this.addressInfo.latitude = res.latitude
// this.addressInfo.longitude = res.longitude
// // this.addressInfo.district = ''
// // this.addressInfo.province = ''
// var reg = /.+?(|||||)/g;
// let arr = res.address.match(reg)
// // var add1 = '34';
// // var add2 = '1'
// // var add3 = '479';
// // var add4 = '23';
// // var add5 = '西';
// // console.log(add1 + ': ', add1.match(reg));
// // console.log(add2 + ': ', add2.match(reg));
// // console.log(add3 + ': ', add3.match(reg));
// // console.log(add4 + ': ', add4.match(reg));
// // console.log(add5 + ': ', add5.match(reg));
// this.addressInfo.province = arr[0]
// this.addressInfo.city = arr[1]
// this.addressInfo.district = arr[2]
// if (!res.address && res.name) { //
// return this.addressInfo.selectAddress = res.name
// }
// if (res.address || res.name) {
// return this.addressInfo.selectAddress = res.address + res.name
// }
// this.addressInfo.selectAddress = '' //
},
fail(e) {
console.log("获取位置信息失败!", e)


+ 146
- 8
pages_order/order/orderList.vue View File

@ -15,7 +15,7 @@
<!-- 订单卡片 -->
<view class="order-card" v-for="(order, index) in orderList" :key="index">
<view class="order-header">
<text>{{ tabs[order.status - 1].name }}</text>
<text>{{ tabs[order.status + 1].name }}</text>
<view class="order-status">
<text v-if="order.teacherId">指定伴宠师下单</text>
<text v-else>系统下单</text>
@ -85,7 +85,8 @@
</view>
<!-- 加载更多 -->
<view class="loading-more" v-if="orderList.length > 0 && hasMore">
<view class="loading-more" v-if="orderList.length > 0 && hasMore && loading">
<view class="loading-spinner"></view>
<text>加载中...</text>
</view>
@ -99,8 +100,22 @@
<image src="/static/images/personal/no-data.png" mode="aspectFit" class="no-data-image"></image>
<text>暂无订单</text>
</view>
<!-- 首次加载状态 -->
<view class="initial-loading" v-if="orderList.length === 0 && loading">
<view class="loading-spinner large"></view>
<text>正在加载订单...</text>
</view>
</view>
</scroll-view>
<!-- 全屏加载遮罩 (仅首次加载显示) -->
<!-- <view class="loading-overlay" v-if="loading && page === 1 && orderList.length === 0 && isFirstLoad">
<view class="loading-content">
<view class="loading-spinner large"></view>
<text class="loading-text">正在加载订单数据...</text>
</view>
</view> -->
<!-- 取消订单弹窗 -->
<cancel-order-popup ref="cancelOrderPopup" @cancel="handleCancelOrder"></cancel-order-popup>
@ -110,6 +125,14 @@
<!-- 伴宠师选择弹窗 -->
<companion-select-popup ref="companionSelectPopup" />
<!-- 支付加载遮罩 -->
<view class="loading-overlay" v-if="isPaying">
<view class="loading-content">
<view class="loading-spinner large"></view>
<text class="loading-text">正在处理支付...</text>
</view>
</view>
</view>
</template>
@ -166,6 +189,10 @@
refreshing: false,
currentOrder: null,
isPaying : false,
requestId: 0, //
switchTabTimer: null, //
loadMoreTimer: null, //
isFirstLoad: true, //
// API
exampleData: [{
id: '1',
@ -196,12 +223,23 @@
methods: {
//
switchTab(tabValue) {
// if (this.currentTab === tabValue) return;
if (this.currentTab === tabValue) return; //
this.currentTab = tabValue;
this.orderList = [];
this.page = 1;
this.hasMore = true;
this.getOrderList();
this.isFirstLoad = false; //
//
if (this.switchTabTimer) {
clearTimeout(this.switchTabTimer);
}
//
this.switchTabTimer = setTimeout(() => {
this.getOrderList();
}, 100);
},
//
@ -210,6 +248,7 @@
this.page = 1;
this.orderList = [];
this.hasMore = true;
this.isFirstLoad = false; //
this.getOrderList().then(() => {
this.refreshing = false;
}).catch(() => {
@ -224,8 +263,16 @@
//
loadMore() {
if (this.loading || !this.hasMore) return;
this.page++;
this.getOrderList();
//
if (this.loadMoreTimer) {
clearTimeout(this.loadMoreTimer);
}
this.loadMoreTimer = setTimeout(() => {
this.page++;
this.getOrderList();
}, 200);
},
//
@ -284,6 +331,9 @@
getOrderList() {
if (this.loading) return Promise.reject();
this.loading = true;
// ID
const currentRequestId = ++this.requestId;
//
const params = {
@ -317,6 +367,12 @@
// });
// API
return getOrderList(params).then(res => {
//
if (currentRequestId !== this.requestId) {
console.log('忽略过期的请求结果');
return Promise.reject('过期的请求');
}
if (res.content) {
const newList = res.content || [];
if (this.page === 1) {
@ -342,9 +398,13 @@
this.hasMore = false;
}
this.loading = false;
resolve();
this.isFirstLoad = false; //
}).catch(err => {
this.loading = false;
// loading
if (currentRequestId === this.requestId) {
this.loading = false;
this.isFirstLoad = false; //
}
});
},
@ -369,6 +429,18 @@
onLoad() {
//
this.getOrderList();
},
onUnload() {
//
if (this.switchTabTimer) {
clearTimeout(this.switchTabTimer);
this.switchTabTimer = null;
}
if (this.loadMoreTimer) {
clearTimeout(this.loadMoreTimer);
this.loadMoreTimer = null;
}
}
}
</script>
@ -569,6 +641,72 @@
padding: 20rpx 0;
color: #999;
font-size: 24rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.initial-loading {
text-align: center;
padding: 100rpx 0;
color: #999;
font-size: 28rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.loading-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
// background-color: rgba(255, 255, 255, 0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 999;
}
.loading-content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
// background-color: #FFFFFF;
padding: 40rpx;
border-radius: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
}
.loading-text {
color: #666;
font-size: 28rpx;
margin-top: 20rpx;
}
.loading-spinner {
width: 40rpx;
height: 40rpx;
border: 4rpx solid #f3f3f3;
border-top: 4rpx solid #FFAA48;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 16rpx;
&.large {
width: 60rpx;
height: 60rpx;
border-width: 6rpx;
}
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.no-order {


+ 1
- 1
utils/getUrl.js View File

@ -1,4 +1,4 @@
let current ="trial";
let current ="develop";
const accountInfo = wx.getAccountInfoSync();
// current = accountInfo.miniProgram.envVersion;


Loading…
Cancel
Save