<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>
|