step1.vue
13.2 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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<template>
<view class="">
<u--form ref="uForm" labelPosition="top" :model="khxx" :rules="rules" errorType="toast">
<view class="usuallyCard margin-sm padding flex flex-direction" v-if="openType !== 0">
<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>
<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" :disabled="!openType">
<u-radio :customStyle="{marginRight: '20px'}" v-for="(item, index) in radiolist"
:key="index" :label="item.name" :name="item.name" @change="radioChange">
</u-radio>
</u-radio-group>
</view>
</view>
</u-form-item>
<u-form-item label="客户名称" prop="khmc" labelWidth="180">
<u-input v-model="khxx.khmc" maxlength="8" placeholder="请输入客户名称" :disabled="!openType"
disabled-color="#fff" border="bottom"></u-input>
</u-form-item>
<u-form-item label="客户联系电话" prop="khlxdh" labelWidth="180">
<u-input v-model="khxx.khlxdh" maxlength="11" placeholder="请输入客户联系电话" :disabled="!openType"
disabled-color="#fff" border="bottom"></u-input>
</u-form-item>
<u-form-item label="客户联系地址(省市区)" prop="area" labelWidth="180"
v-show="openType === 1 || openType === 2">
<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"></u-icon>
</u-form-item>
<u-form-item label="街道" prop="stree" labelWidth="180" v-show="openType === 1 || openType === 2">
<u-input v-model="khxx.khlxdzjd" disabled disabled-color="#fff" placeholder="街道"
border="bottom"></u-input>
</u-form-item>
<u-form-item label="客户详细联系地址" prop="khlxdzxxdz" labelWidth="180"
v-show="openType === 1 || openType === 2">
<u-input v-model="khxx.khlxdzxxdz" :disabled="!openType" disabled-color="#fff"
placeholder="请输入客户详细联系地址" border="bottom"></u-input>
</u-form-item>
<u-form-item label="客户身份证号" labelWidth="180">
<u-input v-model="khxx.khsfzh" maxlength="18" placeholder="请输入客户身份证号" :disabled="!openType"
disabled-color="#fff" border="bottom"></u-input>
</u-form-item>
<u-form-item label="企业统一社会信用代码" maxlength="18" labelWidth="180" v-if="khxx.khlx === '非居民'">
<u-input v-model="khxx.qytyshxydm" placeholder="请输入企业统一社会信用代码" :disabled="!openType"
disabled-color="#fff" border="bottom"></u-input>
</u-form-item>
</view>
<view class="usuallyCard margin-sm padding" v-if="!openType">
<view class="text-lg margin-bottom">
用气信息
</view>
<u-form-item label="收货人" labelWidth="180">
<u-input v-model="khxx.shr" placeholder="请输入用气地址" :disabled="!openType" disabled-color="#fff"
border="bottom"></u-input>
</u-form-item>
<u-form-item label="收货人联系电话" labelWidth="180">
<u-input v-model="khxx.shrdh" placeholder="请输入用气地址" :disabled="!openType" disabled-color="#fff"
border="bottom"></u-input>
</u-form-item>
<u-form-item label="收货地址" labelWidth="180">
<u-input v-model="khxx.shrdz" placeholder="请输入用气地址" :disabled="!openType" disabled-color="#fff"
border="bottom"></u-input>
</u-form-item>
<u-form-item label="末次安装时间" labelWidth="180">
<u-input v-model="khxx.mcazsj" placeholder="末次安装时间" :disabled="!openType" disabled-color="#fff"
border="bottom"></u-input>
</u-form-item>
<u-form-item label="备注" labelWidth="180">
<u-input v-model="khxx.bz" placeholder="备注信息" :disabled="!openType" disabled-color="#fff"
border="bottom"></u-input>
</u-form-item>
</view>
</u--form>
<u-datetime-picker ref="datetimePicker" :show="dateShow" v-model="value1" mode="date" @cancel="dateShow = false"
:formatter="formatter" @confirm="handleConfirm"></u-datetime-picker>
</view>
</template>
<script>
export default {
name: "step1",
components: {},
props: {
openType: {
type: Number,
default: 0
},
ddid: {
type: String,
default: ""
}
},
watch: {
// khxxData:{
// handler(){
// this.khxx = {...this.khxxData}
// console.log("当前客户信息111111",this.khxx);
// },
// immediate: true,
// deep:true
// }
},
data() {
return {
radiolist: [{
name: '居民',
disabled: false
},
{
name: '非居民',
disabled: false
},
],
khxx: {
khlx: "", //客户类型 必填
khmc: "", //客户名称 必填
khlxdh: "", //客户联系电话 必填
khsfzh: "", //客户身份证号
khlxdzsf: "", //省
khlxdzs: "", //市
khlxdzq: "", //区
khlxdzjd: "", //街道
khlxdzxxdz: "", //客户联系地址
qytyshxydm: "", //企业统一社会信用代码
yqdz: "", //用气地址
mcazsj: "", //末次安装时间
bz: "", //备注
jd: "",
wd: "",
shr: null,
shrdh: null,
shrdz: null
},
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']
},
},
dateShow: false,
value1: Number(new Date()),
aiText: "", //ai识别文本
};
},
mounted() {
console.log("mounted", this.openType);
this.$refs.datetimePicker.setFormatter(this.formatter);
//获取定位
this.getLocal();
// 根据订单id自动查询会员信息 type类型为0
if (this.openType === 0) {
this.getOrderByid();
}
},
methods: {
getLocal() {
console.log("执行定位");
let that = this;
uni.getLocation({
type: 'gcj02',
success: function(res) {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
// that.khxx.jd = res.longitude;
// that.khxx.wd = res.latitude;
}
});
},
async getOrderByid() {
let query = {
oracleId: this.ddid
}
this.$api.orderApi.getOrderByid(query).then(res => {
console.log("订单id查询会员信息", res);
if (res.code === 200) {
let data = res.value;
console.log('data------------->', data);
this.khxx.khlx = data.fHylx;
this.khxx.khmc = data.fHymc;
this.khxx.khlxxm = data.fHymc;
this.khxx.khlxdh = data.fHydh;
this.khxx.khsfzh = data.fSfzh;
this.khxx.shr = data.fShlxr;
this.khxx.shrdh = data.fShlxrdh;
this.khxx.shrdz = data.fShsf + ' ' + data.fShs + ' ' + data.fShq + ' ' + data.fShjd +
' ' + data.fShxxdz
this.khxx.qytyshxydm = data.fShtysbm || "";
this.khxx.mcazsj = data.mcazsj || "-";
this.khxx.bz = data.fMjly;
this.khxx.jd = data.fShdzjd;
this.khxx.wd = data.fShdzwd;
console.log("填充会员信息", this.khxx);
}
})
},
openMap() {
let that = this;
uni.chooseLocation({
success: function(res) {
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);
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();
console.log("街道", street);
that.$set(that.khxx, 'khlxdzjd', that.$streetOrNot(street) ? street : extractedText || "");
// that.$set(that.khxx, 'khlxdzxxdz', geocodes.formatted_address);
} else {
uni.$u.toast('地址解析失败')
}
},
fail(err) {
console.log(err, "获取位置失败信息")
uni.$u.toast(err);
}
})
},
radioChange() {},
formatter(type, value) {
if (type === 'year') {
return `${value}年`
}
if (type === 'month') {
return `${value}月`
}
if (type === 'day') {
return `${value}日`
}
return value
},
async handleAi() {
let that = this;
console.log("待识别内容2", this.aiText);
if (!this.aiText) {
uni.$u.toast('请输入内容');
return;
}
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.khlx = data.fHylx;
this.khxx.khmc = 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 || "";
setTimeout(() => {
that.$modal.closeLoading();
}, 500)
} else {
uni.$u.toast('未查询到用户信息');
console.log();
}
})
},
handleConfirm(e) {
this.dateShow = false;
console.log("选择日期", e);
let timestamp = e.value;
let time = uni.$u.timeFormat(timestamp, 'yyyy年mm月dd号');
this.khxx.mcazsj = time;
console.log("格式化日期", this.khxx.mcazsj);
},
validate() {
let that = this;
console.log('校验', JSON.parse(JSON.stringify(this.khxx)));
if (!this.khxx.khlx) {
uni.$u.toast('请先选择客户类型');
return;
}
return new Promise((resolve, reject) => {
that.$refs.uForm.validate().then(valid => {
// uni.$u.toast('校验通过')
resolve(true);
}).catch(errors => {
// uni.$u.toast('校验失败')
resolve(false);
})
});
}
}
}
</script>
<style lang="scss" scoped>
</style>