This commit is contained in:
yanran200730
2022-05-24 16:31:10 +08:00
parent e7c61c8293
commit 2b8e4dc41d
19 changed files with 255 additions and 72 deletions

View File

@@ -27,7 +27,7 @@
<div class="right" :class="[currIndex === index ? 'active' : '']"></div>
</div>
</scroll-view>
<div class="address-btn">
<div class="address-btn" v-if="!isChooseAddress">
<span>打卡有效范围</span>
<div class="right" @click="isShowScope = true">
<i>{{ distance[chooseIndex] }}</i>
@@ -54,7 +54,7 @@
</template>
<script>
import { mapState } from 'vuex'
import { mapState, mapActions } from 'vuex'
export default {
name: 'ChooseAddess',
@@ -79,7 +79,8 @@
addressList: [],
page: 1,
marker: null,
timeout: null
timeout: null,
isChooseAddress: false
}
},
@@ -95,22 +96,41 @@
...mapState(['user',])
},
onLoad () {
uni.getLocation({
type: 'wgs84',
success: res => {
this.longitude = res.longitude
this.latitude = res.latitude
}
})
onLoad (query) {
if (query.type === 'address') {
this.isChooseAddress = true
uni.setNavigationBarTitle({
title: '选择地点'
})
}
this.getLocation()
},
methods: {
...mapActions(['injectJWeixin']),
chooseDistance (index) {
this.chooseIndex = index
this.isShowScope = false
},
getLocation () {
this.injectJWeixin(['getLocation']).then(res => {
wx.getLocation({
type: 'wgs84',
success: res => {
this.longitude = res.longitude
this.latitude = res.latitude
},
error: res => {
console.log(res)
}
})
})
},
init () {
this.map.setZoom(19)
this.addMarker(this.map.getCenter())
@@ -126,13 +146,20 @@
confirm () {
const address = this.addressList[this.currIndex]
uni.$emit('address', {
address: address.address,
title: address.title,
lat: address.location.lat,
lng: address.location.lng,
distance: this.distance[this.chooseIndex]
})
if (this.isChooseAddress) {
uni.$emit('change', {
...uni.getStorageSync('formConfig'),
defaultValue: address.address
})
} else {
uni.$emit('address', {
address: address.address,
title: address.title,
lat: address.location.lat,
lng: address.location.lng,
distance: this.distance[this.chooseIndex]
})
}
uni.navigateBack({
delta: 1
})