improveCustomer.vue
12.7 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<template>
<view class="container">
<Navbar title="完善客户信息" canBack></Navbar>
<view class="usuallyCard margin-sm padding flex flex-direction">
<view class="flex justify-between w100">
<view class="flex align-center">
<u-image src="/static/images/home/AI.png" mode="heightFix" width="20px" height="20px"></u-image>
<view class="margin-left-xs">
智能识别
</view>
</view>
<view class="">
<!-- <u-icon name="scan" size="25"></u-icon> -->
</view>
</view>
<view class="">
<!-- <u-input placeholder="请输入客户基本信息进行智能识别客户信息" border="none" ></u-input> -->
<u--textarea v-model="aiText" placeholder="请输入客户基本信息进行智能识别客户信息" border="none"></u--textarea>
</view>
<view class="flex justify-end w100">
<view class="w30" @click="handleAi">
<u-button shape="circle" :color="aiText.length?'#EA5504':'#AAAAAA'">智能识别</u-button>
</view>
</view>
</view>
<u--form ref="uForm" labelPosition="top" :model="khxx" :rules="rules" errorType="toast">
<view class="usuallyCard margin-sm padding">
<view class="text-lg">
客户信息
</view>
<u-form-item>
<view class="flex align-center margin-top margin-bottom-xs">
<view class="w50" style="font-size: 15px;">
客户类型
</view>
<view class="">
<u-radio-group v-model="khxx.khlx" activeColor="#EE2F24">
<u-radio :customStyle="{marginRight: '20px'}" label="居民" name="居民"> </u-radio>
<u-radio label="非居民" name="非居民"></u-radio>
</u-radio-group>
</view>
</view>
</u-form-item>
<u-form-item label="客户名称" required prop="khmc" labelWidth="180">
<u-input v-model="khxx.khmc" maxlength="8" placeholder="请输入客户名称" border="bottom"></u-input>
</u-form-item>
<u-form-item label="客户联系电话" required prop="khlxdh" labelWidth="180">
<u-input v-model="khxx.khlxdh" maxlength="11" placeholder="请输入客户联系电话" border="bottom"></u-input>
</u-form-item>
<!-- <u-form-item label="客户联系姓名" required prop="khlxxm" labelWidth="180" v-if="khxx.khlx === '非居民'">-->
<!-- <u-input v-model="khxx.khlxxm" maxlength="8" placeholder="请输入客户联系姓名" border="bottom"></u-input>-->
<!-- </u-form-item>-->
<u-form-item label="客户联系地址(省市区)" required labelWidth="180">
<u-input v-model="khxx.khlxdzsf" disabled disabled-color="#fff" placeholder="省"
border="bottom"></u-input>
<u-input v-model="khxx.khlxdzs" disabled disabled-color="#fff" placeholder="市"
border="bottom"></u-input>
<u-input v-model="khxx.khlxdzq" disabled disabled-color="#fff" placeholder="区"
border="bottom"></u-input>
<u-icon name="map-fill" @click="openMap(1)"></u-icon>
</u-form-item>
<u-form-item label="街道" required prop="khlxdzxxdz" labelWidth="180">
<u-input v-model="khxx.khlxdzjd" disabled disabled-color="#fff" placeholder="街道"
border="bottom"></u-input>
</u-form-item>
<u-form-item label="客户详细联系地址" required prop="khlxdzxxdz" labelWidth="180">
<u-input v-model="khxx.khlxdzxxdz" placeholder="请输入客户详细联系地址" border="bottom"></u-input>
</u-form-item>
<u-form-item label="客户身份证号" required prop="khsfzh" labelWidth="180">
<u-input v-model="khxx.khsfzh" maxlength="18" placeholder="请输入客户身份证号" border="bottom"></u-input>
</u-form-item>
<u-form-item label="企业统一社会信用代码" labelWidth="180" v-if="khxx.khlx === '非居民'">
<u-input v-model="khxx.qytyshxydm" maxlength="18" placeholder="请输入企业统一社会信用代码"
border="bottom"></u-input>
</u-form-item>
</view>
<!-- <view class="usuallyCard margin-sm padding">-->
<!-- <view class="text-lg">-->
<!-- 收货信息-->
<!-- </view>-->
<!-- <u-form-item label="收货人姓名" required prop="shrxm" labelWidth="180">-->
<!-- <u-input v-model="khxx.shrxm" maxlength="8" placeholder="请输入客户名称" border="bottom"></u-input>-->
<!-- </u-form-item>-->
<!-- <u-form-item label="收货人电话" required prop="shrdh" labelWidth="180">-->
<!-- <u-input v-model="khxx.shrdh" maxlength="11" placeholder="请输入客户联系电话" border="bottom"></u-input>-->
<!-- </u-form-item>-->
<!-- <u-form-item label="收货人地址(省市区街道)" required labelWidth="180">-->
<!-- <u-input v-model="khxx.shrdzsf" disabled disabled-color="#fff" placeholder="省"-->
<!-- border="bottom"></u-input>-->
<!-- <u-input v-model="khxx.shrdzs" disabled disabled-color="#fff" placeholder="市"-->
<!-- border="bottom"></u-input>-->
<!-- <u-input v-model="khxx.shrdzq" disabled disabled-color="#fff" placeholder="区"-->
<!-- border="bottom"></u-input>-->
<!-- <u-input v-model="khxx.shrdzjd" disabled disabled-color="#fff" placeholder="街道"-->
<!-- border="bottom"></u-input>-->
<!-- <u-icon name="map-fill" @click="openMap(2)"></u-icon>-->
<!-- <!– <u-input v-model="khxx.area" placeholder="请选择收货人省市区街道" border="bottom"></u-input> –>-->
<!-- </u-form-item>-->
<!-- <u-form-item label="收货人详细地址" required prop="shrdzxxdz" labelWidth="180">-->
<!-- <u-input v-model="khxx.shrdzxxdz" placeholder="请输入收货人详细地址" border="bottom"></u-input>-->
<!-- </u-form-item>-->
<!-- </view>-->
</u--form>
<view class="bomBtnCss" @click="handleConfirm">
<u-button color="#EA5504">确定</u-button>
</view>
</view>
</template>
<script>
export default {
components: {},
props: {
},
data() {
return {
khxx: {
hyID: "",
khlx: "", //客户类型 必填
khmc: "", //客户名称 必填
khlxxm: "", //客户联系姓名(客户类型为:非居民时,此字段必填)
khlxdh: "", //客户联系电话 必填
khsfzh: "", //客户身份证号
khlxdzxxdz: "", //客户联系地址
qytyshxydm: "", //企业统一社会信用代码
shrxm: "", //收货人姓名
shrdh: "", //收货人电话
shrdzsf: "", //收货人省
shrdzs: "", //收货人市
shrdzq: "", //收货人区
shrdzjd: "", //收货人街道
jd: "",
wd: "",
},
aiText: "",
rules: {
'khmc': {
type: 'string',
required: true,
message: '请填写客户姓名',
trigger: ['blur', 'change']
},
'khlxxm': {
type: 'string',
required: true,
message: '请填写客户联系姓名',
trigger: ['blur', 'change']
},
'khlxdh': {
type: 'string',
required: true,
message: '请填写客户联系电话',
trigger: ['blur', 'change']
},
'khlxdzxxdz': {
type: 'string',
required: true,
message: '请填写客户联系地址',
trigger: ['blur', 'change']
},
'khsfzh': {
type: 'string',
required: true,
message: '请填写客户身份证号',
trigger: ['blur', 'change']
},
'khlxdzxxdz': {
type: 'string',
required: true,
message: '请填写客户联系地址',
trigger: ['blur', 'change']
},
// 收货人信息校验
'shrxm': {
type: 'string',
required: true,
message: '请填写收货人姓名',
trigger: ['blur', 'change']
},
'shrdh': {
type: 'string',
required: true,
message: '请填写收货人电话',
trigger: ['blur', 'change']
},
'shrdzxxdz': {
type: 'string',
required: true,
message: '请填写收货人详细地址',
trigger: ['blur', 'change']
},
},
openMapType: null,
}
},
computed: {
},
onLoad(data) {
if(data.adsData){
let datas = JSON.parse(data.adsData)
if (Object.keys(datas).length !== 0) {
this.khxx = datas;
console.log(this.khxx);
}
}
},
methods: {
async handleAi() {
let that = this;
console.log("待识别内容1", this.aiText);
let query = {
search: this.aiText
}
this.$api.orderApi.getDetailSearch(query).then(res => {
console.log("识别结果", res);
let {
code,
value
} = res;
if (code === 200 && value.userInfo) {
this.$modal.showLoading('识别中...')
console.log(value.userInfo);
let data = value.userInfo
// this.khxx.hyID = data.fHybh;
this.khxx.khlx = data.fHylx;
this.khxx.khmc = data.fXm;
this.khxx.khlxxm = data.fXm;
this.khxx.khlxdh = data.fSjh;
this.khxx.khsfzh = data.fSfzh;
this.khxx.qytyshxydm = data.fShtysbm || "";
if (value.hydzs && value.hydzs.length > 0) {
let mrdz = value.hydzs.find(d => d.fSfmrdz == 'y');
this.khxx.khlxdzsf = mrdz?mrdz.fLxrsf:value.hydzs[0].fLxrsf;
this.khxx.khlxdzs = mrdz?mrdz.fLxrs:value.hydzs[0].fLxrs;
this.khxx.khlxdzq = mrdz?mrdz.fLxrq:value.hydzs[0].fLxrq;
this.khxx.khlxdzjd = mrdz?mrdz.fLxrjd:value.hydzs[0].fLxrjd;
this.khxx.khlxdzxxdz = mrdz?mrdz.fLxrxxdz:value.hydzs[0].fLxrxxdz;
this.khxx.jd = mrdz?mrdz.fJd:value.hydzs[0].fJd;
this.khxx.wd = mrdz?mrdz.fWd:value.hydzs[0].fWd;
}
// this.khxx.khlxdzsf = data.fFwszsf;
// this.khxx.khlxdzs = data.fFwszs;
// this.khxx.khlxdzq = data.fFwszq;
// this.khxx.khlxdzjd = data.fFwszjd;
// this.khxx.khlxdzxxdz = data.fFwszxqmc;
// this.khxx.qytyshxydm = data.fShtysbm || "";
// this.khxx.mcazsj = data.mcazsj;
setTimeout(() => {
that.$modal.closeLoading();
}, 500)
} else {
uni.$u.toast('未查询到用户信息');
console.log();
}
})
},
openMap(e) {
this.openMapType = parseInt(e);
let that = this;
uni.chooseLocation({
success: function(res) {
//划皆市区
// let location = res.address
// const [province, city, district, street] = location.match(/(.*?省|.*?市|.*?区|.*$)/g).map(
// item => item.replace(/省|市|区/g, ''));
// console.log(province, city, district, street);
console.log('位置名称:' + res.name);
console.log('详细地址:' + res.address);
console.log('纬度:' + res.latitude);
console.log('经度:' + res.longitude);
that.khxx.jd = res.longitude;
that.khxx.wd = res.latitude;
// 逆地址获取
that.loadCity(res.longitude, res.latitude, res.address, res.name)
}
});
},
loadCity(longitude, latitude, address, name) {
let that = this;
uni.request({
header: {
'Content-Type': 'application/json',
},
//注意:这里的key值需要高德地图的 web服务生成的key 只有web服务才有逆地理编码
url: `https://restapi.amap.com/v3/geocode/geo?output=JSON&address=${address}&location=${longitude},${latitude}&key=${this.$config.gaodeMapKey}`,
success(res) {
console.log("逆地址获取位置成功信息", res)
let data = res.data;
if (data.status === '1') {
let geocodes = data.geocodes[0];
console.log("取第一个地址", geocodes);
console.log("打开地图类型", that.openMapType);
if (that.openMapType === 1) {
that.$set(that.khxx,'khlxdzsf',geocodes.province);
that.$set(that.khxx,'khlxdzs',geocodes.city);
that.$set(that.khxx,'khlxdzq',geocodes.district);
let street = geocodes.street;
const regex = /区(.*)$/;
const extractedText = /区(.*)$/.exec(geocodes.formatted_address)[1].trim();
that.$set(that.khxx, 'khlxdzjd', that.$streetOrNot(street) ? street : extractedText || "");
// that.$set(that.khxx, 'khlxdzxxdz', geocodes.formatted_address);
console.log('客户信息', JSON.parse(JSON.stringify(that.khxx)));
} else {
that.khxx.shrdzsf = geocodes.province;
that.khxx.shrdzs = geocodes.city;
that.khxx.shrdzq = geocodes.district;
that.khxx.shrdzjd = address;
// that.khxx.shrdzxxdz = `${address}${name}`;
console.log('收货人信息', JSON.parse(JSON.stringify(that.khxx)));
}
}else{
uni.$u.toast('地址解析失败')
}
},
fail(err) {
console.log(err, "获取位置失败信息")
uni.$u.toast(err);
}
})
},
handleConfirm() {
this.$refs.uForm.validate().then(async res => {
uni.$emit('khxxData',this.khxx);
this.$goBack();
}).catch(errors => {
// uni.$u.toast('校验失败')
})
}
}
}
</script>
<style lang="scss" scoped>
.container {
padding-bottom: 50px;
}
.bomBtnCss {
position: fixed;
bottom: 0;
background: #fff;
width: 100%;
height: 50px;
padding: 5px 10px;
}
/deep/.u-input {
padding: 6px 0px !important;
}
</style>