页面修改

This commit is contained in:
zmj 2023-12-20 08:42:32 +08:00
parent a59c789cd8
commit 59f356fa2e
5 changed files with 73 additions and 178 deletions

View File

@ -40,6 +40,7 @@ export const listForType = (data) => syhttp.get('/action/listForType', data)
//首页
export const lindexist = (data) => syhttp.get('/index/index', data)
//产品列表
export const landproduct = (data) => syhttp.get('/land/product', data)
@ -63,5 +64,3 @@ export const towns = (data) => http.get('/common/geo/towns', data)
export const villages = (data) => http.get('/common/geo/villages', data)
//小组
export const groups = (data) => http.get('/common/geo/groups', data)

View File

@ -364,10 +364,19 @@
}
const location = () => {
uni.navigateTo({
url: '/pages/addLand/select_address_n'
})
return
uni.showLoading({
title: '获取位置中'
})
uni.getLocation({
type: 'gcj02',
geocode: true,
isHighAccuracy: true,
@ -441,7 +450,7 @@
}
onLoad((options) => {
console.log(options || "")
provincen()
})

View File

@ -17,65 +17,26 @@
<view class="re-location">
<view style="width: 120rpx;"><text class="text">当前位置: </text></view>
<view style="flex: 1;">
<text
class="text">{{locationInfo.formatted_addresses?locationInfo.formatted_addresses.recommend:locationInfo.address}}</text>
<text class="text">{{address}}</text>
</view>
</view>
<view class="re-btn" @click="reGetLocation">
<image class="re-address-img" src="@/static/images/re_address.png"></image><text
class="text">重新定位</text>
<text class="text">重新定位</text>
</view>
</view>
<u-button text="确认" @click="submitAddress"></u-button>
</view>
<view class="address-box" v-if="current==1">
<view class="head_item_tips">
<view><text class="text">泸州区县</text></view>
</view>
<view class="area">
<view class="area-item" :class="{'area-item-on': item.code==area_change}"
v-for="(item, index) in areaList" :key="index" @click="changeArea(item)">
<text class="text">{{item.name}}</text>
</view>
</view>
<view class="head_item_tips">
<view><text class="text">选择街道/镇</text></view>
</view>
<view class="street">
<view class="letter-item" v-for="key in mapKey" :key="key">
<view class="letter"><text class="text">{{key}}</text></view>
<view class="item-box">
<view class="street-item" v-for="item in mapList[key]" :key="item.code"
@click="changeStreet(item)">
<text class="text">{{item.name}}</text>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {
getGeocoder,
merClassifly,
getProductslist
} from '@/api/store.js';
import {
getArea,
getStreet
} from "@/api/article.js";
import {
Toast
} from '@/libs/uniApi';
export default {
data() {
return {
tabsList: [{
name: '地图定位',
}, {
name: '泸州区县',
}],
current: 0,
latitude: '28.87',
@ -88,20 +49,14 @@
width: 28,
height: 28
},
address: "",
locationInfo: {},
town: '',
street_id: '',
street: '',
areaList: [],
streetList: [],
mapList: {},
area_change: '',
street_change: '',
}
},
onLoad(options) {
this.getLoaction();
this.loadArea();
},
onShow() {},
computed: {
@ -114,104 +69,46 @@
this.current = e.index;
},
getLoaction() {
let that = this
this.street = '定位中'
this.locationInfo = {};
this.locationInfo.formatted_addresses = {};
this.locationInfo.formatted_addresses.recommend = '定位中'
uni.getLocation({
type: 'wgs84',
timeout: '4',
geocode: true,
isHighAccuracy: true,
success: (res) => {
let latitude, longitude;
latitude = res.latitude.toString();
longitude = res.longitude.toString();
this.latitude = res.latitude.toFixed(6);
this.longitude = res.longitude.toFixed(6);
this.$store.commit('setLocation', {
lat: res.latitude.toFixed(6),
long: res.longitude.toFixed(6),
uni.request({
url: `https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=${res.longitude},${res.latitude}&key=976a447183ed0d384e1c5b6448b8a75d&radius=1000&extensions=all`, //仅为示例,并非真实接口地址。
success: (res) => {
that.address = res.data.regeocode.formatted_address
// console.log();
}
});
getGeocoder({
lat: latitude,
long: longitude
}).then(res => {
this.locationInfo = res.data;
this.town = res.data.address_reference.town.title
this.street_id = res.data.address_reference.town.id
this.street = res.data.address_reference.town.title;
}).catch(err => {
uni.showToast({
title: err,
icon: 'none'
})
this.street = '定位失败'
})
},
fail: (err) => {
console.log('定位失败');
this.isshow = false
Toast('定位失败,请检查定位权限是否开启')
// Toast('定位失败,请检查定位权限是否开启')
this.street = '定位失败'
this.locationInfo.formatted_addresses.recommend = '定位失败'
// uni.showToast({
// title: "获取定位超时",
// icon: 'none',
// duration: 2000
// });
}
});
},
reGetLocation() {
this.getLoaction()
},
loadArea() {
getArea({
city_code: 510500
}).then((res) => {
this.areaList = res.data;
this.changeArea(this.areaList[0]);
})
},
loadStreet(area_code) {
this.street_change = '';
getStreet({
area_code
}).then((res) => {
this.streetList = res.data;
this.initPinyin();
})
},
initPinyin() {
this.mapList = {};
this.streetList.forEach((item) => {
let str = item.pinyin?.toUpperCase();
str = str ? str : '#';
if (this.mapList[str]) {
this.mapList[str].push(item);
} else {
this.mapList[str] = [];
this.mapList[str].push(item)
}
})
},
changeArea(item) {
this.area_change = item.code;
this.loadStreet(this.area_change);
},
// 选择位置
changeStreet(item) {
uni.navigateBack({
success: () => {
uni.$emit('changeAddress', {
area: this.area_change,
street: item
})
}
})
},
// 点击地图
handleMapTap(e) {
let that = this
// console.log('点击地图', e);
// #ifdef H5
return Toast('H5暂不支持选择坐标');
@ -220,49 +117,37 @@
let latitude = e.detail.latitude;
this.markers.longitude = longitude;
this.markers.latitude = latitude;
// console.log('修改成功', this.markers);
getGeocoder({
lat: latitude,
long: longitude
}).then(res => {
// console.log(res);
this.locationInfo = res.data;
}).catch(err => {
uni.showToast({
title: err,
icon: 'none'
})
this.locationInfo = {};
this.locationInfo.formatted_addresses = {};
this.locationInfo.formatted_addresses.recommend = '定位失败'
})
this.longitude = longitude
this.latitude = latitude
uni.request({
url: `https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=${longitude},${latitude}&key=976a447183ed0d384e1c5b6448b8a75d&radius=1000&extensions=all`, //仅为示例,并非真实接口地址。
success: (res) => {
console.log(res)
that.address = res.data.regeocode.formatted_address
}
});
},
submitAddress() {
console.log(this.locationInfo);
try {
this.town = this.locationInfo.address_reference.town.title;
this.street_id = this.locationInfo.address_reference.town.id;
this.street = this.locationInfo.address_reference.town.title;
let obj = {
area: this.locationInfo.ad_info.adcode,
street: {
name: this.street,
code: this.street_id
},
latitude: this.latitude,
longitude: this.longitude
}
console.log({
...obj
});
uni.navigateBack({
success: () => {
uni.$emit('changeAddress', obj)
// console.log(this.latitude)
// console.log(this.longitude)
// console.log(this.address)
let data = {
lat: this.latitude,
lon: this.longitude,
address: this.address
}
uni.navigateTo({
url: "/pages/addLand/addLand" + JSON.stringify(data)
})
} catch (e) {
return Toast('地址有误,请重新选择')
}
},
searchMap() {
uni.request({

View File

@ -8,7 +8,7 @@
<view class="nav-con" style="justify-content: space-between;">
<view class="" v-if="Object.keys(dataobj).length>0"
style="padding-left: 20rpx;display: flex;color: white;" @click="show=true">
<u--image :src="u('qhtd')" width="38.55rpx" @click="scanFn" height="38.55rpx"
<u--image :src="u('qhtd')" width="38.55rpx" height="38.55rpx"
style="margin-right: 20rpx;"></u--image>
{{dataobj.title}}
@ -130,8 +130,8 @@
{{item.name}}
</view>
<view class="" style="color:#73DFB2">
{{ item.num?item.num+item.unit:'--' }}
<text v-if="item.num==0">{{item.num+item.unit}}</text>
<text v-else>{{ item.num?item.num+item.unit:'--' }}</text>
</view>
</view>
</view>
@ -427,7 +427,7 @@
])
onShow(() => {
getlist()
// getlist()
getlist1()
getlist2()
@ -445,12 +445,10 @@
if (res.code == 1) {
if (Object.keys(res.data).length > 0) {
getlist3(res.data.id)
Object.assign(dataobj, res.data);
if (res.data && res.data.monitor && res.data.monitor.soil_monitor_data) {
soilList[0].num = res.data.monitor.soil_monitor_data.temperature
soilList[1].num = res.data.monitor.soil_monitor_data.moisture
soilList[0].num = res.data.monitor.soil_monitor_data.soil_temperature
soilList[1].num = res.data.monitor.soil_monitor_data.soil_moisture
soilList[2].num = res.data.monitor.soil_monitor_data.conductivity
soilList[3].num = res.data.monitor.soil_monitor_data.ph
soilList[4].num = res.data.monitor.soil_monitor_data.n_content
@ -460,13 +458,12 @@
if (res.data && res.data.monitor && res.data.monitor.air_monitor_data) {
environmentList[0].num = res.data.monitor.air_monitor_data.wind_speed
environmentList[1].num = res.data.monitor.air_monitor_data.wind_direction
environmentList[2].num = res.data.monitor.air_monitor_data.temperature
environmentList[3].num = res.data.monitor.air_monitor_data.moisture
environmentList[2].num = res.data.monitor.air_monitor_data.air_temperature
environmentList[3].num = res.data.monitor.air_monitor_data.air_moisture
environmentList[4].num = res.data.monitor.air_monitor_data.co2_content
environmentList[5].num = res.data.monitor.air_monitor_data.pressure
environmentList[6].num = res.data.monitor.air_monitor_data.rainfall
environmentList[7].num = res.data.monitor.air_monitor_data.light_intensity
}
}
@ -482,6 +479,9 @@
keyword: ''
}).then((res) => {
if (res.code == 1) {
tdId.value = res.data[0].id
getlist()
if (res.data.length > 0) {
columns.splice(0, columns.length, ...res.data.map((step, index) => {
return {
@ -604,7 +604,6 @@
}
const navgo = () => {
uni.navigateTo({
url: '/pages/landDetail/index?id=' + dataobj.id
})

View File

@ -1,5 +1,8 @@
Promise.resolve("./pages/live/live.js").then((res) => {
res.length;
});
Promise.resolve("./pages/addLand/select_address_n.js").then((res) => {
res.length;
});
Promise.resolve("./app.css.js").then(() => {
});