wangguoyu 3 months ago
parent
commit
05971fcddf
4 changed files with 16 additions and 11 deletions
  1. 4 4
      components/customMap/customMap.vue
  2. 2 2
      components/customMap/useMap.js
  3. 8 3
      config.js
  4. 2 2
      manifest.json

+ 4 - 4
components/customMap/customMap.vue

@@ -72,7 +72,7 @@
 	import {
 		useCustomMap
 	} from "@/components/customMap/useMap.js"
-
+	import config from "@/config.js"
 	const emits = defineEmits(['close', 'xuanzeAdress', 'currentWeizhi'])
 	const {
 		getPositionSearchByKeyword
@@ -105,7 +105,7 @@
 	function getCityLocation(city) {
 		console.log('222222');
 		console.log('city', city);
-		const Key = `KBYBZ-FS3KZ-U2FXR-7VPDX-L7J46-23F55`
+		const Key = config.mapKey
 		const url = `https://apis.map.qq.com/ws/geocoder/v1`;
 		const url2 = `https://apis.map.qq.com/ws/geocoder/v1/?address=${city}&key=${Key}`;
 		// #ifdef H5
@@ -265,7 +265,7 @@
 	})
 
 	function getCityName(latitude, longitude) {
-		const Key = `KBYBZ-FS3KZ-U2FXR-7VPDX-L7J46-23F55`
+		const Key = config.mapKey
 		const url1 = `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${Key}`;
 		const url = `https://apis.map.qq.com/ws/geocoder/v1`;
 		//const url = `https://apis.map.qq.com/ws/geocoder/v1/`;
@@ -342,7 +342,7 @@
 	}
 
 	onLoad(() => {
-		console.log('初始化')
+		console.log('初始化',config)
 		initLocation();
 	})
 </script>

+ 2 - 2
components/customMap/useMap.js

@@ -7,10 +7,10 @@ import {
 import {
 	jsonp
 } from "@/utils/common.js"
-
+import config from '@/config.js'
 // 关键词不全
 const httpUrl = "https://apis.map.qq.com/ws/place/v1/search"
-const Key = `KBYBZ-FS3KZ-U2FXR-7VPDX-L7J46-23F55`
+const Key = config.mapKey
 
 export function useCustomMap() {
 	// 关键字 范围 页码 数量 成功回调 失败回调

+ 8 - 3
config.js

@@ -1,8 +1,13 @@
 // 应用全局配置
+// 切换环境后 注意 :map 要去对应manifest.json文件修改
+let isPro = process.env.NODE_ENV === 'production'
+const devUrl = 'https://kf3.mtavip.com/api'
+const proUrl = 'https://www.chengxiangjiaoyu.com/api'
+const devKey = 'MZRBZ-Q6PKQ-THS5E-BOGKN-ZH4MQ-6YFWC'
+const proKey = ''
 export default   {
-  baseUrl: 'https://www.chengxiangjiaoyu.com/api',
-  // baseUrl: 'https://kf3.mtavip.com/api',
-  // baseUrl: 'http://localhost:8080',
+  baseUrl: isPro?proUrl:devUrl,
+  mapKey:isPro?proKey:devKey,
   // 应用信息
   appInfo: {
     // 应用名称

+ 2 - 2
manifest.json

@@ -80,7 +80,7 @@
                 },
                 "maps" : {
                     "tencent" : {
-                        "key" : "KBYBZ-FS3KZ-U2FXR-7VPDX-L7J46-23F55"
+                        "key" : "MZRBZ-Q6PKQ-THS5E-BOGKN-ZH4MQ-6YFWC"
                     }
                 }
             },
@@ -158,7 +158,7 @@
                     "key" : "KBYBZ-FS3KZ-U2FXR-7VPDX-L7J46-23F55"
                 },
                 "tencent" : {
-                    "key" : "KBYBZ-FS3KZ-U2FXR-7VPDX-L7J46-23F55"
+                    "key" : "MZRBZ-Q6PKQ-THS5E-BOGKN-ZH4MQ-6YFWC"
                 }
             }
         }