realName.vue
4.9 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
<template>
<view class="realName">
<view class="title">
实名认证
</view>
<view class="contail">
<view class="bar">
<view class="beforename">
姓名:
</view>
<input type="text" placeholder="请输入" v-model="kname">
</view>
<view class="bar">
<view class="beforename">
身份证号:
</view>
<input type="text" placeholder="请输入" v-model="kidentity">
</view>
<view class="imgbar" @click="chooseImgs(1)">
<view class="mytitle">身份证照片</view>
<image class="image_s" :src="head_image" mode="" v-if="head_image"></image>
<image class="image_s" src="../../static/img_card_b.png" mode="" v-else></image>
<view class="tip">
点击相机拍摄头像面
</view>
<image class="image_b" src="../../static/icon_square_cream.png" mode="" v-if="!head_image"></image>
</view>
<view class="imgbar" @click="chooseImgs(2)">
<image class="image_s" :src="last_image" mode="" v-if="last_image"></image>
<image class="image_s" src="../../static/img_card_a.png" mode="" v-else></image>
<view class="tip">
点击相机拍摄国徽面
</view>
<image class="image_b"></image>
<image class="image_b" src="../../static/icon_square_cream.png" mode="" v-if="!last_image"></image>
</view>
</view>
<view class="btn">
<view class="paybtn" @click="user_cert">
提交
</view>
</view>
</view>
</template>
<script>
import {
user_cert
} from '@/api/index.js'
import {
baseURL
} from '@/utils/request.js'
export default {
data() {
return {
kname: "",
kidentity: "",
head_image: "../../static/icon_square_cream.png",
last_image: "../../static/icon_square_cream.png",
}
},
onLoad() {
},
methods: {
//实名认证
async user_cert() {
let obj = {
name: this.kname,
identity: this.kidentity,
image_front: this.head_image,
image_back: this.last_image,
}
try {
const res = await user_cert(obj)
console.log('user_cert', res)
let objk = uni.getStorageSync("showlist")
objk.is_cert = 1
uni.setStorageSync("showlist", objk)
uni.navigateBack({
delta: 1
})
// 保存数据
} catch (err) {
uni.showToast({
title: err,
icon: 'none'
})
console.log('user_cert', err)
}
},
//上传图片
chooseImgs(type) {
let that = this;
uni.chooseImage({ // 从本地选择图片或使用相机拍照
success: (res) => {
count: 1, // 最多可以选择的图片张数,默认为9张
console.log(res)
const tempFilePaths = res.tempFilePaths; // 成功的返回图片的本地路径列表
uni.uploadFile({ // 直接上传文件到云储存
url: baseURL + 'common/upload', //仅为示例,非真实的接口地址
filePath: res.tempFilePaths[0], // 要上传文件的对象
name: 'file',
formData: {
'user': 'test'
},
success: (uploadFileRes) => {
let data = JSON.parse(uploadFileRes.data);
console.log(data);
if (type == 1) {
that.head_image = data.data.fullurl; // 绝对路径
} else {
that.last_image = data.data.fullurl; // 绝对路径
}
}
});
}
})
return;
},
}
}
</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>