Преглед изворни кода

评论添加地区经纬度

xhj пре 2 година
родитељ
комит
4e79098485
3 измењених фајлова са 191 додато и 3 уклоњено
  1. 66 0
      office/comments/comments.vue
  2. 65 2
      office/detail/detail.vue
  3. 60 1
      office/vote/vote.vue

+ 66 - 0
office/comments/comments.vue

@@ -68,6 +68,10 @@ export default {
 			checkPositionIndex: '' ,//选中的下标
 			checkItm: '',
 			commentIds: '',//二级评论id
+			
+			location: {},
+			poiIndex: -1,
+			poiList: [],
 		};
 	},
 	onLoad(opt) {
@@ -77,12 +81,54 @@ export default {
 		}
 		this.getComments()
 		this.getUpdateIsSee();
+		QQMapWX.initMap();
+		let location = {
+			latitude: req.getStorage('loctionAddressMap').location.lat,
+			longitude: req.getStorage('loctionAddressMap').location.lng
+		}
+		QQMapWX.reverseGeocoder(location, data => {
+			this.poiList = data.pois;
+			this.checkLocation(this.poiList[0],0)
+		});
 	},
 
 	onShow() {
 	},
 
 	methods: {
+		chooseLocation(){
+			let that = this;
+			uni.chooseLocation({//choosePoi不返回经纬度
+				success: function (res) {
+					console.log('位置名称:' , res);
+					that.location = {
+						poiName: res.name,
+						poiAddress: res.address,
+						poiLongitude: res.longitude,
+						poiLatitude: res.latitude
+					}
+					that.reverseGeocoder(res);
+				}
+			});
+		},
+		reverseGeocoder(location) {
+			QQMapWX.initMap();
+			QQMapWX.reverseGeocoder(location, data => {
+				this.location.poiRegionalism = data.ad_info.adcode.substring(0, 2) + "0000," + data.ad_info.adcode.substring(0, 4) +"00," + data.ad_info.adcode
+				console.log('解析后的地址地址数据:', data,this.location.poiRegionalism);
+			});
+		},
+		checkLocation(item,index){
+			if(this.poiIndex == index) return false;
+			this.poiIndex = index;
+			this.location = {
+				poiName: item.title,
+				poiAddress: item.address,
+				poiLongitude: item.location.lng,
+				poiLatitude: item.location.lat,
+				poiRegionalism: item.ad_info.adcode.substring(0, 2) + "0000," + item.ad_info.adcode.substring(0, 4) +"00," + item.ad_info.adcode
+			}
+		},
 		getUpdateIsSee(){
 			let params = {
 				id: this.commentId
@@ -114,6 +160,16 @@ export default {
 			dataP.type = type; //1,观看 ,2点赞,3评论,4分享,5收藏
 			dataP.pid = pid;
 			dataP.momentsId = this.params.momentsId;
+			
+			// 位置
+			if(this.location&&this.location.poiName){
+				dataP.poiName = this.location.poiName;
+				dataP.poiAddress = this.location.poiAddress;
+				dataP.poiLongitude = this.location.poiLongitude;
+				dataP.poiLatitude = this.location.poiLatitude;
+				dataP.poiRegionalism = this.location.poiRegionalism
+			}
+			
 			req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
 				this.params.isPraise = 1
 			});
@@ -160,6 +216,16 @@ export default {
 				dataP.toUserId = this.checkUserDTO.id;
 			}
 			dataP.momentsId = this.params.momentsId;
+			
+			// 位置
+			if(this.location&&this.location.poiName){
+				dataP.poiName = this.location.poiName;
+				dataP.poiAddress = this.location.poiAddress;
+				dataP.poiLongitude = this.location.poiLongitude;
+				dataP.poiLatitude = this.location.poiLatitude;
+				dataP.poiRegionalism = this.location.poiRegionalism
+			}
+			
 			req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
 				req.msg('评论成功');
 				this.hideReply();

+ 65 - 2
office/detail/detail.vue

@@ -276,7 +276,11 @@ export default {
 			videoContext: '',
 			config: {},
 			pois: '',
-			currentPoi: {}
+			currentPoi: {},
+			
+			location: {},
+			poiIndex: -1,
+			poiList: [],
 		};
 	},
 	onLoad(opt) {
@@ -314,6 +318,16 @@ export default {
 			});
 		}
 		this.getCommentList();
