Parcourir la source

人脸核身板块

学习?学个屁 il y a 20 heures
Parent
commit
a7fa9e2ba3

+ 57 - 46
src/App.vue

@@ -1,50 +1,61 @@
 <script setup lang="ts">
-	import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
-	onLaunch(() => {
-		console.log("App Launch");
-	});
-	onShow(() => {
-		console.log("App Show");
-	});
-	onHide(() => {
-		console.log("App Hide");
-	});
+import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
+import { initEid} from '@/pages/mp_ecard_sdk/main'
+
+onLaunch(() => {
+	initEid()
+	console.log("App Launch");
+});
+onShow(() => {
+	console.log("App Show");
+});
+onHide(() => {
+	console.log("App Hide");
+});
 </script>
 <style lang="less">
- @import "@/styles/variables.less";
-	page {
-		background: #F6F6F6;
-	}
-	.content {
-		box-sizing: border-box;
-		padding: 0rpx 20rpx;
-		padding-bottom: 30rpx;
-	}
-	svg {
-	  overflow: hidden; /* 防止裁剪 */
-	  vertical-align: -0.15em; /* 图标对齐修正 */
-	}
-	.textHidden {
-		overflow: hidden !important;
-		white-space: nowrap !important;
-		text-overflow: ellipsis !important;
-	}
-	.mini-text{
-		font-size: 26rpx;
-		
-	}
-	.footer{
-		position: fixed;
-		display: flex;
-		align-items: center;
-		justify-content: space-between;
-		width: 710rpx;
-		height: 166rpx;
-		background: #FFFFFF;
-		box-shadow: 0rpx -6rpx 12rpx 2rpx rgba(0, 0, 0, 0.09);
-		border-radius: 32rpx 32rpx 0rpx 0rpx;
-		bottom: 0;
-		padding: 0 20rpx;
-		z-index: 9999;
-	}
+@import "@/styles/variables.less";
+
+page {
+	background: #F6F6F6;
+}
+
+.content {
+	box-sizing: border-box;
+	padding: 0rpx 20rpx;
+	padding-bottom: 30rpx;
+}
+
+svg {
+	overflow: hidden;
+	/* 防止裁剪 */
+	vertical-align: -0.15em;
+	/* 图标对齐修正 */
+}
+
+.textHidden {
+	overflow: hidden !important;
+	white-space: nowrap !important;
+	text-overflow: ellipsis !important;
+}
+
+.mini-text {
+	font-size: 26rpx;
+
+}
+
+.footer {
+	position: fixed;
+	display: flex;
+	align-items: center;
+	justify-content: space-between;
+	width: 710rpx;
+	height: 166rpx;
+	background: #FFFFFF;
+	box-shadow: 0rpx -6rpx 12rpx 2rpx rgba(0, 0, 0, 0.09);
+	border-radius: 32rpx 32rpx 0rpx 0rpx;
+	bottom: 0;
+	padding: 0 20rpx;
+	z-index: 9999;
+}
 </style>

+ 6 - 1
src/pages.json

@@ -118,6 +118,12 @@
 				"navigationBarTitleText": "本人身份认证"
 			}
 		},
+		{
+			"path": "pages/mp_ecard_sdk/index/index",
+			"style": {
+				"navigationBarTitleText": "腾讯云E证通授权"
+			}
+		},
 		{
 			"path": "pages/index/training/index",
 			"style": {
@@ -311,7 +317,6 @@
 			"style": {
 				"navigationBarTitleText": "index",
 				"navigationBarTitleText": "合同签署"
-
 			}
 		}
 	],

+ 28 - 30
src/pages/index/attestation/index.vue

@@ -48,10 +48,11 @@
 	</view>
 </template>
 
-<script lang="ts" setup>
+<script setup>
 import { ref } from 'vue';
 import { http } from '@/utils/http';
 import { TipsUtils, ValidateUtils } from '@/utils/util';
+import { startEid } from '@/pages/mp_ecard_sdk/main'
 import { uploadImage } from '@/utils/common/upload'
 import { useCacheStore } from '@/stores/cache'
 const cache = useCacheStore()
