From 93dade2fc9c58d69b2fe2361675b9d9647e5c130 Mon Sep 17 00:00:00 2001
From: liuyg <liuyg@qq.com>
Date: Sat, 19 Feb 2022 10:51:52 +0800
Subject: [PATCH] +任务发布地图和列表更改逻辑和字段

---
 leafletMapOur/grabOrdersMap/js/vueMain.js |  210 ++++++++++++++++++++++++++--------------------------
 1 files changed, 104 insertions(+), 106 deletions(-)

diff --git a/leafletMapOur/grabOrdersMap/js/vueMain.js b/leafletMapOur/grabOrdersMap/js/vueMain.js
index 0284b82..99be971 100644
--- a/leafletMapOur/grabOrdersMap/js/vueMain.js
+++ b/leafletMapOur/grabOrdersMap/js/vueMain.js
@@ -32,35 +32,28 @@
 		oldlat: '',
 		oldlng: '',
 		haveJDWD: true,
-		data: {}
-		// {
-		// 	type: 0,
-		// 	city: "南昌市",
-		// 	content: "按路线巡逻",
-		// 	district: "青山湖区",
-		// 	id: 5,
-		// 	integral: "14",
-		// 	jnum: 2,
-		// 	line: "LINESTRING(115.88518439579809 28.67705200351289,115.89115548582284 28.677382855466767,115.89148633777671 28.675523782583074,115.88565704144649 28.675145666064356,115.88521590550799 28.67700473894805,115.88521590550799 28.67700473894805)",
-		// 	num: 0,
-		// 	province: "江西省",
-		// 	raddress: null,
-		// 	rname: "巡逻任务",
-		// 	rtype: "0",
-		// 	serid: null,
-		// 	time: "2021-11-17 00:00:00",
-		// 	url: "http://223.82.109.183:2081/zhba/upload/20211102/07fe327a76a43fa8d3431c73febade22.jpg",
-		// }
+		data: {},
+
+		mapPositionLoding: false, //定位loding
+		oncePosition: null, //一次定位实例
+		onPosition: false, //持续定位指示
 	},
 	methods: {
 		openAPP(type) {
 			// console.log(type)
 			let that = this;
 			if (type != 1) {
-				//反馈
-				uni.navigateTo({
-					url: '/pages/grabOrders/feedback?data=' + JSON.stringify(this.data)
-				});
+				if (that.data.butCT == "beginUp") {
+					// 反馈
+					uni.navigateTo({
+						url: '/pages/grabOrders/feedback?data=' + JSON.stringify(this.data)
+					});
+				} else if (that.data.butCT == "begin") {
+					// 开始任务
+					// uni.navigateTo({
+					// 	url: '/pages/grabOrders/feedback?data=' + JSON.stringify(this.data)
+					// });
+				}
 			} else {
 				this.$confirm('是否参与活动:' + this.data.rname + "?", '提示', {
 					confirmButtonText: '确定',
@@ -69,50 +62,30 @@
 					center: true,
 					customClass: "customClass"
 				}).then(() => {
-					let url = "http://223.82.109.183:2082/api" + "/taskqd/Graborder",
+					let url = that.data.appenUrl + "taskqd/Graborder",
 						dataAppend = that.data;
-					axios.post(url, dataAppend).then(res => {
-						// console.log(res);
-						if (res.data.msg == "抢单成功") {
-							that.data.type = 0;
-							that.$message({
-								message: res.data.msg,
-								type: 'success'
-							});
-							return;
-						}
-						that.$message({
-							message: res.data.msg,
-							type: 'warning'
-						});
-					})
+					console.log(url, dataAppend)
+					// axios.post(url, dataAppend).then(res => {
+					// 	// console.log(res);
+					// 	if (res.data.msg == "抢单成功") {
+					// 		that.data.type = 0;
+					// 		that.$message({
+					// 			message: res.data.msg,
+					// 			type: 'success'
+					// 		});
+					// 		return;
+					// 	}
+					// 	that.$message({
+					// 		message: res.data.msg,
+					// 		type: 'warning'
+					// 	});
+					// })
 				}).catch(() => {
 					// this.$message({
 					// 	type: 'info',
 					// 	message: '已取消删除'
 					// });
 				});
-				// return;
-				//抢单
-				// console.log(this.data)
-				// let up = this.data.appenUrl == '/api' ? "http://192.168.0.107:85" : this.data.appenUrl;
-				// let url = "http://223.82.109.183:2082/api" + "/taskqd/Graborder",
-				// 	dataAppend = this.data;
-				// axios.post(url, dataAppend).then(res => {
-				// 	console.log(res);
-				// 	if (res.data.msg == "抢单成功") {
-				// 		this.data.type = 0;
-				// 		this.$message({
-				// 			message: res.data.msg,
-				// 			type: 'success'
-				// 		});
-				// 		return;
-				// 	}
-				// 	this.$message({
-				// 		message: res.data.msg,
-				// 		type: 'warning'
-				// 	});
-				// })
 			}
 		},
 		getDataList() {
@@ -121,27 +94,30 @@
 		},
 		beginCome() {
 			var data = {
-				city: "无数据",
-				content: "无数据",
-				district: "无数据",
-				id: 5,
-				integral: "14",
-				jnum: 2,
-				line: "LINESTRING(115.88518439579809 28.67705200351289,115.89115548582284 28.677382855466767,115.89148633777671 28.675523782583074,115.88565704144649 28.675145666064356,115.88521590550799 28.67700473894805,115.88521590550799 28.67700473894805)",
-				num: 2,
-				province: "无数据",
-				raddress: "",
-				rname: "无数据",
+				appenUrl: "http://192.168.0.108:83/",
+				butCT: "begin",
+				buttype: 0,
+				captain: "我",
+				city: "南昌市",
+				content: "测试",
+				district: "西湖区",
+				id: 37,
+				integral: "222",
+				iscation: "0",
+				jnum: 3,
+				line: "LINESTRING(115.8995839881188 28.687205773173343,115.89391916267935 28.678966027079593,115.90404718391959 28.673644524394046,115.91211526863638 28.681369286356936)",
+				num: 1,
+				nums: 0,
+				province: "江西省",
+				publisher: "管理",
+				raddress: null,
+				rname: "测试1",
 				rtype: "0",
 				serid: "1123598821738675201,",
-				time: "无数据",
-				url: "http://223.82.109.183:2081/zhba/upload/20211102/07fe327a76a43fa8d3431c73febade22.jpg",
-				buttype: "1",
-				type: '1',
-				captain: '队长',
-				team: "张三,李四",
-				iscation: '0',
-				publisher: '管理者'
+				team: "你,他,它",
+				time: "2022-02-18 14:15:52",
+				type: "0",
+				url: "http://223.82.109.183:2081/zhba/upload/20220218/67f0c8bf3e7b5024c64133691f265072.ico",
 			}
 			//url解码
 			this.data = this.getQueryVariable('data') || data;
@@ -149,23 +125,12 @@
 				this.data.team = this.data.team.split(',');
 			}
 			console.log(this.data)
-			// this.getdata = data;
-			// this.changeDom(this.getdata[0]);//改变地图高度
-			// console.log(this.getdata[0]);
 			let lines = this.data.line
 			let position = lines.slice(lines.indexOf("(") + 1, lines.indexOf(",")).split(" ");
 			// console.log(position)
 			// return
 			this.map = this.beginMap(this.map, position); //创建并接受map
-			// this.move = new myDomMove('#seedata', '.title', '#map');
 			this.map.invalidateSize(true); //应用地图高度
-			// this.move.followFinger(this.map, 'down');
-			// this.lat = data[0].wd;
-			// this.lng = data[0].jd;
-			// this.oldlat = data[0].wd;
-			// this.oldlng = data[0].jd;
-			// this.oldlat = this.getdata[0].wd;
-			// this.oldlng = this.getdata[0].jd;
 		},
 		changeDom(data) {
 			// console.log(data, 'changeDom');
@@ -368,9 +333,51 @@
 		// },
 		//定位当前位置
 		locationMap() {
-
-			// console.log([this.lat, this.lng])
-			// this.map.setView([this.lat, this.lng], 20);
+			let that = this;
+			if (!this.oncePosition) {
+				this.oncePosition = new $getPositions({
+					id: 1,
+					fn: function(res) {
+						console.log(res);
+						that.mapPositionLoding = res.state;
+						if (!res.state) {
+							that.addIcon(res.intlat);
+						}
+					}
+				}).init();
+			}
+			if (!this.onPosition) {
+				this.oncePosition.continued();
+				this.onPosition = !this.onPosition;
+			} else {
+				this.oncePosition.overContinued();
+				this.onPosition = !this.onPosition;
+			}
+		},
+		//添加图标
+		addIcon(intlat) {
+			var markers = L.markerClusterGroup(),
+				marker;
+			var transportIcon = L.Icon.extend({ //图标初始化
+				options: {
+					iconSize: [30, 30], // 图标尺寸
+				}
+			});
+			var carIcon = new transportIcon({ //引入图标
+				iconUrl: './img/dinw/dinw1.png'
+			});
+			var setData = (a) => { //定义图标
+				marker = L.marker(a, {
+					icon: carIcon,
+					myData: { //自定义数据
+						...a
+					}
+				});
+			}
+			setData(intlat)
+			markers.addLayer(marker);
+			this.map.addLayer(markers);
+			this.map.setView(intlat, this.map._zoom);
 		},
 		toJQposition() {
 			this.map.setView([this.oldlat, this.oldlng], 20);
@@ -393,6 +400,7 @@
 				that.lat = position.lat; //
 				that.lng = position.lng; //火星坐标 //TODO 实现业务代码逻辑 
 				that.haveShishiweizhi++; //控制只执行一次
+				console.log(position)
 				// console.log(that.haveShishiweizhi)
 				if (that.haveShishiweizhi == 2) {
 					// console.log(position)
@@ -543,18 +551,6 @@
 			for (let k in line) {
 				line[k] = line[k].split(" ").reverse();
 			}
-			// console.log(line)
-
-			// var latlngs = [
-			// 	['28.67705200351289', '115.88518439579809'],
-			// 	['28.68755200354289', '115.88518439574809'],
-			// 	['28.68755200354289', '115.85518439574809'],
-			// ]
-			// var polygon = L.polygon(latlngs, {
-			// 	color: '#000eff',
-			// 	fillColor: '#0000ed',
-			// 	weight: 2
-			// });
 			var polyline = L.polyline(line, {
 				color: '#FC5E20'
 			})
@@ -601,7 +597,8 @@
 		this.getDataList();
 		//map适应任务详情高度
 		// console.log(document.getElementById("map"))
-		let UmainHeight = document.getElementById("Umain").clientHeight;
+		//因为按钮使用v-if所以在识别高度时候,but还没渲染所以手动添加 56px 不会变
+		let UmainHeight = document.getElementById("Umain").clientHeight + 56;
 		let h = document.getElementById("mapVue").clientHeight;
 		this.checkDomHeight({
 			domName: "getElementById",
@@ -628,6 +625,7 @@
 			openAnimation: false,
 			fn: function(res) {
 				// console.log(that.map.options)
+
 				document.getElementById("map").style.height = h - res.height + "px";
 				// that.map.setView([that.map.options.center[0], +that.map.options.center[1] + 0.002], that.map
 				// 	.options.zoom);

--
Gitblit v1.9.3