guhongwei 2 rokov pred
rodič
commit
742ed36e5b

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 31
common/amap-wx.130.js


+ 8 - 8
common/api.js

@@ -5,17 +5,17 @@ const getDomain = (uri, method, type) => {
 	else return config.serverUrl + '/point/v1/api' + uri;
 }
 // 获取token
-const getToken = () => {
-	try {
-		const value = uni.getStorageSync('token');
-		if (value) return value;
-	} catch {}
-}
+// const getToken = () => {
+// 	try {
+// 		const value = uni.getStorageSync('token');
+// 		if (value) return value;
+// 	} catch {}
+// }
 export const requestBase = (uri, method, data, type) => {
 	let baseUrl = getDomain(uri, method, type);
-	let token = getToken();
+	// let token = getToken();
 	let header = {};
-	if (token) header.token = token;
+	// if (token) header.token = token;
 	return new Promise((resolve, reject) => {
 		uni.request({
 			url: baseUrl,

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1122 - 0
common/qqmap-wx-jssdk.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 0
common/qqmap-wx-jssdk.min.js


+ 23 - 0
common/tool.js

@@ -0,0 +1,23 @@
+//new Promise封装起来使用,避免代码多次重复
+
+import QQMapWX from './qqmap-wx-jssdk.min.js'
+
+export function getAddress(lng, lat) {
+	return new Promise((resove, reject) => {
+		const qqmapsdk = new QQMapWX({
+			key: '5WLBZ-H6RWU-NQVVO-BQG7I-XEHFK-PAFSF',
+		})
+		qqmapsdk.reverseGeocoder({
+			location: {
+				latitude: lat,
+				longitude: lng
+			},
+			success: (res) => {
+				resove(res)
+			},
+			fail: (e) => {
+				reject(e)
+			},
+		})
+	})
+}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 3082 - 2
config.js


+ 4 - 1
pages/home/index.vue

@@ -59,6 +59,9 @@
 </template>
 
 <script>
+	import {
+		getAddress
+	} from '@/common/tool.js'
 	export default {
 		data() {
 			return {
@@ -75,7 +78,7 @@
 				],
 				// 是否显示返回顶部
 				isShow: false,
-				topItem: ''
+				topItem: '',
 			};
 		},
 		onLoad: function() {

+ 67 - 61
pagesMy/address/add.vue

@@ -13,17 +13,17 @@
 						<button type="default" size="mini" class="toLoacl" @click="toLocaltion()">地图选点</button>
 					</uni-forms-item>
 					<uni-forms-item label="所在省份" name="province">
-						<picker class="picker" mode="selector" :range="provinceList" @change="proChange" range-key="value">
+						<picker class="picker" mode="selector" :range="provinceList" @change="proChange" range-key="name">
 							<view>{{form.province||'请选择所在省份'}}</view>
 						</picker>
 					</uni-forms-item>
 					<uni-forms-item label="所在市" name="city">
-						<picker class="picker" mode="selector" :range="cityList" @change="cityChange" range-key="value">
+						<picker class="picker" mode="selector" :range="cityList" @change="cityChange" range-key="name">
 							<view>{{form.city||'请选择所在市'}}</view>
 						</picker>
 					</uni-forms-item>
 					<uni-forms-item label="所在区" name="area">
-						<picker class="picker" mode="selector" :range="areaList" @change="areaChange" range-key="value">
+						<picker class="picker" mode="selector" :range="areaList" @change="areaChange">
 							<view>{{form.area||'请选择所在区'}}</view>
 						</picker>
 					</uni-forms-item>
@@ -43,6 +43,9 @@
 </template>
 
 <script>
+	import {
+		getAddress
+	} from '@/common/tool.js';
 	export default {
 		data() {
 			return {
@@ -89,48 +92,12 @@
 					},
 				},
 				provinceList: [ //所在省份
-					{
-						code: '1',
-						value: '吉林省',
-					},
-					{
-						code: '2',
-						value: '辽宁省',
-					},
-					{
-						code: '3',
-						value: '黑龙江省',
-					},
 				],
 				cityList: [ //所在市
-					{
-						code: '1-1',
-						value: '长春市',
-					},
-					{
-						code: '2-1',
-						value: '大连市',
-					},
-					{
-						code: '3-1',
-						value: '哈尔滨市',
-					},
 				],
 				areaList: [ //所在区
-					{
-						code: '1-1-1',
-						value: '朝阳区'
-					},
-					{
-						code: '2-1-1',
-						value: '开发区'
-					},
-					{
-						code: '3-1-1',
-						value: '发展区'
-					},
-				]
-
+				],
+				paltForm: ''
 			};
 		},
 		onLoad: function(e) {
@@ -140,6 +107,12 @@
 		},
 		onShow: function() {
 			const that = this;
+			uni.getStorage({
+				key: 'system',
+				success: function(res) {
+					that.$set(that, `paltForm`, res.data.uniPlatform)
+				}
+			})
 		},
 		onUnload: function() {},
 		methods: {
@@ -164,6 +137,7 @@
 								})
 							}
 						}
+						that.searchPor();
 					},
 					fail: function(err) {
 						uni.reLaunch({
@@ -172,47 +146,79 @@
 					}
 				})
 			},
