Browse Source

地址铺更改

sunChengjie 11 months ago
parent
commit
e11bc451c7
5 changed files with 160 additions and 255 deletions
  1. 13 0
      src/api/addressBoook.js
  2. 16 0
      src/main.js
  3. 88 66
      src/pages/editaddress.vue
  4. 1 1
      src/pages/express.vue
  5. 42 188
      src/pages/newaddress.vue

+ 13 - 0
src/api/addressBoook.js

@@ -61,4 +61,17 @@ export function listByParent(data) {
     })
 }
 
+// 地址铺-识别
+export function spiltAddress(data) {
+    return request({
+        url: '/tianzong/client/address/spiltAddress',
+        method: 'post',
+        data: data,
+        emulateJSON: true
+    })
+}
+
+
+
+
 

+ 16 - 0
src/main.js

@@ -53,6 +53,22 @@ Vue.filter('dateFormat', (dataStr) => {
   return y + '-' + timeAdd0(m) + '-' + timeAdd0(d) + ' ' + timeAdd0(h) + ':' + timeAdd0(mm) + ':' + timeAdd0(s)
 })
 
+// 微信登录校验
+// wx.login({
+//   success(res) {
+//     if (res.code) {
+//       wx.request({
+//         url: '',
+//         data: {
+//           code: res.code
+//         }
+//       })
+//     } else {
+//       console.log('登录失败' + res.errMsg)
+//     }
+//   }
+// })
+
 //Vue.prototype.common=common
 // Vue.http.options.emulateJSON = true;
 // Vue.http.options.headers = {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'};

+ 88 - 66
src/pages/editaddress.vue

@@ -2,12 +2,33 @@
 	<div class="content">
 		<back :title="titlename"></back>
 		<div class="form">
+			<van-cell-group inset>
+				<van-field v-model="message" rows="1" label="识别" type="textarea"
+					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-button 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">
 			<van-form @submit="onSubmit">
 				<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 readonly clickable name="area" :value="city" label="省市区" placeholder="请选择省市区"
+				<!-- <van-field readonly clickable name="area" :value="city" label="省市区" placeholder="请选择省市区"
+					@click="areashow = true" :rules="[{ required: false }]" /> -->
+				<van-field readonly clickable name="area" :value="province" label="省" placeholder="自动识别"
+					@click="areashow = true" :rules="[{ required: false }]" />
+				<van-field readonly clickable name="area" :value="city" label="市" placeholder="自动识别"
+					@click="areashow = true" :rules="[{ required: false }]" />
+				<van-field readonly clickable name="area" :value="district" label="区" placeholder="自动识别"
+					@click="areashow = true" :rules="[{ required: false }]" />
+				<van-field readonly clickable name="area" :value="town" label="镇" placeholder="自动识别"
 					@click="areashow = true" :rules="[{ required: false }]" />
 				<van-field v-model="address" name="详细地址" maxlength="50" label="详细地址" placeholder="请输入详细地址"
 					:rules="[{ required: false }]" />
@@ -16,10 +37,6 @@
 						:disabled="disabled">确定</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>
@@ -27,7 +44,7 @@
 <script>
 import areaList from "@/script/areas.js"
 import { Toast } from 'vant'
