<template> <view class="content"> <u-gap height="10"></u-gap> <u-list> <u-empty :show="pageList.length == 0" mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png"></u-empty> <u-list-item v-for="(item, index) in pageList" :key="index"> <view class="evaluateInit" @click="choseThisaddress(item)"> <view class="evaluateInitInfo"> <view class="evaluateInitInfoName"> <span>{{item.contacts}}</span><span style="color: #999999;font-size: 22rpx;">{{item.phone}}</span> </view> <view class="evaluateInitInfoText"> {{item.address}} </view> </view> <view class="dsddh" @click="gotoHere(item.address,item.lat_lng)"> <view class="evaluateUserImg"> <image class="init_image" src="http://amy.yyinhong.cn/uploads/wximg/dh.png" mode=""></image> </view> <span>{{item.distance}}km</span> </view> </view> </u-list-item> </u-list> <u-toast ref="uToast"></u-toast> </view> </template> <script> export default { data() { return { pageList: [], goods_id: '', total: 0 } }, onShow() { this.pageList = []; this.getuserlocation() }, methods: { gotoHere(address, lat_lng) { let lat = lat_lng.split(",")[0] let lng = lat_lng.split(",")[1] uni.openLocation({ longitude: parseFloat(lng), // 经度,范围为-180~180,负数表示西经 latitude: parseFloat(lat), // 纬度,范围为-90~90,负数表示南纬 scale: 18, // 缩放比例 name: address, //终点名称 address: address, //终点详细地址 success: function(res) { console.log('success:', res); } }); }, getuserlocation() { let _this = this uni.getLocation({ type: 'wgs84', success: function(res) { console.log(res); _this.getaddress_list(res.latitude, res.longitude); }, fail: function(error) { _this.getaddress_list('', ''); console.error('获取位置失败:', error); } }); }, //获取地址列表 getaddress_list(lat, lng) { this.$request('/express-collection', 'POST', { lat, lng, }).then(res => { this.pageList = res.data; }).catch(err => { uni.showToast({ icon: 'error', title: '' + err.message }) }) }, choseThisaddress(item) { uni.setStorageSync('address', item); uni.navigateBack() } } } </script> <style lang="scss" scoped> .content { width: 100vw; background: #F8F8F8; } .evaluateInit { margin: 0 30rpx; padding: 30rpx; background-color: #ffffff; width: calc(100% - 120rpx); display: flex; flex-direction: row; margin-bottom: 20rpx; border-radius: 8rpx; } .dsddh { height: 60rpx; width: 60rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 16rpx; } .evaluateUserImg { height: 40rpx; width: 40rpx; border-radius: 60rpx; overflow: hidden; } .evaluateInitInfo { flex: 1; .evaluateInitInfoName { height: 32rpx; font-size: 26rpx; color: #303949; font-weight: 600; padding-bottom: 10rpx; } .evaluateInitInfoText { line-height: 30rpx; font-size: 26rpx; color: #161C2B; } } </style>