Procházet zdrojové kódy

对接退出登录接口,隐藏高德key接口

xueyihao před 4 měsíci
rodič
revize
f644568ad4

+ 2 - 2
src/api/index.js

@@ -2,8 +2,8 @@ import request from "@/utils/request.js";
 //区域根据name获取code接口
 export function getCityCode(data) {
     return request({
-        method: 'get',
-        url: '/area/code',
+        method: 'post',
+        url: '/area/city',
         data
     });
 }

+ 4 - 22
src/pages/index/index.vue

@@ -257,28 +257,10 @@ export default {
         return;
       }
       try {
-        const amapKey = '5457092e6c62b83c1b2e45dbe973d858';
-        const url = `https://restapi.amap.com/v3/geocode/regeo?key=${amapKey}&location=${longitude},${latitude}`;
-        const res = await uni.request({
-          url: url,
-          method: 'GET',
-        });
-        if (!res.data || !res.data.regeocode || !res.data.regeocode.addressComponent) {
-          console.error('获取城市信息失败:响应数据格式错误');
-          return;
-        }
-        const city = res.data.regeocode.addressComponent.city;
-        if (!city) {
-          console.error('获取城市信息失败:未找到城市名称');
-          return;
-        }
-        uni.setStorageSync('selectCity', city);
-        const resquery = await getCityCode({name: city});
-        if (!resquery || !resquery.data || !resquery.data.data) {
-          console.error('获取城市代码失败:响应数据格式错误');
-          return;
-        }
-        uni.setStorageSync('selectCitycode', resquery.data.data);
+        const resquery = await getCityCode({longitude: longitude,latitude:latitude});
+        console.log(resquery);
+        uni.setStorageSync('selectCity', resquery.data.data.cityName);
+        uni.setStorageSync('selectCitycode', resquery.data.data.cityCode);
       } catch (error) {
         console.error('获取城市信息失败:', error);
       }

+ 3 - 1
src/setting/myNew/index.vue

@@ -34,7 +34,9 @@ export default {
             logout().then(res => {
               if (res.data.code == 200) {
                 uni.removeStorageSync('access-token')
-                this.$router.go(0)
+                uni.switchTab({
+                  url: '/pages/my/my'
+                })
                 uni.showToast({
                   title: '已退出登录',
                   icon: 'none'

+ 5 - 3
src/setting/myNew/phone.vue

@@ -65,6 +65,7 @@ export default {
       }, 1000)
     },
     bindPhone() {
+      var _this = this;
       if (this.isBinding) return
 
       if (!this.phone) {
@@ -94,16 +95,17 @@ export default {
       this.isBinding = true
       bindPhone({
         openId:uni.getStorageSync('wx_copenid'),
-        phone:this.phone,
-        code:this.code
+        phone:_this.phone,
+        code:_this.code
       }).then(res =>{
         if (res.data.code == 200) {
           uni.showToast({
             title: '绑定成功',
             icon: 'success'
           })
-          uni.setStorageSync('wx_phone', this.phone)
+          uni.setStorageSync('wx_phone', _this.phone)
           uni.navigateBack()
+          _this.isBinding = false;
         }
       })
     }