diff --git a/pages/newOrder/address.vue b/pages/newOrder/address.vue index cf625ad..262df18 100644 --- a/pages/newOrder/address.vue +++ b/pages/newOrder/address.vue @@ -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) diff --git a/pages/newOrder/petList.vue b/pages/newOrder/petList.vue index 7b8a364..19b8f7e 100644 --- a/pages/newOrder/petList.vue +++ b/pages/newOrder/petList.vue @@ -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); // 获取三个月后的日期 diff --git a/pages/personalCenter/addressInfo.vue b/pages/personalCenter/addressInfo.vue index 8a749ce..648d697 100644 --- a/pages/personalCenter/addressInfo.vue +++ b/pages/personalCenter/addressInfo.vue @@ -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) diff --git a/pages_order/order/orderList.vue b/pages_order/order/orderList.vue index 73e2f7f..0df74dc 100644 --- a/pages_order/order/orderList.vue +++ b/pages_order/order/orderList.vue @@ -15,7 +15,7 @@ - {{ tabs[order.status - 1].name }} + {{ tabs[order.status + 1].name }} 指定伴宠师下单 系统下单 @@ -85,7 +85,8 @@ - + + 加载中... @@ -99,8 +100,22 @@ 暂无订单 + + + + + 正在加载订单... + + + + @@ -110,6 +125,14 @@ + + + + + + 正在处理支付... + + @@ -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; + } } } @@ -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 { diff --git a/utils/getUrl.js b/utils/getUrl.js index ca81617..18b4d80 100644 --- a/utils/getUrl.js +++ b/utils/getUrl.js @@ -1,4 +1,4 @@ -let current ="trial"; +let current ="develop"; const accountInfo = wx.getAccountInfoSync(); // current = accountInfo.miniProgram.envVersion;