master
lion 4 years ago
commit 46284bdb37

@ -27,6 +27,9 @@ import uView from "uview-ui";
Vue.use(uView); Vue.use(uView);
import util from "@/utils/util"; import util from "@/utils/util";
Vue.prototype.util = util; Vue.prototype.util = util;
import gcoord from "@/utils/gcoord.js";
Vue.prototype.gcoord = gcoord;
import {VueJsonp} from 'vue-jsonp' //中间有忘记大括号出现install undefind问题 import {VueJsonp} from 'vue-jsonp' //中间有忘记大括号出现install undefind问题
Vue.use(VueJsonp) Vue.use(VueJsonp)

@ -145,7 +145,7 @@
this.$refs.uForm.setRules(this.rules); this.$refs.uForm.setRules(this.rules);
let that = this; let that = this;
uni.getLocation({ uni.getLocation({
type: "gcj02", type: "wgs84",
geocode: true, geocode: true,
success(res) { success(res) {
@ -164,9 +164,13 @@
longitude = res.longitude; longitude = res.longitude;
} }
let _latlog = that.gcoord.transformFromWGSToGCJ(latitude, longitude);
const url = const url =
"https://apis.map.qq.com/ws/geocoder/v1/?key=EUQBZ-MJALU-WZFVR-2HFNW-TIK2K-TNBJI&location=" + "https://apis.map.qq.com/ws/geocoder/v1/?key=EUQBZ-MJALU-WZFVR-2HFNW-TIK2K-TNBJI&location=" +
latitude + "," + longitude + "&output=jsonp" _latlog.latitude + "," + _latlog.longitude + "&output=jsonp"
that.$jsonp( that.$jsonp(
url url
).then(re => { ).then(re => {

@ -1,7 +1,7 @@
<template> <template>
<view class="content"> <view class="content">
<view> <view>
所属道路{{roadName}} 所属道路{{roadName}}
</view> </view>
<u-form :model="form" ref="uForm"> <u-form :model="form" ref="uForm">
<u-form-item label="问题类型" label-position="top" prop="typeName" required> <u-form-item label="问题类型" label-position="top" prop="typeName" required>
@ -45,7 +45,7 @@
return { return {
otherData: { otherData: {
token: "" token: ""
}, },
roadName:"", roadName:"",
unitshow: false, unitshow: false,
typeshow: false, typeshow: false,
@ -99,10 +99,10 @@
if(options.id){ if(options.id){
this.infoId = options.id; this.infoId = options.id;
this.showInfo(this.infoId); this.showInfo(this.infoId);
} }
if(options.roadid){ if(options.roadid){
this.form.road_id = options.roadid this.form.road_id = options.roadid
this.roadName = options.roadname this.roadName = options.roadname
} }
this.action = this.util.HOST + "/api/mobile/upload-file"; this.action = this.util.HOST + "/api/mobile/upload-file";
this.otherData.token = uni.getStorageSync("userInfo_token").access_token; this.otherData.token = uni.getStorageSync("userInfo_token").access_token;
@ -112,24 +112,27 @@
this.$refs.uForm.setRules(this.rules); this.$refs.uForm.setRules(this.rules);
let that = this; let that = this;
uni.getLocation({ uni.getLocation({
type: "gcj02", type: "wgs84",
success(res) { success(res) {
that.location = res; that.location = res;
var loc = null var loc = null
console.log(typeof(window.android)) console.log(typeof(window.android))
if (typeof(window.android) != undefined && typeof(window.android) != "undefined") { if (typeof(window.android) != undefined && typeof(window.android) != "undefined") {
loc = window.android.getLocInfo(); loc = window.android.getLocInfo();
} }
if (loc) { if (loc) {
that.form.latitude = JSON.parse(loc).lat; that.form.latitude = JSON.parse(loc).lat;
that.form.longitude = JSON.parse(loc).lon; that.form.longitude = JSON.parse(loc).lon;
} else { } else {
that.form.latitude = res.latitude; that.form.latitude = res.latitude;
that.form.longitude = res.longitude; that.form.longitude = res.longitude;
} }
const url =
"https://apis.map.qq.com/ws/geocoder/v1/?key=EUQBZ-MJALU-WZFVR-2HFNW-TIK2K-TNBJI&location=" +
that.form.latitude + "," + that.form.longitude + "&output=jsonp" let _latlog= that.gcoord.transformFromWGSToGCJ(that.form.latitude,that.form.longitude);
const url =
"https://apis.map.qq.com/ws/geocoder/v1/?key=EUQBZ-MJALU-WZFVR-2HFNW-TIK2K-TNBJI&location=" +
_latlog.latitude + "," + _latlog.longitude + "&output=jsonp"
that.$jsonp( that.$jsonp(
url url
@ -219,7 +222,7 @@
that.form = result; that.form = result;
that.form.typeName = result.ask_type_detail.value; that.form.typeName = result.ask_type_detail.value;
that.form.contentName = result.ask_content_detail.value; that.form.contentName = result.ask_content_detail.value;
that.form.unitName = result.feedback_department.name that.form.unitName = result.feedback_department.name
that.roadName = result.road?result.road.name:"" that.roadName = result.road?result.road.name:""
let _files = []; let _files = [];
for (var mod of result.common_inspection_files) { for (var mod of result.common_inspection_files) {

@ -129,7 +129,7 @@
this.$refs.uForm.setRules(this.rules); this.$refs.uForm.setRules(this.rules);
let that = this; let that = this;
uni.getLocation({ uni.getLocation({
type: "gcj02", type: "wgs84",
geocode: true, geocode: true,
success(res) { success(res) {
var loc = null var loc = null
@ -143,10 +143,13 @@
} else { } else {
that.form.deal_latitude = res.latitude; that.form.deal_latitude = res.latitude;
that.form.deal_longitude = res.longitude; that.form.deal_longitude = res.longitude;
} }
let _latlog= that.gcoord.transformFromWGSToGCJ(that.form.latitude,that.form.longitude);
const url = const url =
"https://apis.map.qq.com/ws/geocoder/v1/?key=EUQBZ-MJALU-WZFVR-2HFNW-TIK2K-TNBJI&location=" + "https://apis.map.qq.com/ws/geocoder/v1/?key=EUQBZ-MJALU-WZFVR-2HFNW-TIK2K-TNBJI&location=" +
that.form.deal_latitude + "," + that.form.deal_longitude + "&output=jsonp" _latlog.latitude + "," + _latlog.longitude + "&output=jsonp"
that.$jsonp( that.$jsonp(
@ -345,10 +348,12 @@
}, },
chooseLocation(e) { // chooseLocation(e) { //
var that = this; var that = this;
let _latlog= that.gcoord.transformFromWGSToGCJ(that.form.deal_latitude,that.form.deal_longitude);
uni.chooseLocation({ uni.chooseLocation({
longitude: that.form.deal_longitude, longitude: _latlog.longitude,
latitude: that.form.deal_latitude, latitude: _latlog.latitude,
success: res => { success: res => {
that.form.address = res.name; that.form.address = res.name;
that.form.deal_longitude = res.longitude; that.form.deal_longitude = res.longitude;
@ -372,4 +377,4 @@
color: #fff; color: #fff;
padding: 20rpx 30rpx; padding: 20rpx 30rpx;
} }
</style> </style>

@ -16,6 +16,7 @@
{{typeName}} {{typeName}}
</view> </view>
</u-form-item> </u-form-item>
<block v-if='formshow'> <block v-if='formshow'>
<u-form-item label="巡查内容" label-position="top" prop="type" required> <u-form-item label="巡查内容" label-position="top" prop="type" required>
<u-input placeholder="请选择巡查内容" v-model="askName" type="select" :border="true" <u-input placeholder="请选择巡查内容" v-model="askName" type="select" :border="true"
@ -91,7 +92,8 @@
<view v-if="!formshow"> <view v-if="!formshow">
<u-form-item labelWidth="180" label-position="left" label="是否违法"> <u-form-item labelWidth="180" label-position="left" label="是否违法">
<u-radio-group v-model="form.is_law"> <u-radio-group v-model="form.is_law">
<u-radio @change="lawRadioChange" v-for="(item, index) in rainArr.laws" :key="index" :name="item.id"> <u-radio @change="lawRadioChange" v-for="(item, index) in rainArr.laws" :key="index"
:name="item.id">
{{item.name}} {{item.name}}
</u-radio> </u-radio>
</u-radio-group> </u-radio-group>
@ -173,6 +175,7 @@
export default { export default {
data() { data() {
return { return {
location: "",
otherData: { otherData: {
token: "" token: ""
}, },
@ -258,9 +261,9 @@
form: { form: {
road_id: '', road_id: '',
content: "", content: "",
ask_content_id: "", ask_content_id: "",
scope:"", scope: "",
point_name:"", point_name: "",
is_unusual: 0, is_unusual: 0,
is_scene: 0, is_scene: 0,
result: "", result: "",
@ -288,9 +291,8 @@
build_unit:"", build_unit:"",
carry_unit:"" carry_unit:""
}, },
rules: { rules: {
}, },
apis: { apis: {
store: [ store: [
@ -324,9 +326,9 @@
this.form.road_id = options.roadid this.form.road_id = options.roadid
this.roadName = options.roadname this.roadName = options.roadname
} }
if(options.orderId){ if (options.orderId) {
this.form.mobile_worksheet_id = options.orderId this.form.mobile_worksheet_id = options.orderId
} }
console.log(this.form.mobile_worksheet_id) console.log(this.form.mobile_worksheet_id)
this.action = this.util.HOST + "/api/mobile/upload-file"; this.action = this.util.HOST + "/api/mobile/upload-file";
this.otherData.token = uni.getStorageSync("userInfo_token").access_token; this.otherData.token = uni.getStorageSync("userInfo_token").access_token;
@ -335,7 +337,7 @@
this.$refs.uForm.setRules(this.rules); this.$refs.uForm.setRules(this.rules);
let that = this; let that = this;
uni.getLocation({ uni.getLocation({
type: "gcj02", type: "wgs84",
geocode: true, geocode: true,
success(res) { success(res) {
var loc = null var loc = null
@ -358,9 +360,15 @@
that.form.end_latitude = res.latitude; that.form.end_latitude = res.latitude;
that.form.end_longitude = res.longitude; that.form.end_longitude = res.longitude;
} }
let _latlog= that.gcoord.transformFromWGSToGCJ(that.form.latitude,that.form.longitude);
const url = const url =
"https://apis.map.qq.com/ws/geocoder/v1/?key=EUQBZ-MJALU-WZFVR-2HFNW-TIK2K-TNBJI&location=" + "https://apis.map.qq.com/ws/geocoder/v1/?key=EUQBZ-MJALU-WZFVR-2HFNW-TIK2K-TNBJI&location=" +
that.form.latitude + "," + that.form.longitude + "&output=jsonp" _latlog.latitude + "," + _latlog.longitude + "&output=jsonp"
that.$jsonp( that.$jsonp(
url url
).then(re => { ).then(re => {
@ -388,13 +396,13 @@
// } // }
}, },
lawRadioChange(val){ lawRadioChange(val) {
console.log(val) console.log(val)
if(val==0){ if (val == 0) {
this.form.break_id="" this.form.break_id = ""
this.lawName = "" this.lawName = ""
} }
}, },
confirmBuildTypeName(val) { confirmBuildTypeName(val) {
console.log(val) console.log(val)
@ -405,11 +413,11 @@
confirmBuildType(val) { confirmBuildType(val) {
var that = this var that = this
console.log(val) console.log(val)
if (!val[0].value) { if (!val[0].value) {
this.$refs.uForm.resetFields(); this.$refs.uForm.resetFields();
that.buildtypeName="" that.buildtypeName = ""
that.form.name = that.buildName that.form.name = that.buildName
let timeNumber = new Date().getTime() let timeNumber = new Date().getTime()
that.form.number = timeNumber that.form.number = timeNumber
return return
} }
@ -479,10 +487,14 @@
console.log("res", that.form) console.log("res", that.form)
}, },
chooseLocation(e) { // chooseLocation(e) { //
var that = this; var that = this;
let _latlog= that.gcoord.transformFromWGSToGCJ(that.form.latitude,that.form.longitude);
uni.chooseLocation({ uni.chooseLocation({
longitude: that.form.longitude, longitude: _latlog.longitude,
latitude: that.form.latitude, latitude: _latlog.latitude,
success: res => { success: res => {
that.form.address = res.name; that.form.address = res.name;
that.form.longitude = res.longitude; that.form.longitude = res.longitude;
@ -504,9 +516,10 @@
}, },
chooseStartLocation(e) { // chooseStartLocation(e) { //
var that = this; var that = this;
let s_latlog= that.gcoord.transformFromWGSToGCJ(that.form.start_latitude,that.form.start_longitude);
uni.chooseLocation({ uni.chooseLocation({
longitude: that.form.start_longitude, longitude: s_latlog.longitude,
latitude: that.form.start_latitude, latitude: s_latlog.latitude,
success: res => { success: res => {
that.form.start_address = res.name; that.form.start_address = res.name;
that.form.start_longitude = res.longitude; that.form.start_longitude = res.longitude;
@ -516,9 +529,11 @@
}, },
chooseEndLocation(e) { // chooseEndLocation(e) { //
var that = this; var that = this;
let e_latlog= that.gcoord.transformFromWGSToGCJ(that.form.end_latitude,that.form.end_longitude);
uni.chooseLocation({ uni.chooseLocation({
longitude: that.form.end_longitude, longitude: e_latlog.end_longitude,
latitude: that.form.end_latitude, latitude: e_latlog.end_latitude,
success: res => { success: res => {
that.form.end_address = res.name; that.form.end_address = res.name;
that.form.end_longitude = res.longitude; that.form.end_longitude = res.longitude;
@ -783,8 +798,8 @@
} }
} }
that.form.files_list = list; that.form.files_list = list;
that.form.files_end_list = deallist; that.form.files_end_list = deallist;
console.log(that.form) console.log(that.form)
// return // return
let api = ""; let api = "";
if (this.infoId) { if (this.infoId) {
@ -860,4 +875,4 @@
color: #fff; color: #fff;
padding: 20rpx 30rpx; padding: 20rpx 30rpx;
} }
</style> </style>

@ -194,7 +194,7 @@
address: "", address: "",
scope: "", scope: "",
point_name: "", point_name: "",
title_id: "", title_id: "",
mobile_worksheet_id:"" mobile_worksheet_id:""
}, },
rules: { rules: {
@ -249,9 +249,9 @@
if (options.roadid) { if (options.roadid) {
this.form.road_id = options.roadid this.form.road_id = options.roadid
this.roadName = options.roadname this.roadName = options.roadname
} }
if(options.orderId){ if(options.orderId){
this.form.mobile_worksheet_id = options.orderId this.form.mobile_worksheet_id = options.orderId
} }
that.loadAskContent(); that.loadAskContent();
@ -263,7 +263,7 @@
this.$refs.uForm.setRules(this.rules); this.$refs.uForm.setRules(this.rules);
let that = this; let that = this;
uni.getLocation({ uni.getLocation({
type: "gcj02", type: "wgs84",
geocode: true, geocode: true,
success(res) { success(res) {
var loc = null var loc = null
@ -277,10 +277,14 @@
} else { } else {
that.form.latitude = res.latitude; that.form.latitude = res.latitude;
that.form.longitude = res.longitude; that.form.longitude = res.longitude;
} }
let _latlog= that.gcoord.transformFromWGSToGCJ(that.form.latitude,that.form.longitude);
const url = const url =
"https://apis.map.qq.com/ws/geocoder/v1/?key=EUQBZ-MJALU-WZFVR-2HFNW-TIK2K-TNBJI&location=" + "https://apis.map.qq.com/ws/geocoder/v1/?key=EUQBZ-MJALU-WZFVR-2HFNW-TIK2K-TNBJI&location=" +
that.form.latitude + "," + that.form.longitude + "&output=jsonp" _latlog.latitude + "," + _latlog.longitude + "&output=jsonp"
that.$jsonp( that.$jsonp(
url url
).then(re => { ).then(re => {
@ -358,10 +362,11 @@
}); });
}, },
chooseLocation(e) { // chooseLocation(e) { //
var that = this; var that = this;
let _latlog= that.gcoord.transformFromWGSToGCJ(that.form.latitude,that.form.longitude);
uni.chooseLocation({ uni.chooseLocation({
longitude: that.form.longitude, longitude:_latlog.longitude,
latitude: that.form.latitude, latitude: _latlog.latitude,
success: res => { success: res => {
that.form.address = res.name; that.form.address = res.name;
that.form.longitude = res.longitude; that.form.longitude = res.longitude;
@ -656,4 +661,4 @@
color: #fff; color: #fff;
padding: 20rpx 30rpx; padding: 20rpx 30rpx;
} }
</style> </style>

@ -57,7 +57,7 @@
showClear: false, showClear: false,
totype: "", totype: "",
road_id: "", road_id: "",
road_name: "", road_name: "",
orderId:"" orderId:""
} }
@ -77,13 +77,13 @@
}, },
onLoad(options) { onLoad(options) {
let that = this; let that = this;
that.totype = options.type; that.totype = options.type;
that.orderId = options.orderId?options.orderId:"" that.orderId = options.orderId?options.orderId:""
uni.getLocation({ uni.getLocation({
type: "gcj02", type: "wgs84",
geocode: true, geocode: true,
success(res) { success(res) {
var loc = null var loc = null
console.log(typeof(window.android)) console.log(typeof(window.android))
if (typeof(window.android)!=undefined&&typeof(window.android)!="undefined") { if (typeof(window.android)!=undefined&&typeof(window.android)!="undefined") {
loc = window.android.getLocInfo(); loc = window.android.getLocInfo();
@ -334,4 +334,4 @@
} }
} }
} }
</style> </style>

@ -0,0 +1,167 @@
/**
* 判断经纬度是否超出中国境内
*/
function isLocationOutOfChina(latitude, longitude) {
if (longitude < 72.004 || longitude > 137.8347 || latitude < 0.8293 || latitude > 55.8271)
return true;
return false;
}
/**
* 将WGS-84(国际标准)转为GCJ-02(火星坐标):
*/
function transformFromWGSToGCJ(latitude, longitude) {
var lat = "";
var lon = "";
var ee = 0.00669342162296594323;
var a = 6378245.0;
var pi = 3.14159265358979324;
if (isLocationOutOfChina(latitude, longitude)) {
lat = latitude;
lon = longitude;
} else {
var adjustLat = transformLatWithXY(longitude - 105.0, latitude - 35.0);
var adjustLon = transformLonWithXY(longitude - 105.0, latitude - 35.0);
var radLat = latitude / 180.0 * pi;
var magic = Math.sin(radLat);
magic = 1 - ee * magic * magic;
var sqrtMagic = Math.sqrt(magic);
adjustLat = (adjustLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
adjustLon = (adjustLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
latitude = latitude + adjustLat;
longitude = longitude + adjustLon;
}
return {
latitude: latitude,
longitude: longitude
};
}
/**
* 将GCJ-02(火星坐标)转为百度坐标:
*/
function transformFromGCJToBaidu(latitude, longitude) {
var pi = 3.14159265358979324 * 3000.0 / 180.0;
var z = Math.sqrt(longitude * longitude + latitude * latitude) + 0.00002 * Math.sin(latitude * pi);
var theta = Math.atan2(latitude, longitude) + 0.000003 * Math.cos(longitude * pi);
var a_latitude = (z * Math.sin(theta) + 0.006);
var a_longitude = (z * Math.cos(theta) + 0.0065);
return {
latitude: a_latitude,
longitude: a_longitude
};
}
/**
* 将百度坐标转为GCJ-02(火星坐标):
*/
function transformFromBaiduToGCJ(latitude, longitude) {
var xPi = 3.14159265358979323846264338327950288 * 3000.0 / 180.0;
var x = longitude - 0.0065;
var y = latitude - 0.006;
var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * xPi);
var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * xPi);
var a_latitude = z * Math.sin(theta);
var a_longitude = z * Math.cos(theta);
return {
latitude: a_latitude,
longitude: a_longitude
};
}
/**
* 将GCJ-02(火星坐标)转为WGS-84:
*/
function transformFromGCJToWGS(latitude, longitude) {
var threshold = 0.00001;
// The boundary
var minLat = latitude - 0.5;
var maxLat = latitude + 0.5;
var minLng = longitude - 0.5;
var maxLng = longitude + 0.5;
var delta = 1;
var maxIteration = 30;
while (true) {
var leftBottom = transformFromWGSToGCJ(minLat, minLng);
var rightBottom = transformFromWGSToGCJ(minLat, maxLng);
var leftUp = transformFromWGSToGCJ(maxLat, minLng);
var midPoint = transformFromWGSToGCJ((minLat + maxLat) / 2, (minLng + maxLng) / 2);
delta = Math.abs(midPoint.latitude - latitude) + Math.abs(midPoint.longitude - longitude);
if (maxIteration-- <= 0 || delta <= threshold) {
return {
latitude: (minLat + maxLat) / 2,
longitude: (minLng + maxLng) / 2
};
}
if (isContains({
latitude: latitude,
longitude: longitude
}, leftBottom, midPoint)) {
maxLat = (minLat + maxLat) / 2;
maxLng = (minLng + maxLng) / 2;
} else if (isContains({
latitude: latitude,
longitude: longitude
}, rightBottom, midPoint)) {
maxLat = (minLat + maxLat) / 2;
minLng = (minLng + maxLng) / 2;
} else if (isContains({
latitude: latitude,
longitude: longitude
}, leftUp, midPoint)) {
minLat = (minLat + maxLat) / 2;
maxLng = (minLng + maxLng) / 2;
} else {
minLat = (minLat + maxLat) / 2;
minLng = (minLng + maxLng) / 2;
}
}
}
function isContains(point, p1, p2) {
return (point.latitude >= Math.min(p1.latitude, p2.latitude) && point.latitude <= Math.max(p1.latitude, p2
.latitude)) && (point.longitude >= Math.min(p1.longitude, p2.longitude) && point.longitude <= Math.max(p1
.longitude, p2.longitude));
}
function transformLatWithXY(x, y) {
var pi = 3.14159265358979324;
var lat = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
lat += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
lat += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
lat += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
return lat;
}
function transformLonWithXY(x, y) {
var pi = 3.14159265358979324;
var lon = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
lon += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
lon += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
lon += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0;
return lon;
}
module.exports = {
isLocationOutOfChina: isLocationOutOfChina,
transformFromWGSToGCJ: transformFromWGSToGCJ,
transformFromGCJToBaidu: transformFromGCJToBaidu,
transformFromBaiduToGCJ: transformFromBaiduToGCJ,
transformFromGCJToWGS: transformFromGCJToWGS
}
Loading…
Cancel
Save