@@ -93,11 +94,13 @@ const handleChange = (e) => {
 }
 
 const submit = () => {
+	startVerification()
+	return
 	if (!formData.value.idCardFrontImg) return TipsUtils.tips_toast('请上传人像面');
 	if (!formData.value.idCardBackImg) return TipsUtils.tips_toast('请上传国徽面');
 	if (!formData.value.fullName) return TipsUtils.tips_toast('请输入姓名');
-	if(!ValidateUtils.validateIdCard(formData.value.identityCard)) return TipsUtils.tips_toast('身份证号码格式不正确');
-	if(!ValidateUtils.validatePhone(formData.value.phone)) return TipsUtils.tips_toast('手机号格式不正确');
+	if (!ValidateUtils.validateIdCard(formData.value.identityCard)) return TipsUtils.tips_toast('身份证号码格式不正确');
+	if (!ValidateUtils.validatePhone(formData.value.phone)) return TipsUtils.tips_toast('手机号格式不正确');
 	if (!formData.value.realNameImg) return TipsUtils.tips_toast('请上传本人近期高清、无遮挡照片');
 	http.post('/my/familyMembers/addFamilyMembers', { ...formData.value }, { loading: true }).then((res) => {
 		TipsUtils.tips_toast(res.message)
@@ -110,34 +113,29 @@ const submit = () => {
 		frontImg.value = ''
 		flipSideImg.value = ''
 	})
+}
 
-	// uni.navigateTo({
-	// 	url: '/pages/index/identityCertifying/index'
-	// })
-	// uni.checkIsSupportSoterAuthentication({
-	// 	success: (res) => {
-	// 		wx.startFacialRecognitionVerify({
-	// 			name: '',
-	// 			idCardNumber: '',
-	// 			success: (res) => {
-	// 				if (res.errMsg == 'startFacialRecognitionVerify:ok') {
-	// 					console.log(res,'人脸识别结果:success');
-	// 				}
-	// 			},
-	// 			fail: (err) => {
-	// 				console.log(err,'人脸识别结果:fail')
-	// 				uni.showToast({
-	// 					title: '人脸识别失败',
-	// 					icon: 'none',
-	// 					duration: 20000,
-	// 				});
-	// 			}
-	// 		})
-	// 	},
-	// 	fail: (err) => {
-	// 		console.log(err)
-	// 	}
-	// })
+// 开始身份验证
+const verifyToken = ref('')
+const startVerification = () => {
+	console.log('开始身份验证');
+	startEid({
+		data: {
+			token: verifyToken.value,
+			needJumpPage: true
+		},
+		verifyDoneCallback(res) {
+			console.log('收到核身完成的res:', res);
+			const { token, verifyDone } = res;
+			console.log('收到核身完成的res:', res);
+			console.log('核身的token是:', token);
+			console.log('是否完成核身:', verifyDone);
+			if (verifyDone) {
+				formData.value.realNameStatus = 1;
+				verifyToken.value = token;
+			}
+		},
+	});
 }
 </script>
 

+ 6 - 7
src/pages/index/gymDetail/components/popup.vue

@@ -1,5 +1,5 @@
 <template>
-	<uni-popup ref="selectPopup" :safe-area="false" type="bottom">
+	<uni-popup ref="selectPopup" :safe-area="false" type="bottom"  :animation="false">
 		<view class="header-text">开场前{{ listData.earlyRefundTime || '--' }}分钟随时退</view>
 		<view class="select-popup">
 			<view class="pop-title">选择场次</view>
@@ -175,10 +175,11 @@ watch(
 	{ immediate: true }
 );
 
-const open = () => {
+const opens = () => {
 	// 打开弹窗时赋值默认日期,优先根据deteSelIndex
-	that.$refs.selectPopup.open();
-	// selectPopup.value.open();
+	// that.refs.selectPopup?.open();
+	// console.log(getCurrentInstance(),'that.$refs');
+	selectPopup.value?.open('top');
 	if (
 		props.listData &&
 		Array.isArray(props.listData.stadiumConcertsVOList) &&
@@ -193,9 +194,7 @@ const open = () => {
 		weekDayDate.value = '';
 	}
 }
-defineExpose({
-	open
-})
+defineExpose({opens})
 const weekDayDate = ref();
 const sel_tab = (e, i) => {
 	emit('change', e, i);

+ 4 - 3
src/pages/index/gymDetail/index.vue

@@ -313,9 +313,10 @@ const open_popup = (e, i) => {
 	selIndex.value = i
 	dateIndex.value = e
 	get_placeInfoDetail(categoryId.value, i)
-	console.log(openPopup.value, 'openPopup');
-	openPopup.value?.open()
-
+	// console.log(openPopup.value, 'openPopup');
+	openPopup.value?.opens()
+	console.log(openPopup.value,'openPopup');
+	
 }
 
 // 获取所有模块的位置信息

+ 1 - 0
src/pages/mp_ecard_sdk/constants/log.js

@@ -0,0 +1 @@
+const Log={version:"uni_1.0.5__stable",SourceType:"mp_sdk_uni",getIntoIndexPage:"START_INDEX",initSdk:"INIT_SDK",getConfig:"GET_CONFIG",getConfigRetry:"GET_CONFIG_BY_RETRY",webViewResult:"WEBVIEW_RESULT",webViewError:"WEBVIEW_ERROR",navigateToEid:"NAVIGATE_TO_EID",navigateBackFromEid:"NAVIGATE_BACK_FROM_EID",navigateBackFromEidFail:"NAVIGATE_BACK_FROM_EID_FAIL",startEid:"START_EID",startEidFail:"START_EID_FAIL",eidVerifyDone:"EID_VERIFY_DONE",requestFail:"REQUEST_FAIL",requestCatch:"REQUEST_CATCH",onAppShow:"ON_APP_SHOW"};export default Log;

+ 1 - 0
src/pages/mp_ecard_sdk/globalConfig.js

@@ -0,0 +1 @@
+export default{normalPath:"/pages"};

+ 1 - 0
src/pages/mp_ecard_sdk/index.css

@@ -0,0 +1 @@
+.auth{margin-top:128rpx;display:flex;flex-direction:column;align-items:center}.auth-logo{width:200rpx;height:200rpx}.auth-logo image{height:100%;width:100%}.title{margin-top:20rpx;font-size:36rpx;line-height:56rpx}.merchant-name{display:inline;font-weight:700}.sub-title{margin-top:8rpx;font-size:34rpx;line-height:52rpx}.button-area{margin-top:48rpx}.button-area button{width:622rpx;height:96rpx;background:#fff;border:2rpx solid #ddd;font-size:32rpx;font-weight:400;line-height:96rpx;padding:0}.redirect{margin-top:272rpx;display:flex;flex-direction:column;align-items:center}.loading{height:160rpx;width:160rpx;margin-bottom:32rpx}.loading image{height:100%;width:100%}.title{font-size:34rpx;line-height:52rpx}

+ 1 - 0
src/pages/mp_ecard_sdk/index/index.js

@@ -0,0 +1 @@
+import Log from"../constants/log.js";import{navigateToEid,reportStat}from"../utils/index";export default{data(){return{token:""}},onLoad(t){var{token:t,needJumpPage:e}=t;this.token=t,uni.reportLogToEid({token:t,event:Log.getIntoIndexPage,errMsg:`进入配置首页,token:${t},needJumpPage:`+e}),reportStat({module:"StartIndex",action:"enter"})},onUnload(){reportStat({module:"StartIndex",action:"leave"})},methods:{handleStart(){navigateToEid(this.token)}}};

+ 24 - 0
src/pages/mp_ecard_sdk/index/index.vue

@@ -0,0 +1,24 @@
+<template>
+	<view class="auth">
+		<view class="auth-logo">
+			<image src="https://faceid-h5-1254418846.file.myqcloud.com/mp_verify_sdk/images/ecard/logo.png" />
+		</view>
+		<view class="title">
+			即将进入"eID数字身份"小程序
+		</view>
+		<view class="button-area">
+			<button @click='handleStart' >
+				确认进入
+			</button>
+		</view>
+	</view>
+</template>
+
+<script>
+import index from "./index";
+export default index;
+</script>
+
+<style>
+@import url('../index.css');
+</style>

+ 139 - 0
src/pages/mp_ecard_sdk/main.js

@@ -0,0 +1,139 @@
+import validate from "./utils/validate";
+import Log from "./constants/log";
+import globalConfig from "./globalConfig";
+import { navigateToEid, reportStat } from "./utils/index";
+const EIDAppID = "wx0e2cb0b052a91c92";
+function initEid(
+  e = "https://eid.faceid.qq.com",
+  o = "release",
+  n = "https://eid-enhance.faceid.qq.com"
+) {
+  (uni.eidBaseUrl = e), (uni.eidEnvVersion = o), (uni.eidBackUpUrl = n);
+  console.log("初始化EID参数:", { eidBaseUrl: e, eidEnvVersion: o, eidBackUpUrl: n });
+  uni.onAppShow((e) => {
+    console.log("!!!!!!监听onshow事件", e, uni.eidTokenToCallback);
+    var { scene: e, referrerInfo: o } = e,
+      { appId: o, extraData: n } = o || {},
+      { token: i, verifyDone: t } = n || {};
+    1038 === e &&
+      o === EIDAppID &&
+      n &&
+      (t && uni.handleEidVerifyDone
+        ? uni.eidTokenToCallback &&
+          uni.eidTokenToCallback === i &&
+          ((uni.eidTokenToCallback = ""),
+          uni.reportLogToEid({
+            token: i,
+            event: Log.navigateBackFromEid,
+            errMsg: `从EID核身完成返回,token:${i},verifyDone:` + t,
+          }),
+          console.log("!!!!!!执行回调"),
+          uni.handleEidVerifyDone(n))
+        : uni.reportLogToEid({
+            token: i,
+            event: Log.navigateBackFromEidFail,
+            errMsg:
+              `核验未完成或者没有处理核验完成的函数,token:${i},verifyDone:` +
+              t,
+          }));
+  });
+  e = uni.getSystemInfoSync();
+  const d = e["version"];
+  uni.reportLogToEid = function (e) {
+    var {
+        token: e = "",
+        event: o = "",
+        errCode: n = "",
+        errMsg: i = "",
+        data: t = {},
+      } = e,
+      r = new Date();
+    const a = {
+      Token: e,
+      SourceType: Log.SourceType,
+      SourceVersion: Log.version,
+      EnvVersion: d,
+      Timestamp: r.getTime(),
+      Event: o,
+      ErrorCode: "number" == typeof n ? n.toString() : n,
+      ErrorMsg: i,
+      Data: JSON.stringify(t),
+    };
+    console.log("开始上报日志:", a),
+      uni.request({
+        url: uni.eidBaseUrl + "/api/common/ReportEvent",
+        method: "POST",
+        data: a,
+        success(e) {
+          console.log("上报日志完成:", "payload:", a, "res:", e);
+        },
+      });
+  };
+}
+function startEid(e) {
+  const { data: o, verifyDoneCallback: n } = e;
+  if (!o || !n)
+    return (
+      uni.reportLogToEid({
+        token: i,
+        event: Log.startEidFail,
+        errMsg: "传入的参数有误",
+      }),
+      void uni.showModal({
+        title: "提示",
+        content: "传入的参数有误",
+        showCancel: !1,
+      })
+    );
+  const {
+    token: i,
+    needJumpPage: t = !1,
+    enableEmbedded: r = !1,
+    allowFullScreen: a = !0,
+  } = o;
+  validate.isValidateToken(i)
+    ? ((uni.enableEmbedded = r),
+      (uni.allowFullScreen = a),
+      (uni.VerifyEid_TOKEN = i),
+      reportStat({ module: "EidStart", action: "enter" }),
+      (uni.handleEidVerifyDone = (e) => {
+        console.log('赋值是否成功:', e);
+        const o = e["token"];
+        reportStat({ module: "EidEnd", action: "leave" }),
+          t
+            ? uni.navigateBack({
+                success() {
+                  uni.reportLogToEid({
+                    token: o,
+                    event: Log.EidVerifyDone,
+                    errMsg: "验证完成,token:" + o,
+                  }),
+                    n({ token: o, verifyDone: !0 });
+                },
+              })
+            : (uni.reportLogToEid({
+                token: o,
+                event: Log.EidVerifyDone,
+                errMsg: "验证完成,token:" + o,
+              }),
+              n({ token: o, verifyDone: !0 }));
+      }),
+      t
+        ? uni.navigateTo({
+            url:
+              `${globalConfig.normalPath}/mp_ecard_sdk/index/index?token=${i}&needJumpPage=` +
+              t,
+          })
+        : navigateToEid(i))
+    : (uni.reportLogToEid({
+        token: i,
+        event: Log.startEidFail,
+        errMsg: "传入的token有误,token:" + i,
+      }),
+      uni.showModal({
+        title: "提示",
+        content: "传入的token有误",
+        showCancel: !1,
+      }));
+}
+export { initEid, startEid };

+ 1 - 0
src/pages/mp_ecard_sdk/utils/http.js

@@ -0,0 +1 @@
+import Log from"../constants/log.js";const request=function(e,t){const{token:o="",url:a,method:r="POST",data:s,reTry:d,header:u={"Content-Type":"application/json"}}=e;try{uni.request({url:uni.eidBaseUrl+a,method:r,data:s,header:u,success(r){console.log("request success:",r),200===r.statusCode&&r.data?0==r.data.ErrorCode||0==r.data.code?t({ErrorCode:0,ErrorMsg:r.data.ErrorMsg,Data:r.data.Data||r.data.data,reTry:d}):t({ErrorCode:r.data.ErrorCode,ErrorMsg:r.data.ErrorMsg,Data:r.data.Data||r.data.data}):t({ErrorCode:-101,ErrorMsg:"请求错误,请稍后重试"})},fail(r){console.log("request error:",r),d&&d.tryCount&&0<d.tryCount?(d.tryCount--,uni.eidBaseUrl=uni.eidBackUpUrl,setTimeout(()=>{request(e,t)},d.retryDelay||0)):t({ErrorCode:-107,ErrorMsg:"request请求异常,请稍后重试"}),uni.reportLogToEid({token:o,event:Log.requestFail,errCode:"-1",errMsg:"requestFail 调用失败",data:{url:""+(uni.eidBaseUrl+a),err:r}})}})}catch(r){console.log("request error:",r),t({ErrorCode:-109,ErrorMsg:"request方法异常,请稍后重试"}),uni.reportLogToEid({token:o,event:Log.requestCatch,errCode:"-1",errMsg:"requestFail 调用失败",data:{url:""+(uni.eidBaseUrl+a),err:r}})}},$http=request;export{$http};

+ 1 - 0
src/pages/mp_ecard_sdk/utils/index.js

@@ -0,0 +1 @@
+import Log from"../constants/log";const navigateToEid=o=>{console.log("navigateToEid",uni.eidEnvVersion),reportStat({module:"showNavigateToEidDialog",action:"enter"}),(uni.enableEmbedded&&uni.openEmbeddedMiniProgram?uni.openEmbeddedMiniProgram:uni.navigateToMiniProgram)({appId:"wx0e2cb0b052a91c92",path:"pages/huiyan/index",envVersion:uni.eidEnvVersion,allowFullScreen:uni.allowFullScreen,extraData:{useHuiyan:!0,huiyanToken:o},success(e){console.log("success",e),uni.eidTokenToCallback=o,reportStat({module:"NavigateToEid",action:"confirm"}),reportStat({module:"showNavigateToEidDialog",action:"leave"})},fail(e){console.log("err",e),reportStat({module:"NavigateToEid",action:"cancel"})},complete(e){reportStat({module:"NavigateToEidDailog",action:"leave"}),uni.reportLogToEid({token:o,event:Log.navigateToEid,errMsg:e.errMsg})}})},reportStat=async({token:e=uni.VerifyEid_TOKEN,module:a,action:n})=>{if(console.log("reportStat",a,n),e)return console.log("上报埋点:",a,n),new Promise((o,i)=>{uni.request({url:uni.eidBaseUrl+"/api/report/EidEvents?token="+e,method:"POST",data:{token:e,eidSDKVersion:Log.version,enableEmbedded:uni.enableEmbedded,dataList:[{startTimestamp:Date.now(),module:a,action:n}]},success(e){o(e)},fail(e){i(e)}})})};export{navigateToEid,reportStat};

+ 1 - 0
src/pages/mp_ecard_sdk/utils/validate.js

@@ -0,0 +1 @@
+function isValidateToken(e){return/^[a-zA-Z0-9-]{36}$/.test(e)}export default{isValidateToken:isValidateToken};

+ 2 - 2
src/utils/http/index.ts

@@ -179,9 +179,9 @@ export class HttpClient {
 
 // 创建实例
 export const http = new HttpClient({
-  // baseURL: 'http://192.168.1.34:8080/jeecg-boot/app',
+  baseURL: 'http://192.168.1.34:8080/jeecg-boot/app',
   // baseURL: 'http://192.168.1.166:8080/jeecg-boot/app',
-  baseURL: 'http://192.168.0.11:8080/jeecg-boot/app',
+  // baseURL: 'http://192.168.0.11:8080/jeecg-boot/app',
   headers: {
     'Content-Type': 'application/json'
   }