From cd4fa2cfed76c15143511a40783abf3a75eb3146 Mon Sep 17 00:00:00 2001 From: peng <peng.com> Date: 星期三, 10 九月 2025 19:13:24 +0800 Subject: [PATCH] 扫码修改地址 --- pages/order/editOrderAddress/editOrderAddress.vue | 98 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 75 insertions(+), 23 deletions(-) diff --git a/pages/order/editOrderAddress/editOrderAddress.vue b/pages/order/editOrderAddress/editOrderAddress.vue index efcba7b..ef01bd7 100644 --- a/pages/order/editOrderAddress/editOrderAddress.vue +++ b/pages/order/editOrderAddress/editOrderAddress.vue @@ -117,6 +117,20 @@ } }, methods: { + // 瀹夊叏鐨則oast鏂规硶锛岄�傞厤灏忕▼搴忕幆澧� + safeShowToast(options) { + // 纭繚loading鍜屼箣鍓嶇殑toast宸插叧闂� + uni.hideLoading(); + uni.hideToast(); + // 浣跨敤nextTick纭繚鍦ㄤ笅涓�涓簨浠跺惊鐜腑鎵ц + this.$nextTick(() => { + uni.showToast({ + ...options, + duration: options.duration || 2000 + }); + }); + }, + // 瑙f瀽URL鍙傛暟 parseUrlParams(url) { const params = {}; @@ -136,29 +150,66 @@ }, // 鍔犺浇璁㈠崟璇︽儏 async loadOrderDetail() { + if (!this.orderSn) { + console.log('璁㈠崟鍙蜂负绌猴紝鏃犳硶鍔犺浇璁㈠崟璇︽儏'); + this.safeShowToast({ + title: '璁㈠崟鍙蜂笉鑳戒负绌�', + icon: 'none' + }); + return; + } + + let loadingShown = false; try { uni.showLoading({ title: '鍔犺浇涓�...' - }) - const res = await getOrderDetailEdit(this.orderSn) - console.log('----------鑾峰彇璁㈠崟杩斿洖缁撴灉------------->',res) - if (res.data.success) { - this.orderDetail = res.data.result - console.log('----------------------->璁㈠崟鏁版嵁', JSON.stringify(this.orderDetail)) + }); + loadingShown = true; + + console.log('寮�濮嬭姹傝鍗曡鎯咃紝璁㈠崟鍙�:', this.orderSn); + const res = await getOrderDetailEdit(this.orderSn); + console.log('----------鑾峰彇璁㈠崟杩斿洖缁撴灉------------->',res); + + // 妫�鏌ュ搷搴旂姸鎬� + if (res && res.data) { + if (res.data.success) { + this.orderDetail = res.data.result; + console.log('----------------------->璁㈠崟鏁版嵁', JSON.stringify(this.orderDetail)); + } else { + console.log('API杩斿洖澶辫触:', res.data.message); + // 鍏堝叧闂璴oading鍐嶆樉绀簍oast + uni.hideLoading(); + loadingShown = false; + this.safeShowToast({ + title: res.data.message || '鑾峰彇璁㈠崟淇℃伅澶辫触', + icon: 'none' + }); + } } else { - uni.showToast({ - title: res.data.message || '鑾峰彇璁㈠崟淇℃伅澶辫触', + console.log('鏈嶅姟鍣ㄥ搷搴斿紓甯�:', res); + uni.hideLoading(); + loadingShown = false; + this.safeShowToast({ + title: '鏈嶅姟鍣ㄥ搷搴斿紓甯�', icon: 'none' - }) + }); } } catch (error) { - console.error('鑾峰彇璁㈠崟璇︽儏澶辫触:', error) - uni.showToast({ - title: '鑾峰彇璁㈠崟淇℃伅澶辫触', + console.error('鑾峰彇璁㈠崟璇︽儏澶辫触:', error); + // 缃戠粶寮傚父鎴栧叾浠栭敊璇� + if (loadingShown) { + uni.hideLoading(); + loadingShown = false; + } + this.safeShowToast({ + title: '缃戠粶寮傚父锛岃绋嶅悗閲嶈瘯', icon: 'none' - }) + }); } finally { - uni.hideLoading() + // 纭繚loading琚叧闂� + if (loadingShown) { + uni.hideLoading(); + } } }, @@ -317,17 +368,18 @@ needToken: true, data: this.addressForm }) - + console.log("鍦板潃淇濆瓨") if (res.data.success) { - uni.showToast({ - title: '鍦板潃淇濆瓨鎴愬姛', - icon: 'success' + // uni.showToast({ + // title: '鍦板潃淇濆瓨鎴愬姛', + // icon: 'success' + // }) + uni.redirectTo({ + url:'/pages/tabbar/index/home', + fail(e) { + console.log("璺宠浆澶辫触鍘熷洜",e) + } }) - setTimeout(() => { - uni.switchTab({ - url:'/pages/tabbar/index/home' - }) - }, 1500) } else { uni.showToast({ title: res.data.message || '淇濆瓨澶辫触', -- Gitblit v1.8.0