1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!-- ******************* 定位 ******************* -->
<template>
<view class="list u-flex u-row-between">
<text class="required" v-if="item.required">*</text>
<view class="u-m-r-20">{{item.fieldsTitle}}</view>
<view class="u-flex-1">{{valueTxt || ''}}</view>
<u-button type="primary" size="mini" @click="$u.debounce(getLocation,1000)">默认按钮</u-button>
</view>
</template>
<script>
import objMixin from './objMixin'
export default {
name: 'XhLocation',
components: {},
mixins: [objMixin],
props: {},
filters:{},
data() {
return {}
},
computed: {
valueTxt() {
let str = ''
const dataValue = this.dataValue
if(dataValue && dataValue.length>1){
str = '经度:'+dataValue[0]+','+'维度:'+dataValue[1]
}
return str
}
},
watch: {},
mounted() {},
methods: {
getLocation() {
let self = this
const dataValue = this.dataValue || []
const waterInfo = this.waterInfo
uni.getLocation({
type: 'gcj02',
success: function(res) {
dataValue.push(res.longitude)
dataValue.push(res.latitude)
self.dataValue = dataValue
self.setValue(dataValue)
},
fail(err) {}
});
},
setValue(txt) {
this.valueChange(this.dataValue)
}
}
}
</script>
<style lang="scss" scoped>
.required {
padding-right: 10rpx;
font-size: 28rpx;
line-height: 40rpx;
color: #fa3534;
}
</style>