Sfoglia il codice sorgente

首页定位失败处理

chenjj 3 mesi fa
parent
commit
75c88327c9
1 ha cambiato i file con 27 aggiunte e 22 eliminazioni
  1. 27 22
      pages/index.vue

+ 27 - 22
pages/index.vue

@@ -100,7 +100,7 @@ const cityClick = async () => {
   console.log("TCL: settingAddress1 -> data", data)
   store.dispatch('handlerAddress', data.address)
   const token = getToken();
-  token ? settingAddress():getList();
+  token ? settingAddress() : getList();
 }
 
 const loadmoreInfo = ref({
@@ -131,7 +131,7 @@ const getNotice = async () => {
 
 const getList = async () => {
   try {
-    if(userType !== 1){
+    if (userType !== 1) {
       console.log('志愿者端');
       return
     }
@@ -270,7 +270,7 @@ onShow(() => {
     },
   })
 
-  getList();
+
 })
 
 const addresstree = ref([])
@@ -285,26 +285,31 @@ onPageScroll(e => {
 
 onMounted(async () => {
 
-  console.log("TCL:  uni.$u", )
-  getNotice()
-  const token = getToken();
-
-  const res_dara = await regionAddresstree()
-  addresstree.value = res_dara.data
-
-  if (token) {
-    locateTheCurrentAddress(res_dara.data)
-      .then((res) => {
-        data.address = res
-        console.log("TCL: settingAddress0 -> data", data)
-        settingAddress()
-      })
-      .catch((error) => {
-        console.log('获取地址失败!', error)
-        getList()
-      })
+  try {
+    console.log("TCL:  uni.$u",)
+    getNotice()
+    const token = getToken();
+
+    const res_dara = await regionAddresstree()
+    addresstree.value = res_dara.data
+
+    if (token) {
+      locateTheCurrentAddress(res_dara.data)
+        .then((res) => {
+          data.address = res
+          console.log("TCL: settingAddress0 -> data", data)
+          settingAddress()
+        })
+        .catch((error) => {
+          console.log('获取地址失败!', error)
+          getList()
+        })
+    } else {
+      getList();
+    }
+  } catch (error) {
+    getList();
   }
-
 })
 
 onUnload(() => { })