XhLocation.vue 1.38 KB
<!-- *******************  定位  *******************  -->
<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>