From a51c86649b4ae3ff48ea114a68f83110f4c9a9ed Mon Sep 17 00:00:00 2001 From: ChuShiZ Date: Sun, 29 Sep 2024 19:39:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E4=BD=8D=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/rescue/initiate.vue | 276 +++++++++++++++++++++----------------- 1 file changed, 153 insertions(+), 123 deletions(-) diff --git a/pages/rescue/initiate.vue b/pages/rescue/initiate.vue index ba90910..0e78073 100644 --- a/pages/rescue/initiate.vue +++ b/pages/rescue/initiate.vue @@ -32,7 +32,7 @@ 请选择终点地址 {{province1}}{{city1}}{{area1}} - *必填,请填写详细地址 + @@ -43,7 +43,8 @@ --> - + 救援信息 @@ -56,7 +57,7 @@ - * 联系人 + 联系人 @@ -70,7 +71,7 @@ - * 车牌号 + 车牌号 @@ -83,15 +84,15 @@ - - * 路段选择 - - - {{item.label}} - - - + + * 路段选择 + + + {{item.label}} + + + * 车辆类型 @@ -116,7 +117,8 @@ - + 上传图片 @@ -143,7 +145,8 @@ - + @@ -155,7 +158,10 @@ import request from '../../utils/request' import config from '@/config' import upload from '@/utils/upload.js' - import {getTenantId, hasRole} from "@/utils/auth"; + import { + getTenantId, + hasRole + } from "@/utils/auth"; export default { data() { return { @@ -217,7 +223,7 @@ ], title: '救援', roadOptions: [], - seletedRoad: [], + seletedRoad: [], roadVisible: false } }, @@ -313,7 +319,7 @@ this.shows = false }, roadConfirm(e) { - console.log('e: ',e); + console.log('e: ', e); this.roadVisible = false }, roadCancel() { @@ -340,8 +346,7 @@ }, postadd() { this.rescueSceneImage = this.imageList.join(",") - if (typeof this.rescueTime === "number") { - } else { + if (typeof this.rescueTime === "number") {} else { this.rescueTime = '' } if (this.isAppointment == 'undefined') { @@ -369,21 +374,21 @@ // }) // return // } - // if (!this.licenseNum) { - // uni.showToast({ - // title: '车牌号不能为空', - // icon: 'none' - // }) - // return - // } - // if (this.seletedRoad.length === 0) { - // uni.showToast({ - // title: '未选择路段', - // icon: 'none' - // }) - // return - // } - console.log('this.seletedRoad: ',this.seletedRoad); + // if (!this.licenseNum) { + // uni.showToast({ + // title: '车牌号不能为空', + // icon: 'none' + // }) + // return + // } + // if (this.seletedRoad.length === 0) { + // uni.showToast({ + // title: '未选择路段', + // icon: 'none' + // }) + // return + // } + console.log('this.seletedRoad: ', this.seletedRoad); let data = { rescueLongitude: this.rescueLongitude, @@ -395,7 +400,7 @@ rescuePosition: this.rescuePosition, destinationInfo: this.destinationInfo, licenseNum: this.licenseNum, - roadIds: this.seletedRoad, + roadIds: this.seletedRoad, isAppointment: this.isAppointment, rescueTime: this.rescueTime, rescueDetail: this.rescueDetail, @@ -461,9 +466,9 @@ url: '/common/upload', filePath: res.tempFilePath, }).then((res) => { - console.log('res.fileName', res.data.url) + console.log('res.fileName', res.data.url) this.imageList.push(this.$baseImageUrl + res.data.url) - console.log('this.imageList', this.imageList) + console.log('this.imageList', this.imageList) console.log(res); }) @@ -477,88 +482,113 @@ getmap() { let that = this console.log('选择位置') - uni.chooseLocation({ - success: function(res) { - console.log(res) - console.log('位置名称:' + res.name); - console.log('详细地址:' + res.address); - console.log('纬度:' + res.latitude); - console.log('经度:' + res.longitude); - that.rescueLongitude = res.longitude - that.rescueLatitude = res.latitude - - that.rescuePosition = res.address - var address = res.address; - var reg = /.+?(省|市|自治区|自治州|县|区)/g; - let addressList = address.match(reg).toString().split(","); - if (addressList[0] == '重庆市' || addressList[0] == '北京市' || addressList[0] == '天津市' || - addressList[0] == '上海市') { - that.province = addressList[0]; - that.city = '市辖区'; - that.area = addressList[1]; - that.four = address.replace(that.province, '').replace(that.city, '').replace(that - .area, ''); - } else { - that.province = addressList[0]; - that.city = addressList[1]; - that.area = addressList[2]; - that.four = address.replace(that.province, '').replace(that.city, '').replace(that - .area, ''); - }; - console.log(that.four.indexOf(res.name)); - if (that.four.indexOf(res.name) < 0) { - that.four = that.four + res.name - that.rescuePosition = that.rescuePosition + res.name - } - - }, - fail: (err) => { - console.log(err, 'err') - }, - complete(res) { - console.log(res, 'cpmplete') + uni.getLocation({ + type: 'wgs84', + success: function(getres) { + console.log('当前位置的经度:' + getres.longitude); + console.log('当前位置的纬度:' + getres.latitude); + + uni.chooseLocation({ + latitude: getres.latitude, + longitude: getres.longitude, + success: function(res) { + console.log(res) + console.log('位置名称:' + res.name); + console.log('详细地址:' + res.address); + console.log('纬度:' + res.latitude); + console.log('经度:' + res.longitude); + that.rescueLongitude = res.longitude + that.rescueLatitude = res.latitude + + that.rescuePosition = res.address + var address = res.address; + var reg = /.+?(省|市|自治区|自治州|县|区)/g; + let addressList = address.match(reg).toString().split(","); + if (addressList[0] == '重庆市' || addressList[0] == '北京市' || addressList[0] == '天津市' || + addressList[0] == '上海市') { + that.province = addressList[0]; + that.city = '市辖区'; + that.area = addressList[1]; + that.four = address.replace(that.province, '').replace(that.city, '').replace(that + .area, ''); + } else { + that.province = addressList[0]; + that.city = addressList[1]; + that.area = addressList[2]; + that.four = address.replace(that.province, '').replace(that.city, '').replace(that + .area, ''); + }; + console.log(that.four.indexOf(res.name)); + if (that.four.indexOf(res.name) < 0) { + that.four = that.four + res.name + that.rescuePosition = that.rescuePosition + res.name + } + + }, + fail: (err) => { + console.log(err, 'err') + }, + complete(res) { + console.log(res, 'cpmplete') + } + }); } }); + }, getmap1() { let that = this - uni.chooseLocation({ - success: function(res) { - console.log('位置名称:' + res.name); - console.log('详细地址:' + res.address); - console.log('纬度:' + res.latitude); - console.log('经度:' + res.longitude); - console.log(res) - that.destinationLongitude = res.longitude - that.destinationLatitude = res.latitude - that.destinationInfo = res.address - var address = res.address; - var reg = /.+?(省|市|自治区|自治州|县|区)/g; - let addressList = address.match(reg).toString().split(","); - if (addressList[0] == '重庆市' || addressList[0] == '北京市' || addressList[0] == - '天津市' || - addressList[0] == '上海市') { - that.province1 = addressList[0]; - that.city1 = '市辖区'; - that.area1 = addressList[1]; - that.four1 = address.replace(that.province, '').replace(that.city, '') - .replace(that - .area, ''); - } else { - that.province1 = addressList[0]; - that.city1 = addressList[1]; - that.area1 = addressList[2]; - that.four1 = address.replace(that.province, '').replace(that.city, '') - .replace(that - .area, ''); - }; - console.log(that.four1); + uni.getLocation({ + type: 'wgs84', + success: function(getres) { + console.log('当前位置的经度:' + getres.longitude); + console.log('当前位置的纬度:' + getres.latitude); + uni.chooseLocation({ + latitude: getres.latitude, + longitude: getres.longitude, + success: function(res) { + console.log('位置名称:' + res.name); + console.log('详细地址:' + res.address); + console.log('纬度:' + res.latitude); + console.log('经度:' + res.longitude); + console.log(res) + that.destinationLongitude = res.longitude + that.destinationLatitude = res.latitude + that.destinationInfo = res.address + var address = res.address; + var reg = /.+?(省|市|自治区|自治州|县|区)/g; + let addressList = address.match(reg).toString().split(","); + if (addressList[0] == '重庆市' || addressList[0] == '北京市' || + addressList[0] == + '天津市' || + addressList[0] == '上海市') { + that.province1 = addressList[0]; + that.city1 = '市辖区'; + that.area1 = addressList[1]; + that.four1 = address.replace(that.province, '').replace(that + .city, '') + .replace(that + .area, ''); + } else { + that.province1 = addressList[0]; + that.city1 = addressList[1]; + that.area1 = addressList[2]; + that.four1 = address.replace(that.province, '').replace(that + .city, '') + .replace(that + .area, ''); + }; + console.log(that.four1); + + } + }); } }); + }, getback() { uni.navigateBack({ @@ -573,19 +603,19 @@ this.feeType = id this.maneizhi = index }, - /** - * 路段选择事件 - * @param index - * @param id - */ - chooseRoad(index, id) { - if (this.seletedRoad.includes(id)) { - const findIndex = this.seletedRoad.indexOf(id) - this.seletedRoad.splice(findIndex, 1) - } else { - this.seletedRoad.push(id) - } - } + /** + * 路段选择事件 + * @param index + * @param id + */ + chooseRoad(index, id) { + if (this.seletedRoad.includes(id)) { + const findIndex = this.seletedRoad.indexOf(id) + this.seletedRoad.splice(findIndex, 1) + } else { + this.seletedRoad.push(id) + } + } } @@ -779,4 +809,4 @@ background: #327DFB; border-radius: 12rpx; } - + \ No newline at end of file