+			// 查找省
+			searchPor() {
+				const that = this;
+				let list = that.$config.china;
+				that.$set(that, `provinceList`, list)
+			},
 			// 定位
 			toLocaltion() {
 				const that = this;
 				uni.chooseLocation({
 					success: function(res) {
-						if (res) {
-							that.$set(that.form, `address`, res.address || '')
-						}
-					},
-					fail: function(err) {
-						console.log(err);
+						that.searchAddress(res);
 					}
 				})
-				// const key = that.$config.txlocalKey;
-				// const referer = that.$config.txlocalReferer;
-				// uni.navigateTo({
-				// 	url: `plugin://chooseLocation/index?key=${key}&referer=${referer}`
-				// });
+			},
+			// 解析位置详细信息
+			searchAddress(e) {
+				const that = this;
+				that.$set(that.form, `address`, e.address);
+				if (that.paltForm == 'app') {
+					var point = new plus.maps.Point(e.longitude, e.latitude);
+					plus.maps.Map.reverseGeocode(point, {}, function(event) {
+						var address = event.address;
+						var reg = /.+?(省|市|自治区|自治州|县|区)/g;
+						let addressList = address.match(reg).toString().split(",");
+						let province = addressList[0] || '';
+						let city = addressList[1] || '';
+						let area = addressList[2] || '';
+						that.$set(that.form, `province`, province);
+						that.$set(that.form, `city`, city);
+						that.$set(that.form, `area`, area);
+					})
+				} else if (that.paltForm == 'mp-weixin') {
+					getAddress(e.longitude, e.latitude).then((res) => {
+						if (res.status == 0) {
+							let province = res.result.address_component.province;
+							let city = res.result.address_component.city;
+							let area = res.result.address_component.district;
+							that.$set(that.form, `province`, province);
+							that.$set(that.form, `city`, city);
+							that.$set(that.form, `area`, area);
+						} else {
+							uni.showToast({
+								title: '解析位置失败,请重新选择!'
+							});
+						}
+					})
+				}
 			},
 			// 选择省份
 			proChange(e) {
 				const that = this;
 				let data = that.provinceList[e.detail.value];
 				if (data) {
-					that.$set(that.form, `province`, data.value)
+					that.$set(that.form, `province`, data.name);
+					that.$set(that, `cityList`, data.city)
 				}
 			},
-			// 选择区
-			areaChange(e) {
+			// 选择
+			cityChange(e) {
 				const that = this;
-				let data = that.areaList[e.detail.value];
+				let data = that.cityList[e.detail.value];
 				if (data) {
-					that.$set(that.form, `area`, data.value)
+					that.$set(that.form, `city`, data.name);
+					that.$set(that, `areaList`, data.area);
 				}
 			},
-			// 选择市
-			cityChange(e) {
+			// 选择
+			areaChange(e) {
 				const that = this;
-				let data = that.cityList[e.detail.value];
+				let data = that.areaList[e.detail.value];
 				if (data) {
-					that.$set(that.form, `city`, data.value)
+					that.$set(that.form, `area`, data)
 				}
 			},
 			// 是否默认