|
@@ -7,11 +7,11 @@
|
|
|
placeholder="请粘贴,点击识别(姓名、手机号、省、市、区、详细地址间请输入空格)" />
|
|
|
</van-cell-group>
|
|
|
<div style="background-color: white;width: 100%;height: .8rem;padding-top: .2rem;">
|
|
|
- <van-uploader :after-read="afterRead" style="width: 18%;height: .6rem;float: left;">
|
|
|
+ <!-- <van-uploader :after-read="afterRead" style="width: 18%;height: .6rem;float: left;">
|
|
|
<van-button color="#00c4b8" block type="info" size="small">图片识别</van-button>
|
|
|
- </van-uploader>
|
|
|
- <van-button @click="shibie()" style="width: 15%;height: .6rem;float: right;" color="#00c4b8" block
|
|
|
- type="info" size="small">识别</van-button>
|
|
|
+ </van-uploader> -->
|
|
|
+ <van-button @click="shibie()" style="width: 15%;height: .6rem;float: right; margin-right: .2rem;"
|
|
|
+ color="#00c4b8" block type="info" size="small">识别</van-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form">
|
|
@@ -19,43 +19,18 @@
|
|
|
<van-field v-model="name" name="姓名" label="姓名" placeholder="请输入姓名" :rules="[{ required: false }]" />
|
|
|
<van-field v-model="phone" maxlength="11" type="number" name="手机" label="手机" placeholder="请输入手机"
|
|
|
:rules="[{ required: false }]" />
|
|
|
- <!-- <van-field v-model="telPhone" maxlength="20" type="text" name="座机" label="座机" placeholder="请输入座机"
|
|
|
- :rules="[{ required: false }]" /> -->
|
|
|
- <!-- <van-field readonly clickable name="area" :value="city" label="省市区" placeholder="请选择省市区"
|
|
|
- @click="areashow = true" :rules="[{ required: false }]" /> -->
|
|
|
- <!-- 省 -->
|
|
|
- <van-field readonly clickable name="picker" :value="valueA" label="省" placeholder="点击选择省"
|
|
|
+
|
|
|
+ <van-field readonly clickable name="picker" :value="province" label="省" placeholder="自动识别"
|
|
|
@click="showPickerA = true" />
|
|
|
- <van-popup v-model="showPickerA" position="bottom">
|
|
|
- <van-picker show-toolbar :columns="province" @confirm="onConfirmA" @cancel="showPickerA = false">
|
|
|
- <template v-slot:option="slotProps">
|
|
|
- <span>{{ slotProps.label }}</span>
|
|
|
- </template>
|
|
|
- </van-picker>
|
|
|
- </van-popup>
|
|
|
- <!-- 市 -->
|
|
|
- <van-field readonly clickable name="picker" :value="valueB" label="市" placeholder="点击选择市"
|
|
|
+
|
|
|
+ <van-field readonly clickable name="picker" :value="city" label="市" placeholder="自动识别"
|
|
|
@click="showPickerB = true" />
|
|
|
- <van-popup v-model="showPickerB" position="bottom">
|
|
|
- <van-picker show-toolbar :columns="columnsListA" @confirm="onConfirmB"
|
|
|
- @cancel="showPickerB = false">
|
|
|
- <template v-slot:option="slotProps">
|
|
|
- <span>{{ slotProps.label }}</span>
|
|
|
- </template>
|
|
|
- </van-picker>
|
|
|
- </van-popup>
|
|
|
- <!-- 区 -->
|
|
|
- <van-field readonly clickable name="picker" :value="valueC" label="区" placeholder="点击选择区"
|
|
|
+
|
|
|
+ <van-field readonly clickable name="picker" :value="district" label="区" placeholder="自动识别"
|
|
|
@click="showPickerC = true" />
|
|
|
- <van-popup v-model="showPickerC" position="bottom">
|
|
|
- <van-picker show-toolbar :columns="columnsListB" @confirm="onConfirmC"
|
|
|
- @cancel="showPickerC = false">
|
|
|
- <template v-slot:option="slotProps">
|
|
|
- <span>{{ slotProps.label }}</span>
|
|
|
- </template>
|
|
|
- </van-picker>
|
|
|
- </van-popup>
|
|
|
|
|
|
+ <van-field readonly clickable name="picker" :value="town" label="镇" placeholder="自动识别"
|
|
|
+ @click="showPickerC = true" />
|
|
|
<van-field v-model="address" maxlength="50" name="详细地址" label="详细地址" placeholder="请输入详细地址"
|
|
|
:rules="[{ required: false }]" />
|
|
|
<div style="margin-top: 16px;">
|
|
@@ -63,17 +38,13 @@
|
|
|
</van-button>
|
|
|
</div>
|
|
|
</van-form>
|
|
|
- <!-- 城市选择
|
|
|
- <van-popup v-model="areashow" position="bottom">
|
|
|
- <van-area :area-list="areaList" @confirm="onConfirm3" @cancel="areashow = false" />
|
|
|
- </van-popup> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import areaList from "@/script/areas.js"
|
|
|
-import { saveAddress, listByParent } from '../api/addressBoook'
|
|
|
+import { saveAddress, listByParent, spiltAddress } from '../api/addressBoook'
|
|
|
import {
|
|
|
Toast
|
|
|
} from 'vant'
|
|
@@ -85,35 +56,25 @@ export default {
|
|
|
phone: "",
|
|
|
telPhone: "",
|
|
|
city: "",
|
|
|
- address: "",
|
|
|
+ address: "",//地址详情
|
|
|
areashow: false,
|
|
|
type: '',
|
|
|
disabled: false,
|
|
|
userId: '',
|
|
|
message: '', //自动识别
|
|
|
- // 省
|
|
|
- province: [],
|
|
|
- valueA: '',
|
|
|
- columnsListA: [],
|
|
|
- showPickerA: false,
|
|
|
- // 市
|
|
|
- valueB: '',
|
|
|
- columnsListB: [],
|
|
|
- showPickerB: false,
|
|
|
- // 区
|
|
|
- valueC: '',
|
|
|
- columnsC: [],
|
|
|
- showPickerC: false,
|
|
|
+ province: '',// 省
|
|
|
+ city: '',// 市
|
|
|
+ district: '',// 区
|
|
|
+ town: '',//镇
|
|
|
}
|
|
|
},
|
|
|
- // setup() {
|
|
|
- // this.afterRead = (file) => {
|
|
|
- // // 此时可以自行将文件上传至服务器
|
|
|
- // console.log(file);
|
|
|
- // };
|
|
|
- // },
|
|
|
+ setup() {
|
|
|
+ this.afterRead = (file) => {
|
|
|
+ // 此时可以自行将文件上传至服务器
|
|
|
+ console.log(file);
|
|
|
+ };
|
|
|
+ },
|
|
|
created: function () {
|
|
|
- this.onConfirm()
|
|
|
this.isLogin();
|
|
|
this.userId = localStorage.getItem('userId');
|
|
|
this.type = this.$route.query.type
|
|
@@ -127,8 +88,6 @@ export default {
|
|
|
|
|
|
methods: {
|
|
|
afterRead(file) {
|
|
|
- // console.log(encodeURIComponent(file.content))
|
|
|
- // return;
|
|
|
this.$http.post(this.$store.state.host + "/solic/getAddressFromText", {
|
|
|
type: 3,
|
|
|
textStr: encodeURIComponent(file.content)
|
|
@@ -144,48 +103,27 @@ export default {
|
|
|
//发送失败
|
|
|
Toast('识别错误')
|
|
|
})
|
|
|
- //console.log(file)
|
|
|
},
|
|
|
//识别
|
|
|
- shibie() {
|
|
|
- //this.message = this.message.replace(/\n|\r/, " ").replace(/\n|\r/g, "");
|
|
|
- // var arr = this.message.split(" ");
|
|
|
- // if (arr.length > 5) {
|
|
|
- // this.name = arr[0]
|
|
|
- // this.phone = arr[1]
|
|
|
- // this.city = arr[2] + ' ' + arr[3] + ' ' + arr[4]
|
|
|
- // this.address = arr[5]
|
|
|
- // } else {
|
|
|
- // Toast('抱歉 未能识别')
|
|
|
- // return
|
|
|
- // }
|
|
|
+ async shibie() {
|
|
|
if (this.message == '') {
|
|
|
Toast('请粘贴地址')
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- this.$http.post(this.$store.state.host + "/solic/getAddressFromText", {
|
|
|
- type: 1,
|
|
|
- textStr: this.message
|
|
|
- }, {
|
|
|
- emulateJSON: true
|
|
|
- })
|
|
|
- .then(res => {
|
|
|
- //发送成功
|
|
|
- this.name = res.body.person
|
|
|
- this.phone = res.body.phonenum
|
|
|
- this.city = res.body.province + ' ' + res.body.city + ' ' + res.body.county
|
|
|
- this.address = res.body.detail
|
|
|
- }, res => {
|
|
|
- //发送失败
|
|
|
- Toast('识别错误')
|
|
|
- })
|
|
|
-
|
|
|
+ const res = await spiltAddress({ address: this.message })
|
|
|
+ if (res.prov) {
|
|
|
+ this.province = res.prov
|
|
|
+ this.city = res.city
|
|
|
+ this.district = res.district
|
|
|
+ this.town = res.town
|
|
|
+ this.address = res.addr_info
|
|
|
+ } else {
|
|
|
+ Toast('请求失败')
|
|
|
+ }
|
|
|
+ console.log(res, 'res')
|
|
|
},
|
|
|
|
|
|
-
|
|
|
async onSubmit() {
|
|
|
-
|
|
|
if (this.name == '' || this.name == undefined) {
|
|
|
Toast('请输入姓名')
|
|
|
return
|
|
@@ -204,11 +142,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if ((this.valueA == '' || this.valueA == undefined) && (this.valueB == '' || this.valueB == undefined) && (this.valueC == '' || this.valueC == undefined)) {
|
|
|
- Toast('请选择省市区')
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
if (this.address == '' || this.address == undefined) {
|
|
|
Toast('请输入详细地址')
|
|
|
return
|
|
@@ -218,11 +151,12 @@ export default {
|
|
|
let parmas = {
|
|
|
addresseeName: this.name,
|
|
|
addresseePhone: this.phone,
|
|
|
- addresseeProvince: this.valueA,
|
|
|
- addresseeCity: this.valueB,
|
|
|
- addresseeCounty: this.valueC,
|
|
|
- addresseeAddress: this.address,
|
|
|
- // sendNum: 2,
|
|
|
+ addresseeProvince: this.province,
|
|
|
+ addresseeCounty: this.district,
|
|
|
+ addresseeCity: this.city,
|
|
|
+ addresseeTown: this.town,
|
|
|
+ addresseeAddrInfo: this.address,
|
|
|
+ addresseeAddress: this.message,
|
|
|
}
|
|
|
const res = await saveAddress({ ...parmas })
|
|
|
if (res.msg == 'success') {
|
|
@@ -232,87 +166,7 @@ export default {
|
|
|
Toast("保存失败");
|
|
|
}
|
|
|
|
|
|
- // this.$http.post(this.$store.state.host + "/personal/saveAddressInfo.do", {
|
|
|
- // userId: this.userId,
|
|
|
- // name: this.name,
|
|
|
- // phone: this.phone,
|
|
|
- // provinceAndCity: this.city,
|
|
|
- // address: this.address,
|
|
|
- // telPhone: this.telPhone,
|
|
|
- // type: this.type
|
|
|
- // }, {
|
|
|
- // emulateJSON: true
|
|
|
- // })
|
|
|
- // .then(res => {
|
|
|
- // //发送成功
|
|
|
- // if (res.body.msg == 'success') {
|
|
|
- // Toast("保存成功");
|
|
|
- // let that = this;
|
|
|
- // setTimeout(function () {
|
|
|
- // // if(that.type == 2){
|
|
|
- // // that.$router.push({path:"/Myaddressbook",query:{active:2}})
|
|
|
- // // }else{
|
|
|
- // that.$router.back()
|
|
|
- // //}
|
|
|
- // }, 500)
|
|
|
- // } else {
|
|
|
- // Toast("保存失败");
|
|
|
- // }
|
|
|
- // this.disabled = false;
|
|
|
- // }, res => {
|
|
|
- // //发送失败
|
|
|
- // Toast("网络错误");
|
|
|
- // this.disabled = false;
|
|
|
- // })
|
|
|
- // this.disabled = false;
|
|
|
},
|
|
|
- // onConfirm3(e) { //确定
|
|
|
- // this.city = e[0].name + ' ' + e[1].name + ' ' + e[2].name
|
|
|
- // this.areashow = false
|
|
|
- // console.log(e)
|
|
|
- // },
|
|
|
- async onConfirm() {
|
|
|
- const res = await listByParent({ parentAddressCode: 0 })
|
|
|
- const cityList = res.pageDataList.map((item) => {
|
|
|
- return {
|
|
|
- value: item.address_code,
|
|
|
- label: item.address_name + item.address_level
|
|
|
- }
|
|
|
- })
|
|
|
- console.log("333333", res.pageDataList)
|
|
|
- this.province = cityList
|
|
|
- },
|
|
|
- async onConfirmA({ value, label }) {
|
|
|
- const res = await listByParent({ parentAddressCode: value })
|
|
|
- const cityList = res.pageDataList.map((item) => {
|
|
|
- return {
|
|
|
- value: item.address_code,
|
|
|
- label: item.address_name
|
|
|
- }
|
|
|
- })
|
|
|
- this.valueB = ''
|
|
|
- this.valueC = ''
|
|
|
- this.valueA = label;
|
|
|
- this.showPickerA = false;
|
|
|
- this.columnsListA = cityList
|
|
|
- },
|
|
|
- async onConfirmB({ value, label }) {
|
|
|
- const res = await listByParent({ parentAddressCode: value })
|
|
|
- const cityList = res.pageDataList.map((item) => {
|
|
|
- return {
|
|
|
- value: item.address_code,
|
|
|
- label: item.address_name
|
|
|
- }
|
|
|
- })
|
|
|
- this.valueC = ''
|
|
|
- this.valueB = label;
|
|
|
- this.showPickerB = false;
|
|
|
- this.columnsListB = cityList
|
|
|
- },
|
|
|
- onConfirmC({ label }) {
|
|
|
- this.valueC = label;
|
|
|
- this.showPickerC = false;
|
|
|
- }
|
|
|
},
|
|
|
computed: {
|
|
|
areaList() {
|