+		
+		QQMapWX.initMap();
+		let location = {
+			latitude: req.getStorage('loctionAddressMap').location.lat,
+			longitude: req.getStorage('loctionAddressMap').location.lng
+		}
+		QQMapWX.reverseGeocoder(location, data => {
+			this.poiList = data.pois;
+			this.checkLocation(this.poiList[0],0)
+		});
 	},
 	onShow() {
 		this.config = JSON.parse(req.getStorage('configRes'))
@@ -341,6 +355,39 @@ export default {
 	},
 
 	methods: {
+		chooseLocation(){
+			let that = this;
+			uni.chooseLocation({//choosePoi不返回经纬度
+				success: function (res) {
+					console.log('位置名称:' , res);
+					that.location = {
+						poiName: res.name,
+						poiAddress: res.address,
+						poiLongitude: res.longitude,
+						poiLatitude: res.latitude
+					}
+					that.reverseGeocoder(res);
+				}
+			});
+		},
+		reverseGeocoder(location) {
+			QQMapWX.initMap();
+			QQMapWX.reverseGeocoder(location, data => {
+				this.location.poiRegionalism = data.ad_info.adcode.substring(0, 2) + "0000," + data.ad_info.adcode.substring(0, 4) +"00," + data.ad_info.adcode
+				console.log('解析后的地址地址数据:', data,this.location.poiRegionalism);
+			});
+		},
+		checkLocation(item,index){
+			if(this.poiIndex == index) return false;
+			this.poiIndex = index;
+			this.location = {
+				poiName: item.title,
+				poiAddress: item.address,
+				poiLongitude: item.location.lng,
+				poiLatitude: item.location.lat,
+				poiRegionalism: item.ad_info.adcode.substring(0, 2) + "0000," + item.ad_info.adcode.substring(0, 4) +"00," + item.ad_info.adcode
+			}
+		},
 		removeHtml(content) {
 			return util.removeHtml(content);
 		},
@@ -464,7 +511,7 @@ export default {
 				if (this.isNews) {
 					this.getUpdateIsSee();
 				}
-				req.saveBehaviorNew(item.id,this.detail.pollId?10:11,4)
+				req.saveBehaviorNew(this.detail.pollId,this.detail.pollId?10:11,4)
 			});
 		},
 		getUpdateIsSee() {
@@ -520,6 +567,14 @@ export default {
 				dataP.pid = pid;
 			}
 			dataP.momentsId = this.contentId;
+			// 位置
+			if(this.location&&this.location.poiName){
+				dataP.poiName = this.location.poiName;
+				dataP.poiAddress = this.location.poiAddress;
+				dataP.poiLongitude = this.location.poiLongitude;
+				dataP.poiLatitude = this.location.poiLatitude;
+				dataP.poiRegionalism = this.location.poiRegionalism
+			}
 			req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
 				if (type == 2) {
 					//点赞
@@ -582,6 +637,14 @@ export default {
 			}
 			dataP.momentsId = this.contentId;
 			this.isSubmit = true;
+			// 位置
+			if(this.location&&this.location.poiName){
+				dataP.poiName = this.location.poiName;
+				dataP.poiAddress = this.location.poiAddress;
+				dataP.poiLongitude = this.location.poiLongitude;
+				dataP.poiLatitude = this.location.poiLatitude;
+				dataP.poiRegionalism = this.location.poiRegionalism
+			}
 			// await requsetmessage.remindIntegral().then(res => {});
 			req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
 				this.detail.count.commentCount++;

+ 60 - 1
office/vote/vote.vue

@@ -31,6 +31,7 @@
 
 <script>
 const req = require('../../utils/request.js');
+const QQMapWX = require("../../utils/qqmap.js");
 export default {
 	data() {
 		return {
@@ -38,7 +39,11 @@ export default {
 			endTime: '',
 			pollId: '',
 			optionList: [], //投票项
-			optionListResut: [] //最终确认有值的投票项
+			optionListResut: [], //最终确认有值的投票项
+			
+			location: {},
+			poiIndex: -1,
+			poiList: [],
 		};
 	},
 	onLoad(opt) {
@@ -59,8 +64,52 @@ export default {
 				this.optionList = JSON.parse(pollObj.optionJson);
 			}
 		}
+		
+		QQMapWX.initMap();
+		let location = {
+			latitude: req.getStorage('loctionAddressMap').location.lat,
+			longitude: req.getStorage('loctionAddressMap').location.lng
+		}
+		QQMapWX.reverseGeocoder(location, data => {
+			this.poiList = data.pois;
+			this.checkLocation(this.poiList[0],0)
+		});
 	},
 	methods: {
+		chooseLocation(){
+			let that = this;
+			uni.chooseLocation({//choosePoi不返回经纬度
+				success: function (res) {
+					console.log('位置名称:' , res);
+					that.location = {
+						poiName: res.name,
+						poiAddress: res.address,
+						poiLongitude: res.longitude,
+						poiLatitude: res.latitude
+					}
+					that.reverseGeocoder(res);
+				}
+			});
+		},
+		reverseGeocoder(location) {
+			QQMapWX.initMap();
+			QQMapWX.reverseGeocoder(location, data => {
+				this.location.poiRegionalism = data.ad_info.adcode.substring(0, 2) + "0000," + data.ad_info.adcode.substring(0, 4) +"00," + data.ad_info.adcode
+				console.log('解析后的地址地址数据:', data,this.location.poiRegionalism);
+			});
+		},
+		checkLocation(item,index){
+			if(this.poiIndex == index) return false;
+			this.poiIndex = index;
+			this.location = {
+				poiName: item.title,
+				poiAddress: item.address,
+				poiLongitude: item.location.lng,
+				poiLatitude: item.location.lat,
+				poiRegionalism: item.ad_info.adcode.substring(0, 2) + "0000," + item.ad_info.adcode.substring(0, 4) +"00," + item.ad_info.adcode
+			}
+		},
+		
 		//不设置投票
 		noVote() {
 			this.selectedBack('');
@@ -125,6 +174,16 @@ export default {
 				req.msg('投票必须超过2个选项');
 				return;
 			}
+			
+			// 位置
+			if(this.location&&this.location.poiName){
+				dataP.poiName = this.location.poiName;
+				dataP.poiAddress = this.location.poiAddress;
+				dataP.poiLongitude = this.location.poiLongitude;
+				dataP.poiLatitude = this.location.poiLatitude;
+				dataP.poiRegionalism = this.location.poiRegionalism
+			}
+			
 			req.postRequest('/api/v3/poll/save', dataP, data => {
 				req.msg('投票保存成功');
 				setTimeout(() => {