realName.vue
6.1 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
<template>
<view class="realName">
<view class="title">
实名认证
</view>
<view class="contail">
<view class="bar">
<view class="beforename">
姓名:
</view>
<input type="text" v-model="name" placeholder="请输入">
</view>
<view class="bar">
<view class="beforename">
身份证号:
</view>
<input type="number" v-model="text" maxlength="18" placeholder="请输入">
</view>
<view class="imgbar">
<view class="mytitle">身份证照片 </view>
<image class="image_s" @click="upload(1)" :src="imageZ || '/static/img_card_b.png'" mode=""></image>
<view class="tip">
点击相机拍摄头像面
</view>
<image class="image_b" @click="upload(1)" v-if="!imageZ" src="/static/icon_square_cream.png" mode=""></image>
</view>
<view class="imgbar">
<image class="image_s" @click="upload(2)" :src="imageF || '/static/img_card_a.png'" mode=""></image>
<view class="tip">
点击相机拍摄国徽面
</view>
<image class="image_b" @click="upload(2)" v-if="!imageF" src="/static/icon_square_cream.png" mode=""></image>
</view>
</view>
<view class="btn">
<view class="paybtn" >
<input type="text" placeholder="请输入" v-model="name">
</view>
<view class="imgbar" @click="chooseImgs(1)">
<view class="mytitle">身份证照片</view>
<image class="image_s" :src="imageZ || '/static/img_card_b.png'" mode=""></image>
<!-- <image class="image_s" src="/static/img_card_b.png" mode="" v-else></image> -->
<view class="tip">
点击相机拍摄头像面
</view>
<image class="image_b" v-if="!imageZ" src="/static/icon_square_cream.png" mode="" ></image>
</view>
<view class="imgbar" @click="chooseImgs(2)">
<image class="image_s" :src="imageZ || '/static/img_card_a.png'" mode="" ></image>
<view class="tip">
点击相机拍摄国徽面
</view>
<image class="image_b" v-if="!imageZ"></image>
<image class="image_b" src="/static/icon_square_cream.png" mode="" ></image>
</view>
</view>
<view class="btn">
<view class="paybtn" @click="realAuthentication">
提交
</view>
</view>
</view>
</template>
<script>
var that
import { realAuthentication } from '@/api/send.js'
import { toa } from '@/utils/toast.js'
import {
uploadFile
} from '@/utils/upload.js'
export default {
data() {
return {
key: '',
name:'',
number:'',
imageZ:'',
imageF:'',
imgFrontShort:'',
imgBackShort:''
}
},
onLoad() {
that = this
},
methods: {
async realAuthentication(){
try {
let regCardnum = (
/^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
)
if (!regCardnum.test(this.number)) return toa.toast('请输入正确的身份证号码')
if(!this.name) return toa.toast('请输入姓名')
if(!this.number) return toa.toast('请输入身份证')
if(!this.imgFrontShort) return toa.toast('请上传身份证正面')
if(!this.imgBackShort) return toa.toast('请上传身份证反面')
//身份证
const res = await realAuthentication(this.name,this.number,this.imgFrontShort,this.imgBackShort)
var pages = getCurrentPages();
var page = pages[pages.length - 2];
page.$vm.lastInfo.is_cert = 1
page.$vm.show = false
setTimeout(()=>{
toa.success('实名认证成功')
},200)
uni.navigateBack({})
console.log('realAuthentication', res)
// 保存数据
} catch (err) {
uni.showToast({ title:err,icon:'none' })
console.log('realAuthentication', err)
}
},
upload(type){
uni.chooseImage({
count:1, //默认9
sizeType: ['original'], //可以指定是原图还是压缩图,默认二者都有 , 'original','compressed'
sourceType: ['album'], //从相册选择
success: async function(res) {
console.log(JSON.stringify(res.tempFilePaths));
const tempFilePaths = res.tempFilePaths;
for (let i = 0; i < tempFilePaths.length; i++) {
const result = await uploadFile(tempFilePaths[i])
if(type==1){
// console.log(result);
that.imageZ=result.fullurl
that.imgFrontShort=result.url
}else {
that.imageF=result.fullurl
that.imgBackShort=result.url
}
}
}
});
}
},
}
</script>
<style lang="scss">
.realName {
padding: 0 32rpx;
box-sizing: border-box;
.title {
margin-top: 32rpx;
color: rgba(0, 0, 0, 0.9);
font-size: 52rpx;
font-weight: 500;
font-family: "PingFang SC";
}
.contail {
margin-top: 32rpx;
padding-bottom: 160rpx;
.bar {
border-bottom: 1px solid #f0f0f0;
padding: 32rpx;
display: flex;
justify-content: space-between;
input {
text-align: right;
}
}
.imgbar {
text-align: center;
position: relative;
.mytitle {
margin-top: 32rpx;
text-align: left;
color: rgba(0, 0, 0, 0.9);
font-size: 28rpx;
font-weight: 400;
font-family: "PingFang SC";
}
.image_s {
margin-top: 32rpx;
width: 524rpx;
height: 330rpx;
}
.image_b {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 128rpx;
height: 128rpx;
}
.tip {
margin-top: 25rpx;
color: rgba(0, 0, 0, 0.4);
font-size: 28rpx;
font-weight: 400;
font-family: "PingFang SC";
}
}
}
.btn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 128rpx;
padding: 16rpx 32rpx;
box-sizing: border-box;
opacity: 1;
background: rgba(255, 255, 255, 1);
.paybtn {
width: 100%;
height: 96rpx;
line-height: 96rpx;
text-align: center;
border-radius: 28rpx;
opacity: 1;
color: rgba(0, 0, 0, 0.9);
font-size: 32rpx;
font-weight: 600;
font-family: "PingFang SC";
background: linear-gradient(134.8deg, rgba(255, 232, 100, 1) 0%, rgba(255, 216, 0, 1) 100%);
}
}
}
</style>