resident.vue
10.4 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
<template>
<view class="containers">
<view class="resident">
<view class="text-xl text-bold">
请扫描身份证的正反面
</view>
<view class="margin-top-sm" style="color:#ea5504;">
正面为国徽面 反面为头像面
</view>
<!-- 反面 -->
<view class="idCardWarp margin-top">
<view class="flex justify-between">
<view class="margin-top-xl">
<view class="text-xl text-bold">
头像面
</view>
<view class="text-gray margin-top-xs">
上传您身份证头像面
</view>
</view>
<view class="" style="position: relative;">
<view @click="upload(0,'fSfzrxy')">
<u-image v-if="picture[0]?picture[0].temp:''" :src="picture[0].temp" width="366rpx" height="236rpx"
@click="previewPicture(picture[0].temp)"></u-image>
<u-image v-else src="@/static/images/gas-icon/front.png" width="366rpx"
height="236rpx"></u-image>
</view>
<u-icon v-if="picture[0]?picture[0].temp:''" @click="deleteImg(0)" style="position: absolute; top:0px;right: 0px;" name="close-circle-fill" color="red" size="14"></u-icon>
<!-- <u-image src="" width="366rpx" height="236rpx" v-if="!idCardObj.back.length"></u-image>-->
<!-- <u-image :src="idCardObj.back[0]" width="366rpx" height="236rpx" v-else></u-image>-->
</view>
</view>
</view>
<!-- 正面 -->
<view class="idCardWarp margin-top">
<view class="flex justify-between">
<view class="margin-top-xl">
<view class="text-xl text-bold">
国徽面
</view>
<view class="text-gray margin-top-xs">
上传您身份证国徽面
</view>
</view>
<view class="" style="position: relative;">
<view @click="upload(1,'fSfzghy')" >
<u-image v-if="picture[1]?picture[1].temp:''" :src="picture[1].temp" width="366rpx" height="236rpx"
@click="previewPicture(picture[1].temp)"></u-image>
<u-image v-else src="@/static/images/gas-icon/back.png" width="366rpx"
height="236rpx"></u-image>
</view>
<u-icon v-if="picture[1]?picture[1].temp:''" @click="deleteImg(1)" style="position: absolute; top:0px;right: 0px;" name="close-circle-fill" color="red" size="14"></u-icon>
<!-- <u-image src="" width="366rpx" height="236rpx" v-if="!idCardObj.front.length"></u-image>-->
<!-- <u-image :src="idCardObj.front[0]" width="366rpx" height="236rpx" v-else></u-image>-->
</view>
</view>
</view>
<view class="idCardWarp margin-top">
<view class="flex flex-direction">
<view class="text-xl text-bold margin-tb flex">
请填写身份证信息<view class="text-grey">(必填)</view>
</view>
<u-form labelPosition="left" :model="idCardObj" :rules="rules" ref="uForm">
<view class="flex justify-between">
<u-form-item class="w50">
<u-input placeholder="姓名" v-model="idCardObj.name" border="none"></u-input>
</u-form-item>
<u-form-item class="w50">
<u-input placeholder="联系电话" v-model="idCardObj.phone" border="none"></u-input>
</u-form-item>
</view>
<view class="flex justify-between">
<u-form-item class="w50">
<u-input placeholder="性别" v-model="idCardObj.sex" disabled border="none">
<u-icon name="arrow-down" slot="suffix" @click="selectPickCloums('sex')"></u-icon>
</u-input>
</u-form-item>
<u-form-item class="w45">
<u-input placeholder="年龄" v-model="idCardObj.age" border="none"></u-input>
</u-form-item>
</view>
<u-form-item>
<u-input placeholder="身份证号" v-model="idCardObj.idcard" border="none"></u-input>
</u-form-item>
<u-form-item>
<u-input placeholder="有效期" v-model="idCardObj.termOfValidity" border="none">
<u-icon name="calendar" slot="suffix" @click="dateShow = true"></u-icon>
</u-input>
</u-form-item>
<u-form-item>
<u-input placeholder="认证气站" v-model="idCardObj.fSsczmc" disabled border="none">
<u-icon name="arrow-down" slot="suffix" @click="selectPickCloums('rzqz')"></u-icon>
</u-input>
</u-form-item>
</u-form>
</view>
</view>
</view>
<!-- 性别 -->
<u-picker ref="Sex" :show="pickShow" @close="pickShow=false" closeOnClickOverlay :columns="columns"
@cancel="pickShow=false" @confirm="sexConfirm"></u-picker>
<!-- 有效期 -->
<u-datetime-picker :show="dateShow" @close="dateShow=false" closeOnClickOverlay v-model="date" mode="date"
@cancel="dateShow=false" @confirm="dateConfirm"></u-datetime-picker>
</view>
</template>
<script>
import {
mapState
} from 'vuex';
export default {
props: {
},
components: {
},
watch: {},
data() {
return {
picture:[],
idCardObj: {
name: "",
phone: "",
sex: "",
age: "",
idcard: "",
termOfValidity: "",
front: [],
back: [],
fSsczmc:'',
fSsczID:''
},
date: Number(new Date()),
rules: {},
pickShow: false,
dateShow: false,
columns: [],
sexColumns:[
['男', '女']
],
formData: {
current: 1,
size: -1,
// jd: "114.347455", //PC无法定位调试使用
// wd: "30.504396", //PC无法定位调试使用
jd: "",
wd: "",
},
storeList:[],
pickType:''
}
},
computed: {
// 使用 mapState 辅助函数将 Vuex state 中的 adsJd 和 adsWd 映射到当前组件的计算属性中
...mapState({
adsJd: state => state.user.adsJd,
adsWd: state => state.user.adsWd
})
},
async mounted() {
console.log(this.$store);
// 如果未选择地址则获取当前定位
if (!this.adsJd && !this.adsWd) {
await this.getLocation();
}
console.log('打印是否出阿飞this.addJd',this.adsJd,this.adsWd)
await this.getStoreList();
},
onLoad(data) {
},
methods: {
//获取当前的定位
getLocation() {
let that = this;
return new Promise((resolve, reject) => {
uni.getLocation({
type: 'gcj02',
success: (res) => {
console.log('无地址,定位获取', JSON.parse(JSON.stringify(res)));
that.formData.jd = res.longitude;
that.formData.wd = res.latitude;
resolve(); // 成功获取经纬度后 resolve
},
fail: (error) => {
uni.$u.toast("定位失败");
console.log("定位失败",error);
reject(error); // 获取经纬度失败时 reject
}
});
});
},
//获取当前的订气站
async getStoreList() {
// 如果有选择的地址经纬度
if(this.adsJd && this.adsWd){
this.formData.jd = this.adsJd;
this.formData.wd = this.adsWd;
}
console.log('门店列表查询条件', JSON.parse(JSON.stringify(this.formData)));
const result = await this.$api.memberApi.getwCzxxList(this.formData);
let {
code,
value
} = result;
if (code === 200) {
const newlist = value.records;
this.storeList = newlist;
console.log('门店列表', JSON.parse(JSON.stringify(newlist)));
}
},
//上传图片
async upload(index,fileType) {
console.log("上传图片", index);
if(this.picture[index]){
return;
}
uni.chooseImage({
success: async (chooseImageRes) => {
console.log(chooseImageRes);
const tempFilePaths = chooseImageRes.tempFilePaths;
const result = await this.$api.fileApi.uploadFile(tempFilePaths[0]);
console.log('result=====>',result,this.picture);
this.$set(this.picture,index,{
temp:result.url,
fileId:result.response.fileId,
type:fileType,
fileObj: JSON.stringify(result)
});
// this.$set(this.picture,'temp',result.url);
console.log(this.picture);
}
});
},
//删除图片
deleteImg(index){
this.$set(this.picture,index,undefined);
console.log('打印this.picture',this.picture);
// this.picture[index] =empty//删除索引为index的元素
},
//预览图片
previewPicture(url) {
this.$previewPicture(url);
},
//选择选择器的数据
selectPickCloums(type){
this.pickShow = true;
this.pickType = type;
switch (type){
case 'sex':
this.columns = this.sexColumns;
break;
case 'rzqz':
let mcArrayList = this.storeList.map((item)=>item.fCzmc);
this.columns = [mcArrayList];
console.log('打印this.c',this.columns)
}
},
sexConfirm(e) {
console.log(e);
let value = e.value[0];
switch (this.pickType){
case "sex":
this.idCardObj.sex = value;
break;
case 'rzqz':
this.idCardObj.fSsczmc = value;
let choseObj = this.storeList.filter((item)=> item.fCzmc == value);
this.idCardObj.fSsczID = choseObj[0]?choseObj[0].id:'';
console.log('打印choseObj',choseObj);
break;
}
console.log(this.idCardObj.sex);
this.pickShow = false;
},
dateConfirm(e) {
console.log(e);
let date = this.$u.timeFormat(e.value, 'yyyy-mm-dd')
this.idCardObj.termOfValidity = date;
this.dateShow = false;
},
}
}
</script>
<style lang="scss" scoped>
.containers {}
.resident {
margin-top: 63rpx;
padding: 0 24rpx;
}
.idCardWarp {
background: #F4F5F8;
border-radius: 10rpx;
padding: 0 24rpx;
}
.noCardWarp {
background: #fff;
border-radius: 10rpx;
display: flex;
padding: 24rpx;
margin: 24rpx;
}
.cardWarp {
position: relative;
width: 306rpx;
height: 226rpx;
display: flex;
justify-content: center;
background: #F0F3F7;
border-radius: 14rpx;
}
.cardBar {
position: absolute;
bottom: 0;
width: 100%;
height: 56rpx;
background: #DEE8F8;
line-height: 56rpx;
background-color: #dee8f8;
border-radius: 0 0 14rpx 14rpx;
}
.cardBarText {
text-align: center;
color: #536CAA;
font-weight: bold;
}
</style>