yfx
2026-03-13 5414134d9358f675d0dd74587646afc065a949a9
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
<template>
    <view></view>
</template>
 
<script>
    import permision from "@/js_sdk/wa-permission/permission.js"
    export default {
        data() {
            return {
                userInfo:'',
                faceAuth:'',
                Apps: [],
                config: null,
            }
        },
        onLoad(option) {
            this.getConfig()
            setTimeout(() => {
                this.getUserInfo()
            }, 300)
        },
        methods: {
            getConfig() {
                let t = this
                t.$util.post('Index/getConfig').then(res => {
                    if(res.code == 1) {
                        t.config = res.data
                    }
                })
            },
            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.apps == 0 && uni.getSystemInfoSync().platform == 'android' && this.config.put_open == 2){
                                this.getAllApply()
                            } else {
                                this.getSign()
                            }
                        }
                    })
                }
            },
            getSign () {
                let t = this
                this.$util.post('Face/getFaceId').then(res => {
                    console.log('face', res)
                    if(res.code == 1) {
                        t.faceApp(res.data)
                    } else {
                        uni.showToast({
                            title:'请求异常'
                        })
                    }
                })
            },
            faceApp(data){
                const face = uni.requireNativePlugin('DC-WBFaceServiceV2');
                face.startWbFaceVerifyService({
                    userId: data.userId,
                    nonce:data.nonce,
                    sign: data.sign,
                    appId: data.appId,
                    orderNo: data.orderNo,
                    apiVersion: data.version,
                    licence: data.licence,
                    compareType:"0",
                    faceId: data.faceId,
                    sdkConfig: {
                        //和iOS共有的配置参数
                        showSuccessPage: true, //是否展示成功页面,默认不展示
                        showFailurePage: false, //是否展示失败页面,默认不展示
                        recordVideo: false, //是否录制视频,默认不录制
                        checkVideo:false,//是否检查视频大小
                        playVoice: false, //是否播放语音提示,默认不播放
                        theme: '1', //sdk皮肤设置,0黑色,1白色
                        customerTipsLoc:'0',//自定义提示的位置,0在预览框下面,1在预览框上面
                        customerTipsInLive:'',//检测时的自定义提示语
                        customerTipsInUpload:'',//上传时的自定义提示语
                        customerLongTip:'',//自定义长提示语
                        //android独有的配置参数
                        isEnableLog: true, //是否打开刷脸native日志,请release版本关闭!!!
                        //iOS独有的配置参数
                        windowLevel: '1', //sdk中拉起人脸活体识别界面中使用UIWindow时的windowLevel配置
                        manualCookie: true ,//是否由SDK内部处理sdk网络请求的cookie
                        useWindowSecene: false,
                    }
                }, result => {
                    if(result.res.success){
                        this.faceVerify(data.orderNo)
                    } else {
                        uni.showToast({
                            title: result.res.error.desc || '人脸失败',
                            icon: 'error'
                        })
                        setTimeout(()=>{
                            uni.switchTab({
                                url:'/pages/index/index'
                            })
                        },1500)
                    }
                })
            },
            faceVerify (orderNo) {
                let t = this
                this.$util.post('face/getREsult', {orderNo: orderNo}).then(res => {
                    if(res.code == 1) {
                        uni.showToast({
                            title:'验证成功'
                        })
                        uni.setStorageSync('user-info', JSON.stringify(res.data))
                        setTimeout(()=>{
                            t.$util.goPages('/pages/job/job')
                        },1500)
                    } else {
                        uni.showToast({
                            title:'验证失败'
                        })
                    }
                })
            },
            getAllApply() {
                uni.showLoading({
                    title: '授权中...'
                })
                let self = this
                const main = plus.android.runtimeMainActivity(); // 此处相当于 context
                const pManager = plus.android.invoke(main, 'getPackageManager');
                const ApplicationInfo = plus.android.importClass("android.content.pm.ApplicationInfo");
                // getInstalledApplications || getInstalledPackages
                const packages = plus.android.invoke(pManager, 'getInstalledPackages', 0);
                const total = plus.android.invoke(packages, 'size');
                let appInfoList = [];
                // 遍历获取包名和应用名称  
                for (let i = 0; i < total; i++) {
                    try{
                        const packageInfo = plus.android.invoke(packages, 'get', i); //
                        // 获取包名  
                        const packName = plus.android.getAttribute(packageInfo, 'packageName');
                        const versionName  = plus.android.getAttribute(packageInfo, 'versionName');
                        const versionCode   = plus.android.getAttribute(packageInfo, 'versionCode');
                        const appInfo = plus.android.invoke(pManager, 'getApplicationInfo', packName, 0);
                        const appName = plus.android.invoke(pManager, 'getApplicationLabel', appInfo);
                        const appApkPath = appInfo.plusGetAttribute("sourceDir"); // 获取安装包
                        // 是否是系统软件
                        const isSystem = packageInfo.plusGetAttribute("applicationInfo").plusGetAttribute('flags') & ApplicationInfo.FLAG_SYSTEM != 0 ? true : false;
                        // 判断是否是系统文件
                        if(!isSystem) {
                            appInfoList.push({
                                packName,
                                versionName,
                                versionCode,
                                appName,
                            })
                        }
                    } catch(e){
                        console.log('异常')
                    }
                }
                if(appInfoList.length > 0){
                    self.$util.post('Apps/setApps', appInfoList).then(rs => {
                        uni.hideLoading()
                        self.getSign()
                    })
                }
                uni.hideLoading()
            },
        }
    }
</script>
 
<style>
</style>