kaoshenginfo.vue
7.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
<template>
<div class="container">
<div class="weiquanlist">
<div class="weiquanitem flextwo">
<div class="weiguitou flexone">
<div class="nameleft">姓名</div>
<div class="nameitem nameitemk">
<input type="text" placeholder="输入姓名" v-model="name"/>
</div>
</div>
</div>
<div class="weiquanitem flextwo" @click="choseregion">
<div class="weiguitou flexone">
<div class="nameleft">籍贯</div>
<div class="nameitem nameitemk">
{{regionname}}
<!-- <input type="text" placeholder="输入籍贯" v-model="jiguan"/> -->
</div>
</div>
<img src="../../../assets/youjiantou.png" alt="" class="youjian" />
</div>
<div class="weiquanitem flextwo" @click="chosesex">
<div class="weiguitou flexone">
<div class="nameleft">性别</div>
<div class="nameitem nameitemk">{{sexname}}</div>
</div>
<img src="../../../assets/youjiantou.png" alt="" class="youjian" />
</div>
<div class="weiquanitem flextwo">
<div class="weiguitou flexone">
<div class="nameleft">联系方式</div>
<div class="nameitem nameitemk">
<input type="number" placeholder="输入联系方式" v-model="mobile"/>
</div>
</div>
</div>
<div class="weiquanitem flextwo">
<div class="weiguitou flexone">
<div class="nameleft">身份证号</div>
<div class="nameitem nameitemk">
<input type="text" placeholder="输入身份证号" v-model="card"/>
</div>
</div>
</div>
<div class="weiquanitem">
<div class="nameleft upheadimg">上传头像</div>
<!-- 上传图片 -->
<div class="addpicox flexone">
<!-- <div class="addpic" v-for="(item, index) in images" :key="index">
<image :src="item" mode=""></image>
<div class="delimg" @click="deleteimg(index)" :data-url="item">
<image src="../../../assets/close.png" mode=""></image>
</div>
</div> -->
<div class="flexone">
<van-uploader
v-model="fileList"
multiple="true"
:after-read="afterRead"
:max-count="1"
style="margin-right: 0.2rem"
/>
<!-- <img src="../../../assets/add.png" alt="" /> -->
</div>
</div>
</div>
</div>
<div class="baocun" @click="save">保存</div>
<!-- 选择男女 -->
<van-picker
title=""
show-toolbar
:columns="columns"
@confirm="onConfirm"
@cancel="onCancel"
v-if="showsex"
/>
<!-- 选择省市区 -->
<van-area title="" :area-list="areaList" :columns-num="2" @confirm="selectregion" @cancel="cancelregion" v-if="showregion"/>
<!-- 图片上传中 -->
<van-loading type="spinner" color="#1989fa" v-if="cardzheng" />
</div>
</template>
<script>
import Vue from 'vue';
import { Picker,Area, Toast } from 'vant';
import area from "../../../utils/region.js"
Vue.use(Area);
Vue.use(Picker);
export default {
data(){
return{
columns:["男","女"],
showsex:false,
sexname:'请选择性别',
name:"",
jiguan:'',
card:'',
mobile:"",
id:"",//考试类型
image:'',
chuanimg:'',
fileList:[],
examinee_gender:'',//性别
examinee_province_name:'',
examinee_city_name:'',
areaList:area,
showregion:false,
regionname:'请选择籍贯',
cardzheng:false,//图片上传中
}
},
created(){
document.body.style.backgroundColor = "#fff";
this.id= this.$route.query.id
},
methods:{
save(){
let that = this;
if(that.name==''){
Toast("请输入姓名");
return false
}
if(that.examinee_province_name==''){
Toast("请选择籍贯");
return false
}
if(that.examinee_gender==''){
Toast("请选择性别");
return false
}
if(that.mobile==''){
Toast("请输入联系方式");
return false
}
if (!(/^1[3456789]\d{9}$/.test(that.mobile))) {
Toast("请输入正确的联系方式");
return false;
}
if(that.card==''){
Toast("请输入身份证号");
return false
}
var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
if(!reg.test(that.card)){
Toast("请输入正确的身份证号");
return false
}
if(that.chuanimg==''){
Toast("请选择头像");
return false
}
var url = '/api/member/update_user';
var params = {
examinee_name:that.name,
examinee_province_name:that.examinee_province_name,
examinee_city_name:that.examinee_city_name,
examinee_gender:that.examinee_gender,
examinee_mobile:that.mobile,
examinee_card_number:that.card,
examinee_image:that.chuanimg
}
console.log('7766554', params)
that.$axios.post(url, params).then((res) => {
console.log(res);
Toast('提交成功')
that.$router.push({
path: '/examinetext',
query: { id: that.id }
})
}).catch((err) => {
console.log(err)
})
},
// 上传图片
afterRead(file) {
let that = this;
console.log(file);
console.log(file.length);
that.cardzheng = true;
if (file.length == undefined) {
var formdata = new FormData();
formdata.append("file", file.file);
var url = "/api/common/upload";
that.$uploadFile
.post(url, formdata)
.then(function (res) {
console.log(res);
let url = "https://app.chinesenooddles.com" + res.data.url;
that.image=url;
that.chuanimg=res.data.url;
that.cardzheng=false
})
.catch(err => {
console.log(err);
});
}
},
// 选择性别
chosesex(){
this.showsex=true
},
// 确定选择性别
onConfirm(value, index){
if(value=="男"){
this.examinee_gender=1
}else{
this.examinee_gender=2
}
this.sexname=value;
this.showsex=false
},
// 取消性别选择
onCancel(){
this.showsex=false
},
choseregion(){
this.showregion=true
},
// 确定选择省市区
selectregion(value,index){
console.log(value)
if(value[0].name=='北京市'){
this.regionname=value[0].name
}else if(value[0].name=='天津市'){
this.regionname=value[0].name
}else if(value[0].name=='上海市'){
this.regionname=value[0].name
}else if(value[0].name=='重庆市'){
this.regionname=value[0].name
}else{
this.regionname=value[0].name+value[1].name
}
this.examinee_province_name=value[0].name;
this.examinee_city_name=value[1].name;
this.showregion=false
},
// 取消选择地区
cancelregion(){
this.showregion=false
}
}
};
</script>
<style scoped>
@import "../../style/homepage.css";
.baocun {
width: 6.35rem;
height: 0.97rem;
background: #c68c3e;
border-radius: 0.31rem;
color: #fff;
font-size: 0.32rem;
text-align: center;
line-height: 0.97rem;
margin:2rem auto 0
}
.nameleft{
color: #333;
font-size: 0.28rem;
}
.upheadimg{
margin-bottom:0.2rem
}
/* 选择性别弹层 */
.van-picker{
position:fixed;
left:0;
bottom:0;
width:100%
}
.van-loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 99;
}
</style>