|
@@ -13,17 +13,17 @@
|
|
<button type="default" size="mini" class="toLoacl" @click="toLocaltion()">地图选点</button>
|
|
<button type="default" size="mini" class="toLoacl" @click="toLocaltion()">地图选点</button>
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="所在省份" name="province">
|
|
<uni-forms-item label="所在省份" name="province">
|
|
- <picker class="picker" mode="selector" :range="provinceList" @change="proChange" range-key="value">
|
|
|
|
|
|
+ <picker class="picker" mode="selector" :range="provinceList" @change="proChange" range-key="name">
|
|
<view>{{form.province||'请选择所在省份'}}</view>
|
|
<view>{{form.province||'请选择所在省份'}}</view>
|
|
</picker>
|
|
</picker>
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="所在市" name="city">
|
|
<uni-forms-item label="所在市" name="city">
|
|
- <picker class="picker" mode="selector" :range="cityList" @change="cityChange" range-key="value">
|
|
|
|
|
|
+ <picker class="picker" mode="selector" :range="cityList" @change="cityChange" range-key="name">
|
|
<view>{{form.city||'请选择所在市'}}</view>
|
|
<view>{{form.city||'请选择所在市'}}</view>
|
|
</picker>
|
|
</picker>
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="所在区" name="area">
|
|
<uni-forms-item label="所在区" name="area">
|
|
- <picker class="picker" mode="selector" :range="areaList" @change="areaChange" range-key="value">
|
|
|
|
|
|
+ <picker class="picker" mode="selector" :range="areaList" @change="areaChange">
|
|
<view>{{form.area||'请选择所在区'}}</view>
|
|
<view>{{form.area||'请选择所在区'}}</view>
|
|
</picker>
|
|
</picker>
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
@@ -43,6 +43,9 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+ import {
|
|
|
|
+ getAddress
|
|
|
|
+ } from '@/common/tool.js';
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
@@ -89,48 +92,12 @@
|
|
},
|
|
},
|
|
},
|
|
},
|
|
provinceList: [ //所在省份
|
|
provinceList: [ //所在省份
|
|
- {
|
|
|
|
- code: '1',
|
|
|
|
- value: '吉林省',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- code: '2',
|
|
|
|
- value: '辽宁省',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- code: '3',
|
|
|
|
- value: '黑龙江省',
|
|
|
|
- },
|
|
|
|
],
|
|
],
|
|
cityList: [ //所在市
|
|
cityList: [ //所在市
|
|
- {
|
|
|
|
- code: '1-1',
|
|
|
|
- value: '长春市',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- code: '2-1',
|
|
|
|
- value: '大连市',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- code: '3-1',
|
|
|
|
- value: '哈尔滨市',
|
|
|
|
- },
|
|
|
|
],
|
|
],
|
|
areaList: [ //所在区
|
|
areaList: [ //所在区
|
|
- {
|
|
|
|
- code: '1-1-1',
|
|
|
|
- value: '朝阳区'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- code: '2-1-1',
|
|
|
|
- value: '开发区'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- code: '3-1-1',
|
|
|
|
- value: '发展区'
|
|
|
|
- },
|
|
|
|
- ]
|
|
|
|
-
|
|
|
|
|
|
+ ],
|
|
|
|
+ paltForm: ''
|
|
};
|
|
};
|
|
},
|
|
},
|
|
onLoad: function(e) {
|
|
onLoad: function(e) {
|
|
@@ -140,6 +107,12 @@
|
|
},
|
|
},
|
|
onShow: function() {
|
|
onShow: function() {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ uni.getStorage({
|
|
|
|
+ key: 'system',
|
|
|
|
+ success: function(res) {
|
|
|
|
+ that.$set(that, `paltForm`, res.data.uniPlatform)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
onUnload: function() {},
|
|
onUnload: function() {},
|
|
methods: {
|
|
methods: {
|
|
@@ -164,6 +137,7 @@
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ that.searchPor();
|
|
},
|
|
},
|
|
fail: function(err) {
|
|
fail: function(err) {
|
|
uni.reLaunch({
|
|
uni.reLaunch({
|
|
@@ -172,47 +146,79 @@
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ // 查找省
|
|
|
|
+ searchPor() {
|
|
|
|
+ const that = this;
|
|
|
|
+ let list = that.$config.china;
|
|
|
|
+ that.$set(that, `provinceList`, list)
|
|
|
|
+ },
|
|
// 定位
|
|
// 定位
|
|
toLocaltion() {
|
|
toLocaltion() {
|
|
const that = this;
|
|
const that = this;
|
|
uni.chooseLocation({
|
|
uni.chooseLocation({
|
|
success: function(res) {
|
|
success: function(res) {
|
|
- if (res) {
|
|
|
|
- that.$set(that.form, `address`, res.address || '')
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- fail: function(err) {
|
|
|
|
- console.log(err);
|
|
|
|
|
|
+ that.searchAddress(res);
|
|
}
|
|
}
|
|
})
|
|
})
|
|
- // const key = that.$config.txlocalKey;
|
|
|
|
- // const referer = that.$config.txlocalReferer;
|
|
|
|
- // uni.navigateTo({
|
|
|
|
- // url: `plugin://chooseLocation/index?key=${key}&referer=${referer}`
|
|
|
|
- // });
|
|
|
|
|
|
+ },
|
|
|
|
+ // 解析位置详细信息
|
|
|
|
+ searchAddress(e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.$set(that.form, `address`, e.address);
|
|
|
|
+ if (that.paltForm == 'app') {
|
|
|
|
+ var point = new plus.maps.Point(e.longitude, e.latitude);
|
|
|
|
+ plus.maps.Map.reverseGeocode(point, {}, function(event) {
|
|
|
|
+ var address = event.address;
|
|
|
|
+ var reg = /.+?(省|市|自治区|自治州|县|区)/g;
|
|
|
|
+ let addressList = address.match(reg).toString().split(",");
|
|
|
|
+ let province = addressList[0] || '';
|
|
|
|
+ let city = addressList[1] || '';
|
|
|
|
+ let area = addressList[2] || '';
|
|
|
|
+ that.$set(that.form, `province`, province);
|
|
|
|
+ that.$set(that.form, `city`, city);
|
|
|
|
+ that.$set(that.form, `area`, area);
|
|
|
|
+ })
|
|
|
|
+ } else if (that.paltForm == 'mp-weixin') {
|
|
|
|
+ getAddress(e.longitude, e.latitude).then((res) => {
|
|
|
|
+ if (res.status == 0) {
|
|
|
|
+ let province = res.result.address_component.province;
|
|
|
|
+ let city = res.result.address_component.city;
|
|
|
|
+ let area = res.result.address_component.district;
|
|
|
|
+ that.$set(that.form, `province`, province);
|
|
|
|
+ that.$set(that.form, `city`, city);
|
|
|
|
+ that.$set(that.form, `area`, area);
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '解析位置失败,请重新选择!'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
// 选择省份
|
|
// 选择省份
|
|
proChange(e) {
|
|
proChange(e) {
|
|
const that = this;
|
|
const that = this;
|
|
let data = that.provinceList[e.detail.value];
|
|
let data = that.provinceList[e.detail.value];
|
|
if (data) {
|
|
if (data) {
|
|
- that.$set(that.form, `province`, data.value)
|
|
|
|
|
|
+ that.$set(that.form, `province`, data.name);
|
|
|
|
+ that.$set(that, `cityList`, data.city)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- // 选择区
|
|
|
|
- areaChange(e) {
|
|
|
|
|
|
+ // 选择市
|
|
|
|
+ cityChange(e) {
|
|
const that = this;
|
|
const that = this;
|
|
- let data = that.areaList[e.detail.value];
|
|
|
|
|
|
+ let data = that.cityList[e.detail.value];
|
|
if (data) {
|
|
if (data) {
|
|
- that.$set(that.form, `area`, data.value)
|
|
|
|
|
|
+ that.$set(that.form, `city`, data.name);
|
|
|
|
+ that.$set(that, `areaList`, data.area);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- // 选择市
|
|
|
|
- cityChange(e) {
|
|
|
|
|
|
+ // 选择区
|
|
|
|
+ areaChange(e) {
|
|
const that = this;
|
|
const that = this;
|
|
- let data = that.cityList[e.detail.value];
|
|
|
|
|
|
+ let data = that.areaList[e.detail.value];
|
|
if (data) {
|
|
if (data) {
|
|
- that.$set(that.form, `city`, data.value)
|
|
|
|
|
|
+ that.$set(that.form, `area`, data)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 是否默认
|
|
// 是否默认
|