liyongli vor 2 Jahren
Ursprung
Commit
aadb222c8c

+ 10 - 2
miniprogram/api/index.ts

@@ -57,7 +57,8 @@ function getUser(params:WechatMiniprogram.requestParamsData) {
       Authorization: wx.getStorageSync("token"),
       ...params.header
     },
-    success: params.success
+    success: params.success,
+    complete: params.complete || undefined
   })
 }
 
@@ -77,6 +78,10 @@ function getVideo(params:WechatMiniprogram.requestParamsData) {
   })
 }
 
+/**
+ * 保存用户信息
+ * @param params 
+ */
 function seaveUserData(params:WechatMiniprogram.requestParamsData) {
   return request({
     url: "/v3/save-info",
@@ -90,6 +95,10 @@ function seaveUserData(params:WechatMiniprogram.requestParamsData) {
   })
 }
 
+/**
+ * 获取页面信息
+ * @param params 
+ */
 function getPageInfo(params:WechatMiniprogram.requestParamsData) {
   return request({
     url: "https://djweb.smcic.net/video/PageInfo.json",
@@ -97,7 +106,6 @@ function getPageInfo(params:WechatMiniprogram.requestParamsData) {
     method: params.method,
     baseUrlNone: true,
     header:{
-      Authorization: wx.getStorageSync("token"),
       ...params.header
     },
     success: params.success

+ 1 - 2
miniprogram/app.json

@@ -2,14 +2,13 @@
   "pages": [
     "pages/home/index",
     "pages/faceRecognition/index",
-    "pages/faceRecognitionVk/index",
     "pages/entry/index",
     "pages/downloadPage/index"
   ],
   "window": {
     "backgroundTextStyle": "light",
     "navigationBarBackgroundColor": "#fff",
-    "navigationBarTitleText": "马拉松AI云视频",
+    "navigationBarTitleText": "AI云视频",
     "navigationBarTextStyle": "black"
   },
   "style": "v2",

+ 3 - 14
miniprogram/app.ts

@@ -1,24 +1,13 @@
 // app.ts
 import api from "./api/index";
 App<IAppOption>({
-  globalData: {},
+  globalData: {
+    getUserLoad: false
+  },
   onLaunch() {
     // 登录
     const nowTime = Date.now() - (wx.getStorageSync("tokenTime") || 0) >= 86400000 * 7;
     (!wx.getStorageSync("token") || nowTime) && this.wLogin();
-    // 获取用户信息
-    this.getUser({
-      data: {},
-      success: (res: any) => {
-        if(!res) return;
-        if (res.UPLOAD_FACE && res.SAVE_USER_INFO) {
-          // 已经录过脸并且用户信息已经上传,跳转视频下载页
-          return wx.reLaunch({
-            url: "/pages/downloadPage/index"
-          })
-        }
-      }
-    })
     // 获取用户手机号
     this.globalData.phone = wx.getStorageSync("userphone") || "";
     // 获取授权内容

+ 111 - 73
miniprogram/components/camera-face/index.ts

@@ -1,4 +1,5 @@
-import { getAuthorize, setAuthorize, throttle, checkVersion } from './utils'
+import { getAuthorize, checkVersion } from './utils'
+const app = getApp<IAppOption>();
 // 顶部提示信息
 // const app = getApp<IAppOption>();
 const topTips = {
@@ -8,9 +9,9 @@ const topTips = {
   right: '请向右转头',
 }
 const bottomTips = {
-  recording: '脸部信息采集中...',
-  complete: '脸部信息采集成功',
-  error: '脸部信息采集失败'
+  recording: '脸部信息录入中...',
+  complete: '脸部信息录入成功',
+  error: '脸部信息录入失败'
 }
 let ctx: WechatMiniprogram.CameraContext;
 let listener: WechatMiniprogram.CameraFrameListener;
@@ -87,10 +88,12 @@ Component({
 
   // 组件的初始数据
   data: {
+    initFace: false,
     topTips: topTips.ready, // 顶部提示信息
     bottomTips: "", //底部提示信息
     gather: 0, // 采集状态:0 -未开始 1 -加载中 2 -录制中 3 -录制结束
-    seconds: 0
+    seconds: 0,
+    messageAuto: false
   },
 
   /**
@@ -101,7 +104,7 @@ Component({
     readyRecord() {
       if (this.data.gather !== 0 && this.data.gather !== 3) return; // 开始采集
       this.setData({ bottomTips: bottomTips.recording, gather: 1 }); // 状态转换为加载中
-      wx.nextTick(async () => {
+      wx.nextTick(() => {
         wx.showLoading({ title: '加载中..', mask: true })
         if (!checkVersion('2.18.0', () => this.triggerEvent('cannotUse'))) {
           // 基础库不支持 faceDate
@@ -110,72 +113,97 @@ Component({
           return;
         }
 
-        // 调用相机
-        await this.openCamera();
-        // 准备采集
-        startTime = Date.now();
-        this.initFace()
-        // 开始录制
-        this.startRecord()
+        // 获取授权
+        this.getMssage().then(async (r:any) => {
+          this.setData({
+            messageAuto: r || false
+          })
+          // 调用相机
+          await this.openCamera();
+          // 准备采集
+          startTime = Date.now();
+          this.initFace()
+          // 开始录制
+          this.startRecord()
+        })
       })
     },
-    // init 人脸识别能力
-    initFace() {
-      // 视频帧数据读取节流
-      const fn = (frame: any) => {
-        const s = 15 - Math.floor((Date.now() - startTime) / 1000);
-        if (this.data.gather !== 2 || s % 500 > 100) return;
-        let tip = "";
-        switch (true) {
-          case s > 10:
-            tip = topTips.front
-            break;
-          case s > 5 && s <= 10:
-            tip = topTips.left;
-            break
-          default:
-            tip = topTips.right;
-            break;
-        }
-        if (s == 15) innerAudioContext.src = "assets/voice/front.mp3";
-        if (s == 10) innerAudioContext.src = "assets/voice/left.mp3";
-        if (s == 5) innerAudioContext.src = "assets/voice/right.mp3";
-        if (s % 5 === 0 && s !== 0) innerAudioContext.play();
-        this.setData({
-          seconds: s,
-          topTips: tip
-        })
-        if (s <= 0) {
-          // 结束监听
-          this.stopRecord(true);// 停止录像逻辑
-          this.stopUI(true); // 重置ui逻辑;
-          return
-        }
-        // 识别人脸是否在画面种
-        wx.faceDetect({
-          frameBuffer: frame.data,
-          width: frame.width,
-          height: frame.height,
-          enableConf: true,
-          enableAngle: true,
-          success: (res: WechatMiniprogram.FaceDetectSuccessCallbackResult) => this.processFaceData(res),
-          fail: (err) => {
-            wx.showToast({ title: '未识别到人脸', icon: 'error', duration: 2000 });
-            this.setData({
-              seconds: 0,
-              bottomTips: bottomTips.error
-            })
-            this.stopRecord();
-            this.stopUI();
+    // 获取消息授权
+    getMssage() {
+      return new Promise((resolve) => {
+        let T = wx.getStorageSync("messageAuth") || "";
+        if (T) resolve(T);
+        else wx.requestSubscribeMessage({
+          tmplIds: app.globalData.configPage?.messageID || [],
+          success: (res: WechatMiniprogram.RequestSubscribeMessageSuccessCallbackResult) => {
+            const isAccept = res.p1mpCydIQ6OtxCSa62NaSFiEkQiTsb8KPFaAs1SuKMw === 'accept';
+            wx.setStorageSync("messageAuth", isAccept)
+            resolve(isAccept);
+          },
+          fail: () => {
+            resolve(false);
           }
         })
-      }
+      })
+    },
+    // init 人脸识别能力
+    initFace() {
       // 初始化人脸识别
       wx.initFaceDetect({
         success: () => {
           wx.hideLoading();
-          listener = ctx.onCameraFrame((frame: any) => fn(frame))
-          listener?.start()
+          listener = ctx.onCameraFrame((frame: any) => {
+            const s = 15 - Math.floor((Date.now() - startTime) / 1000);
+            if (this.data.gather !== 2 || s % 500 > 100) return;
+            let tip = "";
+            switch (true) {
+              case s > 10:
+                tip = topTips.front
+                break;
+              case s > 5 && s <= 10:
+                tip = topTips.left;
+                break
+              default:
+                tip = topTips.right;
+                break;
+            }
+            if (s == 15) innerAudioContext.src = "assets/voice/front.mp3";
+            if (s == 10) innerAudioContext.src = "assets/voice/left.mp3";
+            if (s == 5) innerAudioContext.src = "assets/voice/right.mp3";
+            if (s % 5 === 0 && s !== 0) innerAudioContext.play();
+            this.setData({
+              seconds: s,
+              topTips: tip
+            })
+            if (s <= 0) {
+              // 结束监听
+              this.stopRecord(true);// 停止录像逻辑
+              this.stopUI(true); // 重置ui逻辑;
+              return
+            }
+            // 识别人脸是否在画面种
+            wx.faceDetect({
+              frameBuffer: frame.data,
+              width: frame.width,
+              height: frame.height,
+              enableConf: true,
+              enableAngle: true,
+              success: (res: WechatMiniprogram.FaceDetectSuccessCallbackResult) => this.processFaceData(res),
+              fail: (err) => {
+                wx.showToast({ title: '未识别到人脸', icon: 'error', duration: 2000 });
+                this.setData({
+                  seconds: 0,
+                  bottomTips: bottomTips.error
+                })
+                this.stopRecord();
+                this.stopUI();
+              }
+            })
+          })
+          listener?.start();
+          this.setData({
+            initFace: true
+          })
         },
         fail: () => {
           wx.hideLoading();
@@ -243,7 +271,6 @@ Component({
     // 结束录制
     stopRecord(isVadeo?: boolean) {
       this.setData({ gather: isVadeo ? 3 : 0 });
-      console.log('+++++++++>')
       ctx?.stopRecord({
         compressed: this.properties.compressed,
         success: (res) => {
@@ -254,21 +281,32 @@ Component({
            */
           console.log("录制结束", res, isVadeo);
           if (!isVadeo) return;
-          this.triggerEvent('complete', res.tempVideoPath)
+          this.triggerEvent('complete', { path: res.tempVideoPath, msg: this.data.messageAuto })
+          wx.stopFaceDetect({
+            success: () => {
+              listener?.stop();
+            },
+            fail: () => {
+              listener?.stop();
+            }
+          });
         },
         fail: (err) => {
           console.log("录制失败+++>", err);
           wx.hideLoading();
-          wx.showToast({ title: "采集失败,请重试", icon: "none" });
+          wx.showToast({ title: "录入失败,请重试", icon: "none" });
           this.setData({
             seconds: 0,
             bottomTips: bottomTips.error
           })
-        },
-        complete: () => {
-          console.log("取消录制");
-          listener?.stop();
-          wx.stopFaceDetect({});
+          wx.stopFaceDetect({
+            success: () => {
+              listener?.stop();
+            },
+            fail: () => {
+              listener?.stop();
+            }
+          });
         }
       })
     },
@@ -290,7 +328,7 @@ Component({
       } catch (error) {
         wx.hideLoading()
         wx.showToast({
-          title: "设备不支持视频采集",
+          title: "设备不支持视频录入",
           icon: "error"
         })
         this.setData({ gather: 0 });

+ 1 - 1
miniprogram/components/camera-face/index.wxml

@@ -13,6 +13,6 @@
   </view>
 
   <!-- 开始人脸验证——人脸验证中——人脸验证成功 -->
-  <view wx:if="{{gather === 0}}" class="faceBtn" bindtap="readyRecord">开始人脸采集</view>
+  <view wx:if="{{gather === 0}}" class="faceBtn" bindtap="readyRecord">开始人脸验证</view>
   <view wx:if="{{gather !== 0}}" class="bottom-tips">{{bottomTips}}</view>
 </view>

+ 40 - 34
miniprogram/pages/downloadPage/index.ts

@@ -35,49 +35,56 @@ Page({
       })
     }, 200);
   },
-
   downloadVideo() {
-    if (t) t = clearTimeout(t);
-    t = setTimeout(() => {
-      wx.showLoading({
-        title: ""
-      })
-      app.getVideo({
-        success: (r: any) => {
-          wx.downloadFile({
-            url: r.url,
-            success: (res) => {
-              wx.showLoading({
-                title: ""
-              })
-              wx.saveVideoToPhotosAlbum({
-                filePath: res.tempFilePath,
-                success: () => {
-                  wx.hideLoading();
-                  wx.showToast({
-                    title: "保存成功",
-                    icon: "none",
-                    duration: 2000
+    app.getUser({
+      data: {},
+      success: (rule: any) => {
+        if(!rule.PAY) return
+        if (t) t = clearTimeout(t);
+        t = setTimeout(() => {
+          wx.showLoading({
+            title: ""
+          })
+          app.getVideo({
+            success: (r: any) => {
+              wx.downloadFile({
+                url: r.url,
+                success: (res) => {
+                  wx.showLoading({
+                    title: ""
+                  })
+                  this.setData({
+                    videoSrc: r.url
+                  })
+                  wx.saveVideoToPhotosAlbum({
+                    filePath: res.tempFilePath,
+                    success: () => {
+                      wx.hideLoading();
+                      wx.showToast({
+                        title: "保存成功",
+                        icon: "none",
+                        duration: 2000
+                      })
+                    },
+                    fail: () => {
+                      wx.hideLoading();
+                    },
+                    complete: () => {
+                      apiPay = false;
+                    }
                   })
                 },
                 fail: () => {
                   wx.hideLoading();
                 },
-                complete: () => {
-                  apiPay = false;
-                }
+                complete: () => { }
               })
             },
-            fail: () => {
-              wx.hideLoading();
-            },
-            complete: () => { }
           })
-        },
-      })
-    }, 200);
+        }, 200);
+      }
+    })
   },
-
   toPAY() {
     app.createOrder({
       success: (res: any) => {
@@ -102,7 +109,6 @@ Page({
       }
     })
   },
-
   inited(res: any) {
     app.getUser({
       data: {},

+ 17 - 11
miniprogram/pages/entry/index.ts

@@ -12,19 +12,19 @@ Page({
     inputed: false
   },
 
-  phoneinput(e:WechatMiniprogram.CustomEvent){
+  phoneinput(e: WechatMiniprogram.CustomEvent) {
     this.setData({
       phoneNumber: e.detail.value
     })
   },
 
-  bindKeyInput(e:WechatMiniprogram.CustomEvent){
+  bindKeyInput(e: WechatMiniprogram.CustomEvent) {
     this.setData({
       nickName: e.detail.value
     })
   },
 
-  toFace(){
+  toFace() {
     if (!this.data.phoneNumber) {
       return wx.showToast({
         "icon": "none",
@@ -33,12 +33,12 @@ Page({
       })
     }
     app.seaveUserData({
-      data:{
+      data: {
         "name": this.data.nickName,
         "phone": this.data.phoneNumber
       },
       method: "POST",
-      success: () =>{
+      success: () => {
         // 进入人脸识别
         let url = "/pages/faceRecognition/index";
         // const version:string = app.globalData.SystemInfo?.SDKVersion || "";
@@ -50,18 +50,24 @@ Page({
     })
   },
   getPhoneNumber(e: WechatMiniprogram.CustomEvent) {
+    if(!e.detail.code) {
+      wx.showToast({
+        title: "请升级最新版微信。"
+      })
+      return
+    }
     app.getPhone({
       data: {
         code: e.detail.code
       },
       header: {},
-      success: (res:any) => {
-        if(!res.purePhoneNumber) {
+      success: (res: any) => {
+        if (!res.purePhoneNumber) {
           app.globalData.phone = "";
           wx.setStorageSync("userphone", "");
           wx.showToast({
-            icon:"none",
-            title: "未获取手机号,请手动输入", 
+            icon: "none",
+            title: "未获取手机号,请手动输入",
             duration: 2000
           })
           return;
@@ -82,7 +88,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad() {
-    if(app.globalData.phone){
+    if (app.globalData.phone) {
       this.setData({
         phoneNumber: app.globalData.phone,
         inputed: true
@@ -140,4 +146,4 @@ Page({
   }
 })
 
-export {}
+export { }

+ 18 - 7
miniprogram/pages/faceRecognition/index.ts

@@ -38,7 +38,9 @@ Page({
     // 在录制中退出后台页面隐藏,返回上一页,确保重新进入当前页
     // 防止在录制中退出后台导致下次重新录制失败 "operateCamera:fail:is stopping"
     console.log('页面隐藏')
-    if (this.data.isBack) wx.navigateBack()
+    if (this.data.isBack) {
+      wx.navigateBack();
+    }
   },
 
   /**
@@ -73,6 +75,7 @@ Page({
     // 因为在设置里授权摄像头不会立即生效,所以要返回上一页,确保重新进入当前页使摄像头生效
     let t = setTimeout(() => {
       wx.navigateBack();
+      wx.stopFaceDetect();
       clearTimeout(t);
     }, 500)
   },
@@ -80,12 +83,18 @@ Page({
   // 版本号过低的回调
   handleCannotuse() {
     console.log('版本号过低无法使用, 组件内已经弹窗提示过了')
-    wx.navigateBack()
+    wx.navigateBack();
+    wx.stopFaceDetect();
   },
 
   // 视频录制完成
   handleComplete(e: WechatMiniprogram.CustomEvent) {
-    console.log('视频文件路径:', e.detail)
+    this.getVideoData(e);
+  },
+
+  // 获取视频信息
+  getVideoData(e: WechatMiniprogram.CustomEvent){
+    console.log('视频文件路径:', e.detail.path)
     // e.detail: 视频临时路径
     this.setData({
       isBack: false
@@ -94,7 +103,7 @@ Page({
     // 打印视频信息文件
     const fileSystemManager = wx.getFileSystemManager();
     fileSystemManager.getFileInfo({
-      filePath: e.detail.toString(),
+      filePath: e.detail.path?.toString(),
       success: (res) => {
         const {
           size
@@ -106,10 +115,10 @@ Page({
       }
     })
 
-    this.uploadVideo(e.detail.toString())
+    this.uploadVideo(e.detail.path.toString(), e.detail.msg)
   },
 
-  uploadVideo(url: string) {
+  uploadVideo(url: string, msg: boolean) {
     var src = url;
     wx.showLoading({
       title: '上传进度:0%',
@@ -120,7 +129,9 @@ Page({
       url: base.url + '/v3/upload',
       filePath: src,
       name: 'file', //服务器定义的Key值
-      formData: {},
+      formData: {
+        notify: msg
+      },
       header: {
         Authorization: wx.getStorageSync("token")
       },

+ 0 - 4
miniprogram/pages/faceRecognitionVk/index.json

@@ -1,4 +0,0 @@
-{
-  "usingComponents": {
-  }
-}

+ 0 - 23
miniprogram/pages/faceRecognitionVk/index.scss

@@ -1,23 +0,0 @@
-/* pages/faceRecognition/index.wxss */
-@import "../../components/camera-face/index.wxss";
-
-page {
-  background: #ffffff;
-  height: 100vh;
-  display: flex;
-  align-items: center;
-}
-
-.page {
-  width: 100%;
-  height: 750rpx;
-
-  .camera{
-    width: 80%;
-    height: 80%;
-    margin: 0 auto 2em auto;
-    border-radius: 50%;
-    background-color: #000000;
-  }
-}
-

+ 0 - 238
miniprogram/pages/faceRecognitionVk/index.ts

@@ -1,238 +0,0 @@
-// pages/faceRecognition/index.ts
-import { base } from "../../config/index";
-import { compareVersion } from "../../utils/util";
-let ctx: WechatMiniprogram.CameraContext | undefined = undefined;
-let createVKSession: WechatMiniprogram.VKSession | undefined = undefined;
-const app = getApp<IAppOption>();
-Page({
-
-  /**
-   * 页面的初始数据
-   */
-  data: {
-    isStartVideo: false, // 是否点击开始按钮
-    isEmpower: false, // 是否授权
-    isUpLoad: false, // 是否上传中
-    isTranscribe: false, // 是否录制中
-
-    buttomText: "录制"
-  },
-
-  // 开始初始化录制
-  initCamera() {
-    if (this.data.isStartVideo) return;
-    this.setData({
-      isStartVideo: true
-    })
-    wx.nextTick(() => {
-      this.createVK();
-      wx.showLoading({
-        title: ""
-      })
-      ctx = wx.createCameraContext();
-      ctx.startRecord({
-        timeout: 15, // 录制时长
-        timeoutCallback: () => {
-          // 超出录制时长 关闭录屏
-          this.overVideo();
-        },
-        success: () => {
-          // 调用成功,开始录制
-          wx.hideLoading();
-        },
-        fail: () => {
-          // 调用失败
-          wx.hideLoading();
-          wx.showToast({
-            icon: "none",
-            title: "相机调用失败",
-            duration: 2000
-          })
-        },
-        complete: () => { }
-      })
-    })
-  },
-
-  // 创建人脸追踪
-  createVK() {
-    console.log("开始追踪人脸");
-    createVKSession = wx.createVKSession({
-      version: "v1",
-      track: {
-        plane: {
-          mode: 3
-        },
-        face: {
-          mode: 1
-        }
-      },
-    })
-
-    createVKSession.on("updateAnchors", anchors => {
-      console.log("检测到人脸", anchors)
-      if (!this.data.isTranscribe) {
-        this.setData({
-          isTranscribe: true
-        })
-      }
-    })
-
-    // 当人脸从相机中离开时,会触发 removeAnchors 事件
-    createVKSession.on('removeAnchors', () => {
-      wx.showToast({
-        icon: "none",
-        title: "未检测到人脸,请重新录制",
-        duration: 2000
-      })
-      //  录制失败
-      this.overVideo();
-    })
-
-    createVKSession.start((errno) => {
-      console.log(errno);
-    })
-  },
-
-  // 结束录像
-  overVideo() {
-    if (!ctx || !this.data.isStartVideo) return;
-    wx.showLoading({
-      title: ""
-    })
-    createVKSession?.stop();
-    ctx.stopRecord({
-      compressed: true,
-      success: res => {
-        // 成功结束
-        wx.hideLoading();
-        this.getUrl(res);
-      },
-      fail: () => {
-        // 结束失败
-        wx.hideLoading();
-        wx.showToast({
-          icon: "none",
-          title: "相机关闭失败",
-          duration: 2000
-        })
-      },
-      complete: () => {
-        this.setData({
-          isStartVideo: false
-        })
-      }
-    })
-  },
-
-  // 获取本地临时地址
-  getUrl(res: WechatMiniprogram.StartRecordTimeoutCallbackResult) {
-    this.setData({
-      isUpLoad: true
-    })
-    wx.showLoading({
-      title: ""
-    })
-    wx.uploadFile({
-      // 仅为示例,非真实的接口地址,视频上传
-      url: base.url + '/v3/upload',
-      filePath: res.tempVideoPath,
-      name: 'file', //服务器定义的Key值
-      formData: {},
-      header: {
-        Authorization: wx.getStorageSync("token")
-      },
-      success: function (res) {
-        console.log(res)
-        wx.hideLoading();
-        wx.showToast({
-          title: "上传成功",
-          duration: 2000,
-          icon: "none"
-        })
-      },
-      fail: function (res) {
-        console.log(res)
-        wx.hideLoading();
-        wx.showToast({
-          title: "上传失败",
-          icon: "none",
-          duration: 2000
-        })
-      },
-      complete: () => {
-        this.setData({
-          isUpLoad: false
-        })
-      }
-    })
-  },
-
-  // 非正常中止
-  improperStop() { },
-
-  // 未授权
-  unauthorized() { },
-
-  // 初始化完成
-  initialization() { },
-
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad(opt) {
-    console.log(opt)
-    const SDKVersion: string = app.globalData.SystemInfo?.SDKVersion || "";
-    compareVersion(SDKVersion, '1.9.6');
-  },
-
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide() {
-    // 在录制中退出后台页面隐藏,返回上一页,确保重新进入当前页
-  },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload() {
-
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh() {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
-
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
-
-  },
-})
-
-export { }

+ 0 - 16
miniprogram/pages/faceRecognitionVk/index.wxml

@@ -1,16 +0,0 @@
-<view class="page-body">
-  <view class="head">
-    <!-- 请拿起手机正对摄像头——请向左转——请向右转 -->
-    <view class="top-tips">{{topTips}}</view>
-
-    <camera class="camera" mode="normal" resolution="medium" device-position="front" flash="off" frame-size="medium" bindstop="improperStop" binderror="unauthorized" 	bindinitdone="initialization">
-      <view wx:if="{{seconds>0}}" class="half-circle">
-        {{seconds}}s
-      </view>
-    </camera>
-  </view>
-
-  <!-- 开始人脸验证——人脸验证中——人脸验证成功 -->
-  <view wx:if="{{!isStartVideo}}" class="faceBtn" bindtap="initCamera">开始人脸采集</view>
-  <view wx:if="{{isStartVideo}}" class="bottom-tips">{{bottomTips}}</view>
-</view>

+ 16 - 1
miniprogram/pages/home/index.ts

@@ -71,7 +71,22 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow() {
-
+    // 获取用户信息
+    app.getUser({
+      data: {},
+      success: (res: any) => {
+        if (!res) return;
+        if (res.UPLOAD_FACE && res.SAVE_USER_INFO) {
+          // 已经录过脸并且用户信息已经上传,跳转视频下载页
+          return wx.reLaunch({
+            url: "/pages/downloadPage/index"
+          })
+        }
+      },
+      complete: () => {
+        app.globalData.getUserLoad = false;
+      }
+    })
   },
 
   /**

+ 2 - 1
miniprogram/utils/request.ts

@@ -29,7 +29,8 @@ export default function request(params: WechatMiniprogram.requestParamsData) {
         duration: 2000
       })
     },
-    complete: () => {
+    complete: (com) => {
+      params.complete && params.complete(com);
     }
   })
 }

+ 3 - 1
typings/index.d.ts

@@ -2,12 +2,14 @@
 
 interface IAppOption {
   globalData: {
+    getUserLoad: boolean;
     SystemInfo?: WechatMiniprogram.SystemInfo,
     token?: string,
     setting?: WechatMiniprogram.AuthSetting,
     FileSystemManager?: WechatMiniprogram.FileSystemManager,
     phone?: string | undefined,
-    configPage?: any
+    configPage?: any;
+    messageID?: any[];
   }
   userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback,
   [params:string]: any

+ 1 - 0
typings/types/wx/lib.local.tool.d.ts

@@ -8,6 +8,7 @@ declare namespace WechatMiniprogram {
     dataType?: 'json' | '其他';
     success:AccessCompleteCallback;
     baseUrlNone?: boolean;
+    complete?: (com? :any) => void;
   }
 }