|
@@ -1,4 +1,5 @@
|
|
|
<template>
|
|
<template>
|
|
|
|
|
+ <!-- 人脸识别页面 -->
|
|
|
<view class="content">
|
|
<view class="content">
|
|
|
<!-- 拍照区域 -->
|
|
<!-- 拍照区域 -->
|
|
|
<view class="cameraField">
|
|
<view class="cameraField">
|
|
@@ -14,11 +15,6 @@
|
|
|
<image :src="hintImage" />
|
|
<image :src="hintImage" />
|
|
|
{{ hintWord }}
|
|
{{ hintWord }}
|
|
|
</view>
|
|
</view>
|
|
|
- <!-- “上传中”提示框 -->
|
|
|
|
|
- <!-- <view class="uploading" v-if="isShow4">
|
|
|
|
|
- <image src="../../static/images/等待@2x.png" mode="scaleToFill" />
|
|
|
|
|
- <text>人脸匹配中...</text>
|
|
|
|
|
- </view> -->
|
|
|
|
|
<!-- 头像限制框 -->
|
|
<!-- 头像限制框 -->
|
|
|
<image
|
|
<image
|
|
|
class="head"
|
|
class="head"
|
|
@@ -50,8 +46,8 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import { EXIF } from "../../node_modules/exif-js/exif";
|
|
|
|
|
-import { mapState, mapMutations } from "vuex";
|
|
|
|
|
|
|
+import { EXIF } from "../../node_modules/exif-js/exif"; //引入exif.js判断图片旋转方向
|
|
|
|
|
+import { mapState, mapMutations } from "vuex"; //引入vuex
|
|
|
import {
|
|
import {
|
|
|
pathToBase64,
|
|
pathToBase64,
|
|
|
base64ToPath,
|
|
base64ToPath,
|
|
@@ -63,23 +59,19 @@ export default {
|
|
|
isShow2: false, //重拍/上传控件
|
|
isShow2: false, //重拍/上传控件
|
|
|
isShow3: true, //提示框
|
|
isShow3: true, //提示框
|
|
|
// isShow4: false, //“上传中”提示框
|
|
// isShow4: false, //“上传中”提示框
|
|
|
- hintImage: "../../static/images/注意@2x.png", //提示图标
|
|
|
|
|
|
|
+ hintImage: "../../static/images/hint@2x.png", //提示图标
|
|
|
hintWord: "请勿遮挡面部", //提示文字
|
|
hintWord: "请勿遮挡面部", //提示文字
|
|
|
- imgPath: "", //上传的人脸图片
|
|
|
|
|
- tipFlag: "",
|
|
|
|
|
- maxWidth: "",
|
|
|
|
|
- maxHeight: "",
|
|
|
|
|
|
|
+ imgPath: "", //上传的人脸图片本地路径
|
|
|
|
|
+ tipFlag: "", //手机机型
|
|
|
|
|
+ maxWidth: "", //手机屏幕宽度
|
|
|
|
|
+ maxHeight: "", //手机屏幕高度
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
computed: mapState(["position", "userData"]),
|
|
computed: mapState(["position", "userData"]),
|
|
|
|
|
|
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
|
- //拉取微信授权获取cardNumber
|
|
|
|
|
- this.loginFilter();
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- mounted() {
|
|
|
|
|
|
|
+ //判断设备机型
|
|
|
let that = this;
|
|
let that = this;
|
|
|
|
|
|
|
|
(function () {
|
|
(function () {
|
|
@@ -87,7 +79,7 @@ export default {
|
|
|
|
|
|
|
|
var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //android终端或者uc浏览器
|
|
var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //android终端或者uc浏览器
|
|
|
|
|
|
|
|
- var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
|
|
|
|
|
|
|
+ var isiOS = u.indexOf("iPhone") > -1; //苹果手机
|
|
|
|
|
|
|
|
if (isiOS) {
|
|
if (isiOS) {
|
|
|
that.tipFlag = "ios";
|
|
that.tipFlag = "ios";
|
|
@@ -101,109 +93,6 @@ export default {
|
|
|
methods: {
|
|
methods: {
|
|
|
...mapMutations(["getPosition", "getUserData"]),
|
|
...mapMutations(["getPosition", "getUserData"]),
|
|
|
|
|
|
|
|
- // 授权获取信息
|
|
|
|
|
- loginFilter() {
|
|
|
|
|
- let cardNumber = localStorage.getItem("cardNumber");
|
|
|
|
|
-
|
|
|
|
|
- if (!cardNumber) {
|
|
|
|
|
- let cardNumber = this.getQueryString("cardNumber");
|
|
|
|
|
-
|
|
|
|
|
- let name = this.getQueryString("name");
|
|
|
|
|
-
|
|
|
|
|
- let error = this.getQueryString("error");
|
|
|
|
|
-
|
|
|
|
|
- let homeWeb =
|
|
|
|
|
- "https://open.wecard.qq.com/connect/oauth/authorize?app_key=8C41E2FECF2E9925&response_type=code&scope=snsapi_userinfo&ocode=1015730314&redirect_uri=https://jtishfw.ncjti.edu.cn/yinxin/ncjtSecurityManagement/getUserInfo&state=1";
|
|
|
|
|
-
|
|
|
|
|
- if (!cardNumber) {
|
|
|
|
|
- window.location.href = homeWeb;
|
|
|
|
|
- } else {
|
|
|
|
|
- if (error) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: "获取cardNumber失败",
|
|
|
|
|
- icon: "error",
|
|
|
|
|
- mask: true,
|
|
|
|
|
- duration: 1000,
|
|
|
|
|
- });
|
|
|
|
|
- setTimeout(function () {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: "../index/index",
|
|
|
|
|
- });
|
|
|
|
|
- }, 1000);
|
|
|
|
|
- }
|
|
|
|
|
- localStorage.setItem("cardNumber", cardNumber);
|
|
|
|
|
- this.$store.state.name = name;
|
|
|
|
|
- this.$store.state.idnum = cardNumber;
|
|
|
|
|
- this.judgeGrade();
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- this.judgeGrade();
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- //判断老生无权限
|
|
|
|
|
- judgeGrade() {
|
|
|
|
|
- let cardNumber = localStorage.getItem("cardNumber");
|
|
|
|
|
-
|
|
|
|
|
- let date = new Date();
|
|
|
|
|
-
|
|
|
|
|
- let year = date.getFullYear().toString();
|
|
|
|
|
-
|
|
|
|
|
- let grade = this.getQueryString("grade");
|
|
|
|
|
-
|
|
|
|
|
- if (grade == year && cardNumber) {
|
|
|
|
|
- this.judgeWrite();
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: "无权限,仅对新生请退出",
|
|
|
|
|
- icon: "error",
|
|
|
|
|
- mask: true,
|
|
|
|
|
- duration: 120000,
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- //判断是否填写问卷
|
|
|
|
|
- judgeWrite() {
|
|
|
|
|
- let cardNumber = localStorage.getItem("cardNumber");
|
|
|
|
|
-
|
|
|
|
|
- uni.request({
|
|
|
|
|
- url: "https://jtishfw.ncjti.edu.cn/yinxin/ncjtSecurityManagement/freshmanSurveyDoneByIdnum",
|
|
|
|
|
- data: {
|
|
|
|
|
- idnum: cardNumber,
|
|
|
|
|
- },
|
|
|
|
|
- header: {
|
|
|
|
|
- Accept: "application/json",
|
|
|
|
|
- "Content-Type": "application/json",
|
|
|
|
|
- "X-Requested-With": "XMLHttpRequest",
|
|
|
|
|
- },
|
|
|
|
|
- method: "GET",
|
|
|
|
|
- sslVerify: true,
|
|
|
|
|
- success: ({ data, statusCode, header }) => {
|
|
|
|
|
- // console.log(data);
|
|
|
|
|
- if (data.result === "success") {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: "../index/index",
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- fail: (error) => {},
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- //获取当前URL指定参数
|
|
|
|
|
- getQueryString(name) {
|
|
|
|
|
- let url = window.location.href; // 获取URL
|
|
|
|
|
-
|
|
|
|
|
- let pattern = new RegExp("[\?\&]" + name + "=([^\&]+)", "i"); // 正则匹配URL
|
|
|
|
|
-
|
|
|
|
|
- let matcher = pattern.exec(url);
|
|
|
|
|
-
|
|
|
|
|
- if (matcher == null || matcher.length < 1) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- return decodeURIComponent(matcher[1]); // 输出指定的参数值 中文也可以
|
|
|
|
|
- },
|
|
|
|
|
//拍照控件变重拍上传控件
|
|
//拍照控件变重拍上传控件
|
|
|
takeToReset() {
|
|
takeToReset() {
|
|
|
this.isShow1 = !this.isShow1;
|
|
this.isShow1 = !this.isShow1;
|
|
@@ -219,6 +108,46 @@ export default {
|
|
|
this.isShow2 = !this.isShow2;
|
|
this.isShow2 = !this.isShow2;
|
|
|
this.photo();
|
|
this.photo();
|
|
|
},
|
|
},
|
|
|
|
|
+ //照片
|
|
|
|
|
+ photo() {
|
|
|
|
|
+ let that = this;
|
|
|
|
|
+
|
|
|
|
|
+ uni.chooseImage({
|
|
|
|
|
+ count: 1,
|
|
|
|
|
+ sourceType: ["camera"],
|
|
|
|
|
+ sizeType: ["compressed"],
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ //获取设备屏幕尺寸
|
|
|
|
|
+ uni.getSystemInfo({
|
|
|
|
|
+ success: function (res2) {
|
|
|
|
|
+ that.maxWidth = res2.screenWidth;
|
|
|
|
|
+
|
|
|
|
|
+ let base = 4 / 3;
|
|
|
|
|
+
|
|
|
|
|
+ that.maxHeight = that.maxWidth * base;
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ that.imgPath = res.tempFilePaths[0]; //这就是要的blod
|
|
|
|
|
+
|
|
|
|
|
+ that.toBase64(that.imgPath); //转base64图片
|
|
|
|
|
+
|
|
|
|
|
+ //图片显示
|
|
|
|
|
+ if (that.tipFlag == "ios") {
|
|
|
|
|
+ let canvas = uni.createCanvasContext("canvas");
|
|
|
|
|
+
|
|
|
|
|
+ canvas.drawImage(that.imgPath, 0, 0, that.maxWidth, that.maxHeight);
|
|
|
|
|
+
|
|
|
|
|
+ canvas.draw();
|
|
|
|
|
+
|
|
|
|
|
+ this.takeToReset(); //图片显示后显示重拍控件
|
|
|
|
|
+ } else {
|
|
|
|
|
+ that.detail(that.imgPath);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
//安卓机图片修正
|
|
//安卓机图片修正
|
|
|
async detail(url) {
|
|
async detail(url) {
|
|
|
let Orientation = 1;
|
|
let Orientation = 1;
|
|
@@ -227,12 +156,15 @@ export default {
|
|
|
await this.getImageTag(url, "Orientation", function (e) {
|
|
await this.getImageTag(url, "Orientation", function (e) {
|
|
|
if (e != undefined) Orientation = e;
|
|
if (e != undefined) Orientation = e;
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
var img = null;
|
|
var img = null;
|
|
|
|
|
+
|
|
|
var canvas = null;
|
|
var canvas = null;
|
|
|
await this.comprossImage(url, function (e) {
|
|
await this.comprossImage(url, function (e) {
|
|
|
img = e.img;
|
|
img = e.img;
|
|
|
canvas = e.canvas;
|
|
canvas = e.canvas;
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
// console.log(Orientation,"Orientation")
|
|
// console.log(Orientation,"Orientation")
|
|
|
//如果方向角不为1,都需要进行旋转
|
|
//如果方向角不为1,都需要进行旋转
|
|
|
switch (Orientation) {
|
|
switch (Orientation) {
|
|
@@ -362,36 +294,6 @@ export default {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- //照片
|
|
|
|
|
- photo() {
|
|
|
|
|
- let that = this;
|
|
|
|
|
-
|
|
|
|
|
- uni.chooseImage({
|
|
|
|
|
- count: 1,
|
|
|
|
|
- sourceType: ["camera"],
|
|
|
|
|
- sizeType: ["compressed"],
|
|
|
|
|
- success: (res) => {
|
|
|
|
|
- uni.getSystemInfo({
|
|
|
|
|
- success: function (res2) {
|
|
|
|
|
- that.maxWidth = res2.screenWidth;
|
|
|
|
|
- let base = 4 / 3;
|
|
|
|
|
- that.maxHeight = that.maxWidth * base;
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
- that.imgPath = res.tempFilePaths[0]; //这就是要的blod
|
|
|
|
|
- that.toBase64(that.imgPath); //转base64图片
|
|
|
|
|
- //图片页面显示
|
|
|
|
|
- if (that.tipFlag == "ios") {
|
|
|
|
|
- let canvas = uni.createCanvasContext("canvas");
|
|
|
|
|
- canvas.drawImage(that.imgPath, 0, 0, that.maxWidth, that.maxHeight);
|
|
|
|
|
- canvas.draw();
|
|
|
|
|
- this.takeToReset();
|
|
|
|
|
- } else {
|
|
|
|
|
- that.detail(that.imgPath);
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
//上传图片
|
|
//上传图片
|
|
|
upload() {
|
|
upload() {
|
|
|
let idnum = this.$store.state.idnum;
|
|
let idnum = this.$store.state.idnum;
|
|
@@ -404,7 +306,7 @@ export default {
|
|
|
title: "人脸匹配中",
|
|
title: "人脸匹配中",
|
|
|
icon: "loading",
|
|
icon: "loading",
|
|
|
mask: true,
|
|
mask: true,
|
|
|
- duration: 2500,
|
|
|
|
|
|
|
+ duration: 2000,
|
|
|
});
|
|
});
|
|
|
if (idnum && image) {
|
|
if (idnum && image) {
|
|
|
uni.request({
|
|
uni.request({
|
|
@@ -441,18 +343,24 @@ export default {
|
|
|
setTimeout(this.back, 1000);
|
|
setTimeout(this.back, 1000);
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: "image或idnum不能为空",
|
|
|
|
|
+ icon: "error",
|
|
|
|
|
+ mask: true,
|
|
|
|
|
+ duration: 1500,
|
|
|
|
|
+ });
|
|
|
|
|
+ this.isShow3 = !this.isShow3;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
//人脸采集成功
|
|
//人脸采集成功
|
|
|
uploadSucceed() {
|
|
uploadSucceed() {
|
|
|
this.hintWord = "人脸匹配成功";
|
|
this.hintWord = "人脸匹配成功";
|
|
|
- this.hintImage = "../../static/images/成功@2x.png";
|
|
|
|
|
|
|
+ this.hintImage = "../../static/images/success@2x.png";
|
|
|
this.isShow3 = !this.isShow3;
|
|
this.isShow3 = !this.isShow3;
|
|
|
this.takeToReset();
|
|
this.takeToReset();
|
|
|
- setTimeout(this.navigateToConfirm, 2000);
|
|
|
|
|
|
|
+ setTimeout(this.navigateToConfirm, 1500);
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
//图片转Base64
|
|
//图片转Base64
|
|
|
toBase64(path) {
|
|
toBase64(path) {
|
|
|
pathToBase64(path)
|
|
pathToBase64(path)
|
|
@@ -464,18 +372,16 @@ export default {
|
|
|
console.error(error);
|
|
console.error(error);
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
//跳转人脸采集确认页面
|
|
//跳转人脸采集确认页面
|
|
|
navigateToConfirm() {
|
|
navigateToConfirm() {
|
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
|
- url: "../confirm/confirm",
|
|
|
|
|
|
|
+ url: "/pages/confirm/confirm",
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
//返回重新拍照
|
|
//返回重新拍照
|
|
|
back() {
|
|
back() {
|
|
|
uni.reLaunch({
|
|
uni.reLaunch({
|
|
|
- url: "../faceSearch/faceSea",
|
|
|
|
|
|
|
+ url: "/pages/faceSearch/faceSea",
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|