From de94f212c37dc68880e3b7db184157a1c984616a Mon Sep 17 00:00:00 2001 From: Yer11214 <17633066053@163.com> Date: Fri, 18 Oct 2024 15:25:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=9C=B0=E5=9D=80=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=B7=BB=E5=8A=A0loading=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/m-city/m-city.vue | 46 ++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/components/m-city/m-city.vue b/components/m-city/m-city.vue index c8e765a..38d1961 100644 --- a/components/m-city/m-city.vue +++ b/components/m-city/m-city.vue @@ -185,25 +185,35 @@ export default { this.tabbars.splice(index + 1, this.tabbars.length - index - 1); } if (this.tabbars.length < this.pickersize) { - let data = await getRegionsById(item.id); - // 当前选项级为最后一级时回调,将选中的数据返回 - if (data.data.result.length == 0) { - this.$emit("funcValue", this.tabbars); - this.hide(); - } else { - // 将新的数据填充进下一级 - var current = { - localName: "请选择", - id: "", - children: data.data.result, - - }; - this.tabbars.push(current); - this.tabCurrentIndex++; + uni.showLoading({ + title: "加载中", + mask:true + }); + try { + let data = await getRegionsById(item.id); + uni.hideLoading(); + // 当前选项级为最后一级时回调,将选中的数据返回 + if (data.data.result.length == 0) { + this.$emit("funcValue", this.tabbars); + this.hide(); + } else { + // 将新的数据填充进下一级 + var current = { + localName: "请选择", + id: "", + children: data.data.result, + + }; + this.tabbars.push(current); + this.tabCurrentIndex++; - // 当前距离重新为最上面 - this.$set(this,'scrollTop',0) - } + // 当前距离重新为最上面 + this.$set(this,'scrollTop',0) + } + } catch (error) { + uni.hideLoading(); + } + } else { this.$emit("funcValue", this.tabbars); this.hide();