liyongli há 2 anos atrás
pai
commit
a6f37e3fdd

+ 3 - 3
miniprogram/api/index.ts

@@ -90,9 +90,9 @@ function seaveUserData(params:WechatMiniprogram.requestParamsData) {
   })
 }
 
-function getdownloadPage(params:WechatMiniprogram.requestParamsData) {
+function getPageInfo(params:WechatMiniprogram.requestParamsData) {
   return request({
-    url: "https://djweb.smcic.net/video/downloadPage.json",
+    url: "https://djweb.smcic.net/video/PageInfo.json",
     data: params.data,
     method: params.method,
     baseUrlNone: true,
@@ -111,5 +111,5 @@ export default {
   getUser,
   getVideo,
   seaveUserData,
-  getdownloadPage
+  getPageInfo
 }

+ 2 - 1
miniprogram/app.ts

@@ -29,7 +29,8 @@ App<IAppOption>({
     });
     this.globalData.SystemInfo = wx.getSystemInfoSync();
     this.globalData.FileSystemManager = wx.getFileSystemManager();
-    console.log(this.globalData.SystemInfo.SDKVersion)
+    console.log(this.globalData.SystemInfo.SDKVersion);
+
   },
   wLogin() {
     wx.login({

BIN
miniprogram/assets/image/0.jpg


+ 1 - 3
miniprogram/components/camera-face/index.ts

@@ -179,8 +179,7 @@ Component({
         },
         fail: () => {
           wx.hideLoading();
-          // 初始化人脸识别失败
-          wx.showToast({ title: '未识别到人脸', icon: 'error', duration: 2000 });
+          wx.showToast({ title: '初始化人脸识别失败', icon: 'error', duration: 2000 });
           this.setData({
             seconds: 0,
             bottomTips: bottomTips.error
@@ -261,7 +260,6 @@ Component({
           console.log("录制失败+++>", err);
           wx.hideLoading();
           wx.showToast({ title: "采集失败,请重试", icon: "none" });
-          wx.navigateBack();
           this.setData({
             seconds: 0,
             bottomTips: bottomTips.error

+ 38 - 25
miniprogram/pages/downloadPage/index.ts

@@ -9,6 +9,7 @@ Page({
    */
   data: {
     videoSrc: "",
+    assetsSrc: "",
     paragraphName: "马拉松简介",
     showImage: true
   },
@@ -102,39 +103,51 @@ Page({
     })
   },
 
+  inited(res: any) {
+    app.getUser({
+      data: {},
+      success: (rule: any) => {
+        if (!rule.SAVE_USER_INFO || !rule.UPLOAD_FACE) {
+          wx.reLaunch({
+            url: "/pages/home/index"
+          })
+          return
+        }
+        if (!rule.PAY || !rule.RESULT) {
+          this.setData({
+            videoSrc: res.videoSrc || "",
+            assetsSrc: res.assetsSrc || "",
+            paragraph: res.paragraph || [],
+            paragraphName: res.paragraphName
+          })
+          return;
+        }
+        app.getVideo({
+          success: (r: any) => {
+            console.log(r);
+            this.setData({
+              videoSrc: r.url,
+              paragraph: res.paragraph || [],
+              paragraphName: res.paragraphName
+            })
+          }
+        })
+      },
+    })
+  },
+
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad() {
     wx.hideHomeButton({});
-
-    app.getdownloadPage({
+    if (!app.globalData.configPage) app.getPageInfo({
       success: (res: any) => {
-        app.getUser({
-          data: {},
-          success: (rule: any) => {
-            if (!rule.PAY || !rule.RESULT) {
-              this.setData({
-                videoSrc: res.videoSrc || "",
-                paragraph: res.paragraph || [],
-                paragraphName: res.paragraphName
-              })
-              return;
-            }
-            app.getVideo({
-              success: (r: any) => {
-                console.log(r);
-                this.setData({
-                  videoSrc: r.url,
-                  paragraph: res.paragraph || [],
-                  paragraphName: res.paragraphName
-                })
-              }
-            })
-          },
-        })
+        app.globalData.configPage = res || {};
+        this.inited(app.globalData.configPage);
       }
     })
+    else this.inited(app.globalData.configPage);
   },
 
   /**

+ 1 - 1
miniprogram/pages/downloadPage/index.wxml

@@ -2,7 +2,7 @@
 <view class="page">
   <view class="headHead">
     <video class="headVideo" bindplay="autoplay" src="{{videoSrc}}" autoplay="autoplay" loop autoplay muted show-center-play-btn controls="{{false}}" picture-in-picture-mode="{{[]}}" />
-    <image wx:if="{{showImage}}" src="https://cxzx.smcic.net/topic/tool/img/miniprogram/download.png" mode="scaleToFill" class="headImage" />
+    <image wx:if="{{showImage}}" src="https://cxzx.smcic.net/topic/tool/img/miniprogram/download.jpg" mode="scaleToFill" class="headImage" />
   </view>
   <view class="main">
     <view class="main_title">

+ 17 - 19
miniprogram/pages/faceRecognition/index.ts

@@ -6,7 +6,6 @@ Page({
    * 页面的初始数据
    */
   data: {
-    videoSrc: '', // 录制的视频临时路径
     isBack: false, // 是否返回上一页,用于页面隐藏时判断
   },
 
@@ -20,7 +19,6 @@ Page({
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady() {
-
   },
 
   /**
@@ -47,7 +45,6 @@ Page({
    * 生命周期函数--监听页面卸载
    */
   onUnload() {
-
   },
 
   /**
@@ -74,8 +71,9 @@ Page({
   handleNoAuth(res: any) {
     console.log("用户拒绝授权:", res)
     // 因为在设置里授权摄像头不会立即生效,所以要返回上一页,确保重新进入当前页使摄像头生效
-    setTimeout(() => {
-      wx.navigateBack()
+    let t = setTimeout(() => {
+      wx.navigateBack();
+      clearTimeout(t);
     }, 500)
   },
 
@@ -90,7 +88,6 @@ Page({
     console.log('视频文件路径:', e.detail)
     // e.detail: 视频临时路径
     this.setData({
-      videoSrc: e.detail.toString(),
       isBack: false
     })
 
@@ -109,17 +106,15 @@ Page({
       }
     })
 
-    this.uploadVideo()
+    this.uploadVideo(e.detail.toString())
   },
 
-  uploadVideo() {
-    var src = this.data.videoSrc
+  uploadVideo(url: string) {
+    var src = url;
     wx.showLoading({
-      title: '采集进度:0%',
+      title: '上传进度:0%',
       mask: true //是否显示透明蒙层,防止触摸穿透
     })
-
-
     // todo: 添加上传服务器的接口
     const uploadTask = wx.uploadFile({
       url: base.url + '/v3/upload',
@@ -132,8 +127,8 @@ Page({
       success: function () {
         console.log('视频上传成功')
         wx.showToast({
-          title: "人脸采集完成",
-          icon: "none", 
+          title: "人脸上传完成",
+          icon: "none",
           duration: 2000
         })
         let time = setTimeout(() => {
@@ -143,11 +138,14 @@ Page({
           })
         }, 2000)
       },
-      fail: function (err:any) {
-        console.log('接口调用失败')
+      fail: (err: any) => {
+        console.log('接口调用失败', err);
+        const son = this.selectComponent("#cameraFace");
+        son.stopRecord();
+        son.stopUI();
         wx.showToast({
-          title: err.message || "人脸采集失败",
-          icon: "none", 
+          title: err.message || "上传失败",
+          icon: "none",
           duration: 2000
         })
       }
@@ -156,7 +154,7 @@ Page({
     //监听上传进度变化事件
     uploadTask.onProgressUpdate((res) => {
       wx.showLoading({
-        title: '采集进度:' + res.progress + '%',
+        title: '上传进度:' + res.progress + '%',
         mask: true //是否显示透明蒙层,防止触摸穿透
       })
     })

+ 1 - 1
miniprogram/pages/faceRecognitionVk/index.ts

@@ -58,7 +58,7 @@ Page({
   createVK() {
     console.log("开始追踪人脸");
     createVKSession = wx.createVKSession({
-      version: "v2",
+      version: "v1",
       track: {
         plane: {
           mode: 3

+ 0 - 9
miniprogram/pages/home/index.scss

@@ -3,21 +3,12 @@
   position: relative;
   background-size: 100% 100%;
   background-repeat: no-repeat;
-  background-image: url(https://cxzx.smcic.net/topic/tool/img/miniprogram/bg.jpg);
   padding-top: 86rpx;
   box-sizing: border-box;
 
-  .title {
-    width: 626rpx;
-    height: 354rpx;
-    margin: 0 auto;
-    display: block;
-  }
-
   .buttom {
     background-size: 100% 100%;
     background-repeat: no-repeat;
-    background-image: url(https://cxzx.smcic.net/topic/tool/img/miniprogram/input.png);
     position: absolute;
     bottom: 180rpx;
     left: 50%;

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

@@ -7,6 +7,8 @@ Page({
    * 页面的初始数据
    */
   data: {
+    pageBGIMG: "",
+    btnBGIMG: ""
   },
 
   lvru() {
@@ -37,11 +39,25 @@ Page({
     })
   },
 
+  inited(res: any) {
+    const { BGIMG, btnBGIMG } = res?.homePage;
+    this.setData({
+      pageBGIMG: BGIMG + "?" + Date.now(),
+      btnBGIMG: btnBGIMG + "?" + Date.now()
+    })
+  },
+
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad() {
-
+    if (!app.globalData.configPage) app.getPageInfo({
+      success: (res: any) => {
+        app.globalData.configPage = res || {};
+        this.inited(app.globalData.configPage);
+      }
+    })
+    else this.inited(app.globalData.configPage);
   },
 
   /**

+ 2 - 4
miniprogram/pages/home/index.wxml

@@ -1,8 +1,6 @@
 <!--pages/home/index.wxml-->
-<view class="page">
-  <image class="title" src="../../assets/image/title.png" mode="scaleToFill"/>
-
-  <view class="buttom"  bindtap="lvru">
+<view class="page" style="background-image: url({{pageBGIMG}});">
+  <view class="buttom" style="background-image: url({{btnBGIMG}});" bindtap="lvru">
     登记选手信息
   </view>
 </view>

+ 14 - 0
project.private.config.json

@@ -42,6 +42,20 @@
           "query": "",
           "launchMode": "default",
           "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/faceRecognitionVk/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/faceRecognitionVk/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
         }
       ]
     }

+ 2 - 1
typings/index.d.ts

@@ -6,7 +6,8 @@ interface IAppOption {
     token?: string,
     setting?: WechatMiniprogram.AuthSetting,
     FileSystemManager?: WechatMiniprogram.FileSystemManager,
-    phone?: string | undefined
+    phone?: string | undefined,
+    configPage?: any
   }
   userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback,
   [params:string]: any