-import { findUserAddressInfoById, editUserAddressInfoById } from '../api/addressBoook'
+import { findUserAddressInfoById, editUserAddressInfoById, spiltAddress } from '../api/addressBoook'
 export default {
 	data() {
 		return {
@@ -35,11 +52,15 @@ export default {
 			name: "",
 			phone: "",
 			telPhone: "",
-			city: "",
-			address: "",
+			province: "",//省
+			city: "",//市
+			district: '',//区
+			town: '',//镇
+			address: "",//详细地址
 			areashow: false,
 			id: '',
-			disabled: false
+			disabled: false,
+			message: '',
 		}
 	},
 	created: function () {
@@ -48,6 +69,7 @@ export default {
 		this.getData()
 	},
 	methods: {
+		// 获取信息
 		async getData() {
 			Toast.loading({
 				message: '加载中...',
@@ -58,30 +80,56 @@ export default {
 			if (res.msg == 'success') {
 				this.name = res.userAddressInfoById.addresseeName
 				this.phone = res.userAddressInfoById.addresseePhone
-				this.city = res.userAddressInfoById.addresseeAllAddress
-				this.address = res.userAddressInfoById.addresseeAllAddress
+				this.province = res.userAddressInfoById.addresseeProvince
+				this.city = res.userAddressInfoById.addresseeCity
+				this.district = res.userAddressInfoById.addresseeCounty
+				this.town = res.userAddressInfoById.addresseeTown
+				this.address = res.userAddressInfoById.addresseeAddrInfo
 			} else {
 				Toast("网络错误!")
 			}
 			Toast.clear()
-			console.log(res)
-			// this.$http.post(this.$store.state.host+"/personal/getAddressInfoById.do",{id:this.id},{emulateJSON:true})
-			// 	.then(res=>{
-			// 		//发送成功
-			// 		if(res.body.msg=='success'){
-			// 			this.name = res.body.addressInfo.name
-			// 			this.phone = res.body.addressInfo.phone
-			// 			this.telPhone = res.body.addressInfo.telPhone
-			// 			this.city = res.body.addressInfo.provinceAndCity
-			// 			this.address = res.body.addressInfo.address
-			// 		}
-			// 	Toast.clear()
-			// },res=>{
-			// 		 //发送失败
-			// 	Toast("网络错误!")
-			// })
-
 		},
+		// 图片识别
+		afterRead(file) {
+			// console.log(encodeURIComponent(file.content))
+			// return;
+			this.$http.post(this.$store.state.host + "/solic/getAddressFromText", {
+				type: 3,
+				textStr: encodeURIComponent(file.content)
+			}, {
+				emulateJSON: true
+			})
+				.then(res => {
+					//发送成功
+					res.body.words_result.forEach((v, i) => {
+						this.message += v.words + " "
+					})
+				}, res => {
+					//发送失败
+					Toast('识别错误')
+				})
+			//console.log(file)
+		},
+		// 识别
+		async shibie() {
+			if (this.message == '') {
+				Toast('请粘贴地址')
+				return
+			}
+			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) {
@@ -102,11 +150,6 @@ export default {
 				}
 			}
 
-			if (this.city == '' || this.city == undefined) {
-				Toast('请选择省市区')
-				return
-			}
-
 			if (this.address == '' || this.address == undefined) {
 				Toast('请输入详细地址')
 				return
@@ -117,41 +160,20 @@ export default {
 				addresseeName: this.name,
 				addresseePhone: this.phone,
 				id: this.id,
-				addresseeAddress: this.city,
-
-
-
-
-				// this.address
+				addresseeProvince: this.province,
+				addresseeCity: this.city,
+				addresseeCounty: this.district,
+				addresseeTown: this.town,
+				addresseeAddrInfo: this.address,
+				addresseeAddress: this.message,
 			}
 			const res = await editUserAddressInfoById({ ...parmas })
-			console.log(res, 'res')
-
-			// this.$http.post(this.$store.state.host + "/personal/editAddressInfoById.do", {
-			// 	id: this.id,
-			// 	name: this.name,
-			// 	phone: this.phone,
-			// 	telPhone: this.telPhone,
-			// 	provinceAndCity: this.city,
-			// 	address: this.address
-			// }, { emulateJSON: true })
-			// 	.then(res => {
-			// 		//发送成功
-			// 		if (res.body.msg == 'success') {
-			// 			Toast("保存成功");
-			// 			let that = this;
-			// 			setTimeout(function () {
-			// 				that.$router.back()
-			// 			}, 500)
-			// 		} else {
-			// 			Toast("保存失败");
-			// 		}
-			// 		this.disabled = false;
-			// 	}, res => {
-			// 		//发送失败
-			// 		Toast("网络错误");
-			// 		this.disabled = false;
-			// 	})
+			if (res.msg == 'success') {
+				Toast("保存成功");
+				this.$router.push('/Myaddressbook')
+			} else {
+				Toast('保存失败')
+			}
 			this.disabled = false;
 		},
 		onConfirm3(e) {//确定

+ 1 - 1
src/pages/express.vue

@@ -402,7 +402,7 @@ export default {
 				return
 			}
 
-			if (this.authorization == '' || this.authorization == undefined) {
+			if (this.authorization == '' & this.SendInfoValue.isVerification == 1) {
 				Toast('请填写授权码')
 				return
 			}

+ 42 - 188
src/pages/newaddress.vue

@@ -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() {