366 lines
8.4 KiB
Vue
366 lines
8.4 KiB
Vue
<template>
|
|
<view class="location">
|
|
<u-navbar id="navbar" :border-bottom="false" :background="{ background: 'rgba(256,256,256, 0)'}"
|
|
:back-bg="'rgba(0, 0, 0, 0.2)'" back-icon-color="rgba(256, 256, 256, 1)" :immersive="true">
|
|
</u-navbar>
|
|
|
|
<map id="map" :longitude="lng" :latitude="lat" :markers="poiList" style="width: 100vw; height: 100vh;"></map>
|
|
|
|
<view class="list" @tap="showPopup = true">
|
|
<!-- 显示自提点列表 -->
|
|
<u-icon name="list" size="32"></u-icon>
|
|
</view>
|
|
|
|
<view class="choose">
|
|
<view class="flex">
|
|
<view class="title" @click="showRegion = true">
|
|
<u-icon class="m-r-10" name="map-fill" size="28"></u-icon>
|
|
{{area || '选择'}}
|
|
</view>
|
|
<view class="desc flex row-between">
|
|
<u-input class="input" v-model="address" placeholder="详细地址: 小区、门牌号等" />
|
|
</view>
|
|
</view>
|
|
<view class="flex m-t-20">
|
|
<view class="title">
|
|
<u-icon class="m-r-10" name="phone-fill" size="28"></u-icon>
|
|
电话
|
|
</view>
|
|
<view class="desc flex row-between">
|
|
<u-input class="input" v-model="phone" placeholder="自提点联系电话" />
|
|
</view>
|
|
</view>
|
|
<view class="text-center m-t-20 bold xxl" @tap="search">
|
|
添加位置
|
|
</view>
|
|
</view>
|
|
|
|
<u-popup v-model="showPopup" mode="bottom" height="50%">
|
|
<view class="p-20">
|
|
<view class="bold">自提点列表</view>
|
|
<view class="m-t-20 m-b-20">
|
|
<view v-if="postStationList" v-for="(item, index) in postStationList" :key="index"
|
|
class="m-b-20">
|
|
<view class="flex">
|
|
<u-icon name="map-fill" size="28"></u-icon>
|
|
<text class="bold m-l-10">{{item.province}} {{item.city}} {{item.area}} {{item.address}}</text>
|
|
</view>
|
|
<view class="flex" v-if="item.phone">
|
|
<u-icon name="phone-fill" size="28"></u-icon>
|
|
<text class="bold m-l-10">{{item.phone}}</text>
|
|
</view>
|
|
<view class="flex m-t-10">
|
|
<view class="bold" @tap="delItem(index, item.id)">
|
|
<u-icon name="trash" size="28"></u-icon>
|
|
<text class="m-l-10">
|
|
删除
|
|
</text>
|
|
</view>
|
|
<view class="bold m-l-20" @tap="editItem(index, item.id)">
|
|
<u-icon name="edit-pen" size="28"></u-icon>
|
|
<text class="m-l-10">
|
|
编辑电话
|
|
</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</u-popup>
|
|
<u-modal v-model="showModel" :content="content" :show-cancel-button="true" @confirm="submit"></u-modal>
|
|
<u-picker v-model="showRegion" mode="region" @confirm="selCity"></u-picker>
|
|
<u-popup v-model="showEdit" :closeable="true" :maskCloseAble="false" mode="center" border-radius="14">
|
|
<view class="modify-container bg-white" style="width: 70vw;padding: 24rpx">
|
|
<view class="xl text-center">修改电话</view>
|
|
<form @submit="changeNameConfirm">
|
|
<u-form-item label="电话" :labelWidth="120">
|
|
<input style="height: 60rpx;" :value="editPhone" name="editPhone" placeholder="请输入电话"></input>
|
|
</u-form-item>
|
|
<button class="btn bg-primary white flex row-center" form-type="submit">确定</button>
|
|
</form>
|
|
</view>
|
|
</u-popup>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
mapActions,
|
|
mapMutations,
|
|
mapGetters
|
|
} from 'vuex'
|
|
|
|
import {
|
|
getLocalShopById
|
|
} from '@/api/shop.js'
|
|
import {
|
|
getPostStationList,
|
|
getLocation,
|
|
addPostStation,
|
|
editPostStationPhone,
|
|
delPostStation
|
|
} from '@/api/local_store.js'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
poiList: [],
|
|
lat: 0,
|
|
lng: 0,
|
|
showRegion: false,
|
|
province: '',
|
|
city: '',
|
|
area: '',
|
|
address: '',
|
|
showModel: false,
|
|
showPopup: false,
|
|
content: '',
|
|
lstore_id: 0,
|
|
location: [],
|
|
info: [],
|
|
postStationList: [],
|
|
phone: '',
|
|
showEdit: false,
|
|
editId: 0,
|
|
editPhone: '',
|
|
editIndex: 0
|
|
}
|
|
},
|
|
onLoad(e) {
|
|
if (e?.lstore_id) {
|
|
this.lstore_id = e.lstore_id
|
|
this.getPostStationListFunc(e.lstore_id)
|
|
}
|
|
},
|
|
methods: {
|
|
...mapActions(['initLocationFunc']),
|
|
...mapMutations(['setCityInfo']),
|
|
|
|
getPostStationListFunc(id) {
|
|
getPostStationList({
|
|
id
|
|
}).then((res) => {
|
|
if (res.code == 1) {
|
|
if (res.data.length >= 1) {
|
|
this.postStationList = res.data
|
|
this.postStationList.map((value, index) => {
|
|
this.poiList.push({
|
|
id: value.id,
|
|
latitude: value.lat,
|
|
longitude: value.lng,
|
|
iconPath: '/bundle_b/static/mark.png',
|
|
width: 40,
|
|
height: 40,
|
|
alpha: 1,
|
|
callout: {
|
|
content: `${value.province} ${value.city} ${value.area} ${value.address}`,
|
|
display: "ALWAYS",
|
|
bgColor: "#39B54A",
|
|
color: "#fff",
|
|
borderRadius: 15,
|
|
padding: '10'
|
|
}
|
|
})
|
|
})
|
|
|
|
this.lat = this.postStationList[0].lat
|
|
this.lng = this.postStationList[0].lng
|
|
} else {
|
|
this.poiList[0] = {
|
|
id: 1,
|
|
latitude: this.cityInfo.gcj02_lat,
|
|
longitude: this.cityInfo.gcj02_lng,
|
|
iconPath: '/bundle_b/static/mark.png',
|
|
width: 40,
|
|
height: 40,
|
|
alpha: 1,
|
|
}
|
|
|
|
this.lat = this.cityInfo.gcj02_lat
|
|
this.lng = this.cityInfo.gcj02_lng
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
// 选择城市
|
|
selCity(e) {
|
|
this.province = e.province.label
|
|
this.city = e.city.label
|
|
this.area = e.area.label
|
|
},
|
|
|
|
async search() {
|
|
if (!this.province && !this.city && !this.area) return this.$toast({
|
|
title: "未选择区域"
|
|
})
|
|
|
|
if (!this.address) return this.$toast({
|
|
title: "请输入地址"
|
|
})
|
|
|
|
if (!this.phone) return this.$toast({
|
|
title: "请输入自提点联系电话"
|
|
})
|
|
|
|
const address = `${this.province}${this.city}${this.area}${this.address}`
|
|
const {
|
|
code,
|
|
data
|
|
} = await getLocation({
|
|
address,
|
|
phone: this.phone
|
|
})
|
|
|
|
if (code == 1) {
|
|
this.poiList[0].latitude = data.lat
|
|
this.poiList[0].longitude = data.lng
|
|
|
|
this.lat = data.lat
|
|
this.lng = data.lng
|
|
|
|
this.showModel = true
|
|
this.content = `是否将自提点设置为:${this.province} ${this.city} ${this.area} ${this.address}`
|
|
}
|
|
},
|
|
|
|
async submit() {
|
|
const {
|
|
province,
|
|
city,
|
|
area,
|
|
address,
|
|
lat,
|
|
lng,
|
|
lstore_id,
|
|
phone
|
|
} = this
|
|
|
|
const {
|
|
code,
|
|
data
|
|
} = await addPostStation({
|
|
province,
|
|
city,
|
|
area,
|
|
address,
|
|
lat,
|
|
lng,
|
|
lstore_id,
|
|
phone
|
|
})
|
|
|
|
if (code == 1) {
|
|
this.$toast({
|
|
title: '设置成功'
|
|
})
|
|
|
|
setTimeout(() => {
|
|
uni.navigateBack({
|
|
delta: 1
|
|
})
|
|
}, 500)
|
|
}
|
|
},
|
|
|
|
delItem(index, id) {
|
|
uni.showModal({
|
|
title: '提示',
|
|
content: '是否删除',
|
|
success: (res) => {
|
|
delPostStation({
|
|
id
|
|
}).then((res) => {
|
|
if (res.code == 1) {
|
|
this.postStationList.splice(index, 1)
|
|
this.$toast({
|
|
title: '删除成功'
|
|
})
|
|
}
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
editItem(index, id) {
|
|
this.editIndex = index
|
|
this.editId = id
|
|
this.showEdit = true
|
|
this.editPhone = this.postStationList[index].phone
|
|
},
|
|
|
|
changeNameConfirm(e) {
|
|
if (!e.detail.value.editPhone) return this.$toast({
|
|
title: '请输入联系电话'
|
|
})
|
|
|
|
const phone = e.detail.value.editPhone
|
|
editPostStationPhone({
|
|
id: this.editId,
|
|
phone
|
|
}).then((res) => {
|
|
if (res.code == 1) {
|
|
this.$toast({
|
|
title: '修改成功'
|
|
})
|
|
this.postStationList[this.editIndex].phone = phone
|
|
this.editPhone = phone
|
|
}
|
|
})
|
|
}
|
|
},
|
|
computed: {
|
|
...mapGetters(['cityInfo'])
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.location {
|
|
position: relative;
|
|
}
|
|
|
|
.choose {
|
|
position: absolute;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
width: 80%;
|
|
bottom: 100rpx;
|
|
background-color: #fff;
|
|
margin: 0 auto;
|
|
padding: 20rpx;
|
|
border-radius: 40rpx;
|
|
box-shadow: 0px 13px 18px rgba(0, 0, 0, 0.4);
|
|
}
|
|
|
|
.title {
|
|
width: 160rpx;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
height: 60rpx;
|
|
line-height: 60rpx;
|
|
border-right: 2rpx solid #ccc;
|
|
padding-right: 10rpx;
|
|
font-size: 28rpx;
|
|
text-align: center;
|
|
}
|
|
|
|
.desc {
|
|
width: calc(100% - 160rpx);
|
|
height: 60rpx;
|
|
line-height: 60rpx;
|
|
padding-left: 10rpx;
|
|
font-size: 28rpx;
|
|
}
|
|
|
|
.list {
|
|
position: absolute;
|
|
right: 20rpx;
|
|
top: 20%;
|
|
background-color: #fff;
|
|
padding: 20rpx;
|
|
border-radius: 50%;
|
|
box-shadow: 8rpx 8rpx 28rpx rgba(0, 0, 0, 0.4);
|
|
}
|
|
</style> |