|
@@ -35,6 +35,11 @@
|
|
const baseUrl = config.baseUrl
|
|
const baseUrl = config.baseUrl
|
|
import {uploadmore} from '@/utils/common.js'
|
|
import {uploadmore} from '@/utils/common.js'
|
|
import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
|
|
import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
|
|
|
|
+ import permijs from '@/utils/permission.js'
|
|
|
|
+
|
|
|
|
+ // #ifdef APP-PLUS
|
|
|
|
+ const lyBDFaceAuth = uni.requireNativePlugin('longyoung-BDFaceAuth'); //android
|
|
|
|
+ // #endif
|
|
export default{
|
|
export default{
|
|
components:{},
|
|
components:{},
|
|
data(){
|
|
data(){
|
|
@@ -46,13 +51,158 @@
|
|
ftipc:require('@/work/static/images/prove/ftipc.png'),
|
|
ftipc:require('@/work/static/images/prove/ftipc.png'),
|
|
user:{
|
|
user:{
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ licenseIDStr: 'longyoung-face-android',
|
|
|
|
+ items: [{
|
|
|
|
+ value: 'Eye',
|
|
|
|
+ name: '眨眨眼',
|
|
|
|
+ checked: 'true'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ value: 'Mouth',
|
|
|
|
+ name: '张张嘴',
|
|
|
|
+ checked: 'true'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ value: 'HeadLeft',
|
|
|
|
+ name: '向左转头'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ value: 'HeadRight',
|
|
|
|
+ name: '向右转头'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ value: 'HeadLeftOrRight',
|
|
|
|
+ name: '左右摇头'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ value: 'HeadUp',
|
|
|
|
+ name: '缓慢抬头'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ value: 'HeadDown',
|
|
|
|
+ name: '缓慢低头'
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ isLivenessRandom: 0,
|
|
|
|
+ isSound: 1,
|
|
|
|
+ txtColor:'#3987FD',
|
|
|
|
+ bgColor:'#2F2F33',
|
|
|
|
+ roundColor:'#3987FD',
|
|
|
|
+
|
|
|
|
+ resultStr: "",
|
|
|
|
+ imgBase64Str: ""
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ onLoad() {
|
|
|
|
+ //权限
|
|
|
|
+ // #ifdef APP-PLUS
|
|
|
|
+ if (uni.getSystemInfoSync().platform == "ios") {
|
|
|
|
+ // this.judgeIosPermission('camera');//相机
|
|
|
|
+ this.licenseIDStr = "longyoung-face-ios";
|
|
|
|
+ } else if (uni.getSystemInfoSync().platform == "android") {
|
|
|
|
+ this.requestAndroidPermission('android.permission.CAMERA'); //相机
|
|
|
|
+ // this.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE');//外部存储(含相册)读取权限
|
|
|
|
+ // this.requestAndroidPermission('android.permission.WRITE_EXTERNAL_STORAGE');//外部存储(含相册)写入权限
|
|
|
|
+ this.licenseIDStr = "longyoung-face-android";
|
|
|
|
+ }
|
|
|
|
+ // #endif
|
|
|
|
+ },
|
|
methods:{
|
|
methods:{
|
|
checkPermi, checkRole,
|
|
checkPermi, checkRole,
|
|
getSumit(){
|
|
getSumit(){
|
|
- this.$tab.navigateTo("/work/pages/prove/addqy")
|
|
|
|
|
|
+ // this.$tab.navigateTo("/work/pages/prove/addqy")
|
|
|
|
+ },
|
|
|
|
+ //刷脸
|
|
|
|
+ onScanFace() {
|
|
|
|
+ console.error("tagg.onScanFace");
|
|
|
|
+
|
|
|
|
+ self = this;
|
|
|
|
+
|
|
|
|
+ var ary = [];
|
|
|
|
+ for (var i = 0; i < this.items.length; i++) {
|
|
|
|
+ var item = this.items[i];
|
|
|
|
+ if (item.checked) {
|
|
|
|
+ ary[i] = item.value;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (uni.getSystemInfoSync().platform == "android") {//安卓
|
|
|
|
+ lyBDFaceAuth.scanFace({
|
|
|
|
+ licenseID: this.licenseIDStr,
|
|
|
|
+ actionAry: ary, //不传无动作
|
|
|
|
+ isLivenessRandom: this.isLivenessRandom, //不传默认有序,0有序,1随机
|
|
|
|
+ isSound: this.isSound, //不传默认有声音,0无声,1有声
|
|
|
|
+ txtColor:this.txtColor,//文字颜色
|
|
|
|
+ bgColor:this.bgColor,//背景颜色
|
|
|
|
+ roundColor:this.roundColor//圆的颜色
|
|
|
|
+ }, result => {
|
|
|
|
+ console.log('file://' + result.imgPath);
|
|
|
|
+
|
|
|
|
+ self.resultStr = "返回结果:\n" + JSON.stringify(result);
|
|
|
|
+
|
|
|
|
+ //图片上传服务器
|
|
|
|
+ uni.uploadFile({
|
|
|
|
+ url: 'http://api.longyoung.com/api/open/common/uploadImgTemp', //图片上传地址
|
|
|
|
+ filePath: 'file://' + result.imgPath, //图片本地路径,上传服务器需要加这个头'file://'
|
|
|
|
+ method: 'post',
|
|
|
|
+ name: 'imgFile', //上传图片参数名
|
|
|
|
+ success: (res) => {
|
|
|
|
+ var data = res.data;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ //***有些同学,后台强烈要求传base64,下面是图片转base64的方法,没此需求的可以无视。
|
|
|
|
+ var bitmapT = new plus.nativeObj.Bitmap("test"); //test标识随便取
|
|
|
|
+ // 从本地加载Bitmap图片
|
|
|
|
+ bitmapT.load(result.imgPath, function() {
|
|
|
|
+ console.log('加载图片成功');
|
|
|
|
+ var base4 = bitmapT.toBase64Data();
|
|
|
|
+ console.log('lygg.base64=' + base4);
|
|
|
|
+ self.resultStr = self.resultStr + "\n======base64字符串(太长,截取前100字符):\n" + base4.substring(0, 100);
|
|
|
|
+ self.imgBase64Str = base4.replace(/[\r\n]/g, ""); //显示图片
|
|
|
|
+ }, function(e) {
|
|
|
|
+ console.log('加载图片失败:' + JSON.stringify(e));
|
|
|
|
+ });
|
|
|
|
+ //***有些同学,后台强烈要求传base64,下面是图片转base64的方法,没此需求的可以无视。
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ } else if (uni.getSystemInfoSync().platform == "ios") {//苹果
|
|
|
|
+ lyBDFaceAuthIOS.scanFace({
|
|
|
|
+ licenseID: this.licenseIDStr,
|
|
|
|
+ actionAry: ary, //不传无动作
|
|
|
|
+ isLivenessRandom: this.isLivenessRandom, //不传默认有序,0有序,1随机
|
|
|
|
+ isSound: this.isSound, //不传默认有声音,0无声,1有声
|
|
|
|
+ }, result => {
|
|
|
|
+ console.log('result=' + result);
|
|
|
|
+ self.resultStr = "返回结果(太长,截取前100字符):\n" + JSON.stringify(result).substring(0, 100);
|
|
|
|
+ self.resultStr = self.resultStr + "\n======base64字符串(太长,截取前100字符):\n" + result.bestImgBase64.substring(0, 100);
|
|
|
|
+ self.imgBase64Str = "data:image/png;base64," + result.bestImgBase64.replace(/[\r\n]/g, ""); //显示图片
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ //权限
|
|
|
|
+ async requestAndroidPermission(permisionID) {
|
|
|
|
+ var result = await permijs.requestAndroidPermission(permisionID);
|
|
|
|
+ var strStatus;
|
|
|
|
+ if (result == 1) {
|
|
|
|
+ strStatus = "已获得授权";
|
|
|
|
+ } else if (result == 0) {
|
|
|
|
+ strStatus = "未获得授权";
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: "请打开权限,否则无法使用",
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ strStatus = "被永久拒绝权限";
|
|
|
|
+ permijs.gotoAppPermissionSetting();
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '请打开权限,否则无法使用',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ console.log("lygg.strStatus=" + strStatus + ",result=" + result);
|
|
},
|
|
},
|
|
}
|
|
}
|
|
}
|
|
}
|