liyongli 2 yıl önce
ebeveyn
işleme
70809f824d

+ 20 - 5
miniprogram/api/index.ts

@@ -45,12 +45,13 @@ function createOrder(params:WechatMiniprogram.requestParamsData) {
 }
 
 /**
- * 判断是否生成视频
+ * 获取状态
  * @param params 
  */
-function createVideo(params:WechatMiniprogram.requestParamsData) {
+function getUser(params:WechatMiniprogram.requestParamsData) {
+  if(!wx.getStorageSync("token")) return;
   return request({
-    url: "/v3/hasVideo",
+    url: "/v3/user-state",
     data: params.data,
     header:{
       Authorization: wx.getStorageSync("token"),
@@ -76,10 +77,24 @@ function getVideo(params:WechatMiniprogram.requestParamsData) {
   })
 }
 
+function seaveUserData(params:WechatMiniprogram.requestParamsData) {
+  return request({
+    url: "/v3/save-info",
+    data: params.data,
+    method: params.method,
+    header:{
+      Authorization: wx.getStorageSync("token"),
+      ...params.header
+    },
+    success: params.success
+  })
+}
+
 export default {
   login,
   getPhone,
   createOrder,
-  createVideo,
-  getVideo
+  getUser,
+  getVideo,
+  seaveUserData
 }

+ 4 - 1
miniprogram/app.json

@@ -1,8 +1,11 @@
 {
   "pages": [
     "pages/home/index",
+    "pages/tool/index",
     "pages/faceRecognition/index",
-    "pages/faceRecognitionVk/index"
+    "pages/faceRecognitionVk/index",
+    "pages/entry/index",
+    "pages/downloadPage/index"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 21 - 10
miniprogram/app.scss

@@ -1,14 +1,25 @@
 /**app.wxss**/
-.container {
+page {
+  width: 750rpx;
   height: 100%;
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  justify-content: space-between;
-  padding: 200rpx 0;
   box-sizing: border-box;
-} 
-
-page{
-  width: 750rpx;
+  font-family: PingFangSC-Regular, PingFang SC;
 }
+
+.page {
+  width: 100%;
+  height: 100%;
+
+  .faceBtn {
+    position: absolute;
+    bottom: 190rpx;
+    left: 126rpx;
+    color: #ffffff;
+    width: 500rpx;
+    text-align: center;
+    height: 72rpx;
+    line-height: 72rpx;
+    border-radius: 36rpx;
+    background: linear-gradient(180deg, #26B4EC 0%, #2F8AFF 100%);
+  }
+}

+ 28 - 4
miniprogram/app.ts

@@ -4,18 +4,41 @@ App<IAppOption>({
   globalData: {},
   onLaunch() {
     // 登录
-    !wx.getStorageSync("token") && this.wLogin();
+    const nowTime = Date.now() - (wx.getStorageSync("tokenTime") || 0) >= 86400000 * 7;
+    console.log(nowTime);
+    (!wx.getStorageSync("token") || nowTime) && this.wLogin();
+    // 获取用户信息
+    this.getUser({
+      data: {},
+      success: (res: any) => {
+        console.log(res);
+        if (!res.RESULT) return wx.showToast({
+          "title": "视频正在生成中,请耐心等待"
+        })
+        if (res.UPLOAD_FACE && res.SAVE_USER_INFO) {
+          // 已经录过脸并且用户信息已经上传,跳转视频下载页
+          return wx.reLaunch({
+            url: "/pages/downloadPage/index"
+          })
+        }
+      }
+    })
+    // 获取用户手机号
+    this.globalData.phone = wx.getStorageSync("userphone") || "";
     // 获取授权内容
     wx.getSetting({
-      success: res =>{
-        this.globalData.setting = res? res.authSetting : {}
+      success: res => {
+        this.globalData.setting = res ? res.authSetting : {}
       }
     });
     this.globalData.SystemInfo = wx.getSystemInfoSync();
     this.globalData.FileSystemManager = wx.getFileSystemManager();
   },
-  wLogin(){
+  wLogin() {
     wx.login({
+      fail: err => {
+        console.log(err)
+      },
       success: res => {
         // 发送 res.code 到后台换取 openId, sessionKey, unionId
         this.login({
@@ -24,6 +47,7 @@ App<IAppOption>({
           },
           success: (res: any) => {
             wx.setStorageSync("token", res.token);
+            wx.setStorageSync("tokenTime", Date.now());
           }
         })
       },

BIN
miniprogram/assets/image/title.png


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

@@ -4,7 +4,7 @@ import { getAuthorize, setAuthorize, throttle, checkVersion } from './utils'
 
 // 顶部提示信息
 const topTips = {
-  ready: '请拿起手机,正对屏幕',
+  ready: '请正对手机,保持光线充足',
   front: '请正对屏幕',
   left: '请向左转头',
   right: '请向右转头',
@@ -13,8 +13,8 @@ const topTips = {
 // 底部提示信息
 const bottomTips = {
   recording: '人脸录制中...',
-  complete: '已录制完成',
-  error: '录制失败'
+  complete: '人脸录制成功',
+  error: '人脸录制失败'
 }
 
 const innerAudioContext = wx.createInnerAudioContext()

+ 13 - 19
miniprogram/components/camera-face/index.wxml

@@ -1,26 +1,20 @@
 <!--components/camera-face/index.wxml-->
 <!--人脸识别录像组件-->
 <view class="page-body">
+  <view class="head">
     <!-- 请拿起手机正对摄像头——请向左转——请向右转 -->
-    <view class="top-view">
-        <view class="top-tips">{{topTips}}</view>
-    </view>
+    <view class="top-tips">{{topTips}}</view>
 
-    <view class="camera-box">
-        <view class="camera-circle">
-            <camera mode="normal" device-position="{{devicePosition}}" frame-size="{{frameSize}}" resolution="{{resolution}}" flash="{{flash}}" binderror="error" bindstop="stop" class="camera">
-                <view wx:if="{{!seconds}}">
-                </view>
-                <view wx:else class="half-circle">
-                    <p> {{seconds}} </p>
-                </view>
-            </camera>
-        </view>
-    </view>
+    <camera mode="normal" device-position="{{devicePosition}}" frame-size="{{frameSize}}" resolution="{{resolution}}" flash="{{flash}}" binderror="error" bindstop="stop" class="camera">
+      <view wx:if="{{seconds}}" class="half-circle">
+        {{seconds}}
+      </view>
+    </camera>
+  </view>
 
-    <!-- 开始人脸验证——人脸验证中——人脸验证成功 -->
-    <view class="bottom-view">
-        <view wx:if="{{!bottomTips}}" class="bottom-btn" bindtap="readyRecord">开始人脸验证</view>
-        <view wx:else class="bottom-btn">{{bottomTips}}</view>
-    </view>
+  <!-- 开始人脸验证——人脸验证中——人脸验证成功 -->
+  <view wx:if="{{!bottomTips}}" class="faceBtn" bindtap="readyRecord">开始人脸验证</view>
+  <view wx:else class="faceBtn">{{bottomTips}}</view>
+
+  
 </view>

+ 30 - 53
miniprogram/components/camera-face/index.wxss

@@ -3,33 +3,24 @@
   width: 100%;
   height: 100%;
   background: #ffffff;
+  overflow: auto
 }
 
-.camera-box {
-  width: 750rpx;
-  height: 750rpx;
-  margin-top: 50rpx;
-  position: relative;
-  overflow: hidden;
-  display: flex;
-  justify-content: center;
-  align-items: center;
-}
-.camera-circle {
-  width: 540rpx;
-  height: 540rpx;
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  border-radius: 50%;
-  border: 2px solid #6699cc;
+.head{
+  padding-top: 154rpx;
+  padding-bottom: 262rpx;
+  background-image: url(https://cxzx.smcic.net/topic/tool/img/miniprogram/faceBg.jpg);
+  background-size: 100% 100%;
+  height: 72.9%;
+  box-sizing: border-box;
 }
 
 .camera {
-  width: 480rpx;
-  height: 480rpx;
+  width: 452rpx;
+  height: 452rpx;
   z-index: 1;
   border-radius: 50%;
+  margin: 0 auto 0 auto;
 }
 
 .half-circle {
@@ -40,6 +31,7 @@
   display: flex;
   justify-content: center;
   align-items: center;
+  color: #ffffff;
 }
 
 .half-circle p {
@@ -63,28 +55,7 @@
   height: 505rpx;
 }
 
-.bottom-view {
-  width: 100%;
-  height: 120rpx;
-
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  margin-top: 30rpx;
-}
-
 /* 底部按钮和提示文字 */
-.bottom-btn {
-  font-family: "Microsoft YaHei";
-  font-size: large;
-  width: 300rpx;
-  height: 70rpx;
-  line-height: 70rpx;
-  text-align: center;
-  background: rgba(250, 250, 250, 0.8);
-  border-radius: 35rpx;
-}
-
 .bottom-tips {
   width: 100%;
   height: 35rpx;
@@ -92,19 +63,25 @@
   line-height: 35rpx;
   text-align: center;
 }
-
-/* 顶部提示文字 */
-.top-view {
-  width: 100%;
-  height: 10rpx;
-  display: flex;
-  align-items: center;
-  justify-content: center;
+.faceBtn {
+  color: #ffffff;
+  margin: 81rpx auto 0 auto;
+  width: 500rpx;
+  text-align: center;
+  height: 72rpx;
+  line-height: 72rpx;
+  border-radius: 36rpx;
+  background: linear-gradient(180deg, #26B4EC 0%, #2F8AFF 100%);
 }
 
+/* 顶部提示文字 */
 .top-tips {
-  font-family: "Microsoft YaHei UI Bold";
-  font-size: 50rpx;
-  color: black;
+  height: 50rpx;
+  font-size: 36rpx;
+  font-family: PingFangSC-Medium, PingFang SC;
+  font-weight: 500;
+  color: #FFFFFF;
+  line-height: 50rpx;
   text-align: center;
-}
+  margin-bottom: 138rpx;
+}

+ 3 - 0
miniprogram/pages/downloadPage/index.json

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

+ 53 - 0
miniprogram/pages/downloadPage/index.scss

@@ -0,0 +1,53 @@
+/* pages/downloadPage/index.wxss */
+.page {
+  position: relative;
+
+  .headImage {
+    width: 750rpx;
+    height: 558rpx;
+    background-color: #000;
+  }
+
+  .main {
+    position: absolute;
+    left: 0;
+    right: 0;
+    bottom: 0;
+    top: 508rpx;
+    border-top-right-radius: 60rpx;
+    border-top: 3rpx solid #26B4EC;
+    border-right: 3rpx solid #26B4EC;
+    background-color: #ffffff;
+    padding: 46rpx 46rpx 0 36rpx;
+
+    line-height: 40rpx;
+    color: #666666;
+    font-size: 28rpx;
+    line-height: 40rpx;
+
+    .iconImage {
+      width: 34rpx;
+      height: 24rpx;
+    }
+
+    .main_title {
+      color: #222222;
+      font-size: 32rpx;
+      font-weight: 500;
+      height: 44rpx;
+      line-height: 44rpx;
+    }
+
+    .btn {
+      width: 500rpx;
+      height: 72rpx;
+      line-height: 72rpx;
+      text-align: center;
+      background: linear-gradient(180deg, #26B4EC 0%, #2F8AFF 100%);
+      border-radius: 36rpx;
+      color: #FFFFFF;
+      font-size: 24rpx;
+      margin: 188rpx auto 0 auto;
+    }
+  }
+}

+ 148 - 0
miniprogram/pages/downloadPage/index.ts

@@ -0,0 +1,148 @@
+// pages/downloadPage/index.ts
+const app = getApp<IAppOption>();
+let apiPay = false;// 是否调用支付成功
+let t: any = undefined;
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+  },
+
+  toDownload() {
+    if (t) t = clearTimeout(t);
+    t = setTimeout(() => {
+      app.getUser({
+        data: {},
+        success: (res: any) => {
+          console.log(res);
+          if (!res.RESULT) return wx.showToast({
+            "title": "视频正在生成中,请耐心等待"
+          })
+          res.PAY ? this.downloadVideo() : this.toPAY();
+        }
+      })
+    }, 200);
+
+  },
+
+  downloadVideo() {
+    if (t) t = clearTimeout(t);
+    t = setTimeout(() => {
+      app.getVideo({
+        success: (r: any) => {
+          wx.showLoading({
+            title: ""
+          })
+          wx.downloadFile({
+            url: r.url,
+            success: (res) => {
+              wx.showLoading({
+                title: ""
+              })
+              wx.saveVideoToPhotosAlbum({
+                filePath: res.tempFilePath,
+                success: () => {
+                  console.log("--保存成功")
+                  wx.showToast({
+                    title: "保存成功",
+                    icon: "none"
+                  })
+                },
+                complete: () => {
+                  wx.hideLoading();
+                }
+              })
+            },
+            complete: () => {
+              wx.hideLoading();
+            }
+          })
+        },
+      })
+    }, 200);
+  },
+
+  toPAY() {
+    app.createOrder({
+      success: (res: any) => {
+        console.log('支付:', res);
+        apiPay = true;
+        wx.requestPayment({
+          timeStamp: res.timeStamp,
+          nonceStr: res.nonceStr,
+          package: res.package,
+          paySign: res.paySign,
+          signType: res.signType,
+          success() { },
+          failL: () => {
+            wx.showToast({
+              icon: "none",
+              title: "支付调用失败"
+            })
+            apiPay = false;
+          }
+        })
+      }
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad() {
+    wx.hideHomeButton({})
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+    console.log("前台");
+    // 如果支付成功则下载视频
+    if (apiPay) this.downloadVideo();
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+    console.log("后台");
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 15 - 0
miniprogram/pages/downloadPage/index.wxml

@@ -0,0 +1,15 @@
+<!--pages/downloadPage/index.wxml-->
+<view class="page">
+  <image src="https://cxzx.smcic.net/topic/tool/img/miniprogram/download.png" mode="scaleToFill" class="headImage"/>
+  <view class="main">
+    <view class="main_title">
+      马拉松简介
+    </view>
+    这是一个小小的简介这是一个小小的简介这是这是一个小小的简介这是一个小小的简介这是这是一个小小的简介这是一个小小的简介这是这是一个小小的简介这是一个小小的简介这是这是一个小小的简介这是一个小小的简介这是这是一个小小的简介这是一个小小的简介这是这是一个小小的简介这是一个小小的简介这是这是一个小小的简介这是一个小小的简介这是这是一个小小的简介这是一个小小的简介这是
+    
+    <view class="btn" bindtap="toDownload">
+      <image class="iconImage" src="https://cxzx.smcic.net/topic/tool/img/miniprogram/video.png" mode="scaleToFill"/>
+      下载个人视频
+    </view>
+  </view>
+</view>

+ 5 - 0
miniprogram/pages/entry/index.json

@@ -0,0 +1,5 @@
+{
+  "navigationBarBackgroundColor": "#2AB0FF",
+  "navigationBarTextStyle": "white",
+  "usingComponents": {}
+}

+ 69 - 0
miniprogram/pages/entry/index.scss

@@ -0,0 +1,69 @@
+/* pages/entry/index.wxss */
+.page {
+  font-weight: 500;
+
+  .title {
+    background: linear-gradient(180deg, #2AB0FF 0%, #2F8AFF 100%);
+    height: 240rpx;
+    line-height: 176rpx;
+    color: #FFFFFF;
+    font-size: 24px;
+    font-family: PingFangSC-Medium, PingFang SC;
+    padding-left: 40rpx;
+  }
+
+  .main {
+    background-color: #fff;
+    position: absolute;
+    top: 176rpx;
+    left: 0;
+    right: 0;
+    bottom: 0;
+    border-radius: 36rpx;
+    padding: 28rpx 40rpx 0 40rpx;
+
+    .label {
+      line-height: 84rpx;
+      height: 84rpx;
+      color: #222222;
+      font-size: 24rpx;
+      font-family: PingFangSC-Regular, PingFang SC;
+    }
+
+    .input {
+      border: 1rpx solid #E5E5E5;
+      padding: 6rpx;
+      height: 72rpx;
+      border-radius: 6rpx;
+      font-size: 0;
+
+      .inputTool {
+        width: 425rpx;
+        height: 100%;
+        font-size: 30rpx;
+        box-sizing: border-box;
+        padding-left: 26rpx;
+        display: inline-block;
+      }
+
+      .placeholder-style {
+        color: #C5C5C5;
+        font-size: 30rpx;
+      }
+
+      .buttom {
+        background: linear-gradient(180deg, #26B4EC 0%, #2F8AFF 100%);
+        color: #FFFFFF;
+        display: inline-block;
+        width: 230rpx;
+        border-radius: 4rpx;
+        height: 100%;
+        line-height: 72rpx;
+        font-size: 30rpx;
+        padding: 0;
+      }
+    }
+
+
+  }
+}

+ 136 - 0
miniprogram/pages/entry/index.ts

@@ -0,0 +1,136 @@
+// pages/entry/index.ts
+const app = getApp<IAppOption>();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    nickName: "",
+    phoneNumber: "",
+    inputed: false
+  },
+
+  phoneinput(e:WechatMiniprogram.CustomEvent){
+    this.setData({
+      phoneNumber: e.detail.value
+    })
+  },
+
+  bindKeyInput(e:WechatMiniprogram.CustomEvent){
+    this.setData({
+      nickName: e.detail.value
+    })
+  },
+
+  toFace(){
+    console.log(this.data.phoneNumber)
+    if (!this.data.phoneNumber) {
+      return wx.showToast({
+        "icon": "none",
+        "title": "未获取手机号"
+      })
+    }
+    app.seaveUserData({
+      data:{
+        "name": this.data.nickName,
+        "phone": this.data.phoneNumber
+      },
+      method: "POST",
+      success: () =>{
+        // 进入人脸识别
+        wx.navigateTo({
+          url: "/pages/faceRecognition/index"
+        })
+      }
+    })
+  },
+  getPhoneNumber(e: WechatMiniprogram.CustomEvent) {
+    app.getPhone({
+      data: {
+        code: e.detail.code
+      },
+      header: {},
+      success: (res:any) => {
+        if(!res.purePhoneNumber) {
+          app.globalData.phone = "";
+          wx.setStorageSync("userphone", "");
+          wx.showToast({
+            icon:"none",
+            title: "未获取手机号,请手动输入"
+          })
+          return;
+        }
+        app.globalData.phone = res.purePhoneNumber;
+        this.setData({
+          phoneNumber: res.purePhoneNumber
+        })
+        wx.setStorageSync("userphone", res.purePhoneNumber);
+        this.setData({
+          inputed: true
+        })
+      }
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad() {
+    if(app.globalData.phone){
+      this.setData({
+        phoneNumber: app.globalData.phone,
+        inputed: true
+      })
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 24 - 0
miniprogram/pages/entry/index.wxml

@@ -0,0 +1,24 @@
+<!--pages/entry/index.wxml-->
+<view class="page">
+  <view class="title">登记选手信息</view>
+  <view class="main">
+    <view class="label">
+      姓名
+    </view>
+    <view class="input">
+      <input value="{{nickName}}" bindinput="bindKeyInput" type="text" style="width: 655rpx;" class="inputTool" placeholder-class="placeholder-style" placeholder="请输入姓名" />
+    </view>
+    <view class="label">
+      手机号
+    </view>
+    <view class="input">
+      <input disabled="{{inputed}}" value="{{phoneNumber}}" bindinput="phoneinput" type="number" class="inputTool" placeholder-class="placeholder-style" placeholder="请输入手机号" />
+      <button disabled="{{inputed}}" class="buttom" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">一键获取手机号</button>
+    </view>
+
+    <view class="faceBtn" bindtap="toFace">
+      进行人脸识别
+    </view>
+  </view>
+
+</view>

+ 1 - 1
miniprogram/pages/faceRecognition/index.scss

@@ -8,7 +8,7 @@ page {
 
 .page {
   width: 100%;
-  height: 800rpx;
+  height: 100%;
 }
 
 .preview-tips {

+ 67 - 73
miniprogram/pages/faceRecognition/index.ts

@@ -8,20 +8,12 @@ Page({
   data: {
     videoSrc: '', // 录制的视频临时路径
     isBack: false, // 是否返回上一页,用于页面隐藏时判断
-    id_card: '',
-    program_id: ''
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(opt) {
-    this.setData({
-      id_card: opt.IDCard,
-      program_id: opt.program_id
-    })
-    console.log(this.data.program_id)
-    console.log(this.data.id_card)
   },
 
   /**
@@ -79,88 +71,90 @@ Page({
 
   },
   // 当取消授权或者打开设置授权
-  handleNoAuth(res:any) {
+  handleNoAuth(res: any) {
     console.log("用户拒绝授权:", res)
     // 因为在设置里授权摄像头不会立即生效,所以要返回上一页,确保重新进入当前页使摄像头生效
     setTimeout(() => {
       wx.navigateBack()
     }, 500)
   },
-  
-    // 版本号过低的回调
-    handleCannotuse() {
-      console.log('版本号过低无法使用, 组件内已经弹窗提示过了')
-      wx.navigateBack()
+
+  // 版本号过低的回调
+  handleCannotuse() {
+    console.log('版本号过低无法使用, 组件内已经弹窗提示过了')
+    wx.navigateBack()
   },
 
   // 视频录制完成
-  handleComplete(e:WechatMiniprogram.CustomEvent) {
-      console.log('视频文件路径:', e.detail)
-      // e.detail: 视频临时路径
-      this.setData({
-          videoSrc: e.detail.toString(),
-          isBack: false
-      })
+  handleComplete(e: WechatMiniprogram.CustomEvent) {
+    console.log('视频文件路径:', e.detail)
+    // e.detail: 视频临时路径
+    this.setData({
+      videoSrc: e.detail.toString(),
+      isBack: false
+    })
 
-      // 打印视频信息文件
-      const fileSystemManager = wx.getFileSystemManager();
-      fileSystemManager.getFileInfo({
-        filePath: e.detail.toString(),
-          success: (res) => {
-              const {
-                  size
-              } = res
-              console.log("视频文件大小M:", size / Math.pow(1024, 2))
-          },
-          fail: (err) => {
-              console.log("获取视频文件失败", err)
-          }
-      })
+    // 打印视频信息文件
+    const fileSystemManager = wx.getFileSystemManager();
+    fileSystemManager.getFileInfo({
+      filePath: e.detail.toString(),
+      success: (res) => {
+        const {
+          size
+        } = res
+        console.log("视频文件大小M:", size / Math.pow(1024, 2))
+      },
+      fail: (err) => {
+        console.log("获取视频文件失败", err)
+      }
+    })
 
-      this.uploadVideo()
+    this.uploadVideo()
   },
 
   uploadVideo() {
-      var src = this.data.videoSrc
-      wx.showLoading({
-          title: '上传进度:0%',
-          mask: true //是否显示透明蒙层,防止触摸穿透
-      })
+    var src = this.data.videoSrc
+    wx.showLoading({
+      title: '采集进度:0%',
+      mask: true //是否显示透明蒙层,防止触摸穿透
+    })
 
-      console.log(this.data.program_id)
-
-      // todo: 添加上传服务器的接口
-      const uploadTask = wx.uploadFile({
-          // 仅为示例,非真实的接口地址,视频上传
-          url: base.url + '/v3/upload', 
-          filePath: src,
-          name: 'file', //服务器定义的Key值
-          formData: {},
-          header: {
-            Authorization: wx.getStorageSync("token")
-          },
-          success: function (res) {
-              console.log(res)
-              console.log('视频上传成功')
-              wx.showToast({
-                title: "上传成功"
-              })
-          },
-          fail: function (res) {
-              console.log(res)
-              console.log('接口调用失败')
-          }
-      })
 
-      //监听上传进度变化事件
-      uploadTask.onProgressUpdate((res) => {
-          wx.showLoading({
-              title: '上传进度:' + res.progress + '%',
-              mask: true //是否显示透明蒙层,防止触摸穿透
+    // todo: 添加上传服务器的接口
+    const uploadTask = wx.uploadFile({
+      // 仅为示例,非真实的接口地址,视频上传
+      url: base.url + '/v3/upload',
+      filePath: src,
+      name: 'file', //服务器定义的Key值
+      formData: {},
+      header: {
+        Authorization: wx.getStorageSync("token")
+      },
+      success: function (res) {
+        console.log(res)
+        console.log('视频上传成功')
+        wx.showToast({
+          title: "人脸采集完成"
+        })
+        let time = setTimeout(() => {
+          clearTimeout(time);
+          wx.reLaunch({
+            url: "/pages/downloadPage/index"
           })
-          console.log("上传进度", res.progress)
-          console.log("已经上传的数据长度,单位 Bytes:", res.totalBytesSent)
-          console.log("预期需要上传的数据总长度,单位 Bytes:", res.totalBytesExpectedToSend)
+        }, 2000)
+      },
+      fail: function (res) {
+        console.log(res)
+        console.log('接口调用失败')
+      }
+    })
+
+    //监听上传进度变化事件
+    uploadTask.onProgressUpdate((res) => {
+      wx.showLoading({
+        title: '采集进度:' + res.progress + '%',
+        mask: true //是否显示透明蒙层,防止触摸穿透
       })
+    })
   }
 })

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

@@ -56,6 +56,7 @@ Page({
 
   // 创建人脸追踪
   createVK() {
+    console.log("开始追踪人脸");
     createVKSession = wx.createVKSession({
       version: "v2",
       track: {
@@ -79,10 +80,17 @@ Page({
 
     // 当人脸从相机中离开时,会触发 removeAnchors 事件
     createVKSession.on('removeAnchors', () => {
-      console.log('未检测到人脸');
+      wx.showToast({
+        icon: "none",
+        title: "未检测到人脸,请重新录制"
+      })
       //  录制失败
       this.overVideo();
     })
+
+    createVKSession.start((errno) => {
+      console.log(errno);
+    })
   },
 
   // 结束录像
@@ -91,6 +99,7 @@ Page({
     wx.showLoading({
       title: ""
     })
+    createVKSession?.stop();
     ctx.stopRecord({
       compressed: true,
       success: res => {

+ 2 - 0
miniprogram/pages/home/index.json

@@ -1,3 +1,5 @@
 {
+  "navigationBarBackgroundColor": "#2AB0FF",
+  "navigationBarTextStyle": "white",
   "usingComponents": {}
 }

+ 28 - 6
miniprogram/pages/home/index.scss

@@ -1,8 +1,30 @@
 /* pages/home/index.wxss */
-.home {
-  width: 750rpx;
-  .top{
-    width: 750rpx;
-    margin-bottom: 15rpx;
+.page {
+  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;
+
+  .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%;
+    transform: translateX(-50%);
+    color: #FFFFFF;
+    text-align: center;
+    padding: 18rpx 86rpx;
+    font-size: 14px;
+    font-weight: 500;
+  }
+}

+ 32 - 87
miniprogram/pages/home/index.ts

@@ -6,14 +6,44 @@ Page({
    * 页面的初始数据
    */
   data: {
-    height: 0,
-    videoSrc: ""
+  },
+
+  titleLoad(e: WechatMiniprogram.CustomEvent) {
+    console.log(e.detail);
+  },
+
+  lvru() {
+      app.getUser({
+      data: {},
+      success: (res: any) => {
+        console.log(res);
+        if (!res.RESULT) return wx.showToast({
+          "title": "视频正在生成中,请耐心等待"
+        })
+        if (!res.SAVE_USER_INFO) {
+          // 未上传用户信息,跳转用户信息页
+          wx.navigateTo({
+            url: "/pages/entry/index"
+          })
+          return;
+        }
+        if (!res.UPLOAD_FACE){
+          // 未上传人脸信息,跳转人脸采集页
+          wx.navigateTo({
+            url: "/pages/faceRecognition/index"
+          })
+          return;
+
+        }
+      }
+    })
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad() {
+
   },
 
   /**
@@ -63,90 +93,5 @@ Page({
    */
   onShareAppMessage() {
 
-  },
-
-
-  loadimage(e: WechatMiniprogram.CustomEvent) {
-    const width: number = e.detail.width;
-    const height: number = e.detail.height;
-    this.setData({
-      height: 750 * (height / width)
-    })
-  },
-
-  getPay() {
-    app.createOrder({
-      success: (res: any) => {
-        console.log('支付:', res);
-        wx.requestPayment({
-          timeStamp: res.timeStamp,
-          nonceStr: res.nonceStr,
-          package: res.package,
-          paySign: res.paySign,
-          signType: res.signType,
-          success(res) {
-            console.log("pay--->", res);
-          },
-          fail(err) {
-            console.log("err---> ", err);
-          }
-        })
-      },
-    })
-
-  },
-  getPhoneNumber(e: WechatMiniprogram.CustomEvent) {
-    app.getPhone({
-      data: {
-        code: e.detail.code
-      },
-      header: {},
-      success: () => { }
-    })
-  },
-  face() {
-    wx.navigateTo({
-      url: "/pages/faceRecognition/index"
-    })
-  },
-  faceVK(){
-    wx.navigateTo({
-      url: "/pages/faceRecognitionVk/index"
-    })
-  },
-  tonamtve() {
-    wx.navigateTo({
-      url: "/pages/index/index"
-    })
-  },
-  getVideo() {
-    app.getVideo({
-      success: (res: any) => {
-        this.setData({
-          videoSrc: res.url
-        });
-        wx.downloadFile({
-          url: res.url,
-          success: (res) =>{
-            wx.saveVideoToPhotosAlbum({
-              filePath: res.tempFilePath,
-              success: () => {
-                wx.showToast({
-                  title: "保存成功",
-                  icon: "none"
-                })
-              }
-            })
-          }
-        })
-      }
-    })
-  },
-  isVideo() {
-    app.createVideo({
-      success: (res: any) => {
-        console.log('是否生成视频:', res.data);
-      }
-    })
   }
 })

+ 6 - 11
miniprogram/pages/home/index.wxml

@@ -1,13 +1,8 @@
 <!--pages/home/index.wxml-->
-<view class="home">
-  <image class="top" style="height:{{height}}rpx" bindload="loadimage" src="../../assets/image/0.jpg" mode="scaleToFill" />
-  <button bindtap="getPay" type="primary">支付</button> 
-  <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">获取手机号</button>
-  <button bindtap="face" type="primary">人脸录制</button>
-  <button bindtap="faceVK" type="primary">人脸录制vk</button>
-  <button bindtap="getVideo">获得视频</button>
-  <button bindtap="tonamtve" type="primary">index</button>
-  <button bindtap="isVideo">是否生成视频</button>
+<view class="page">
+  <image class="title" src="../../assets/image/title.png" mode="scaleToFill" bindload="titleLoad"/>
 
-  <video src="{{videoSrc}}"/>
-</view>
+  <view class="buttom"  bindtap="lvru">
+    登记选手信息
+  </view>
+</view>

+ 3 - 0
miniprogram/pages/tool/index.json

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

+ 8 - 0
miniprogram/pages/tool/index.scss

@@ -0,0 +1,8 @@
+/* pages/home/index.wxss */
+.home {
+  width: 750rpx;
+  .top{
+    width: 750rpx;
+    margin-bottom: 15rpx;
+  }
+}

+ 146 - 0
miniprogram/pages/tool/index.ts

@@ -0,0 +1,146 @@
+// pages/home/index.ts
+const app = getApp<IAppOption>();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    height: 0,
+    videoSrc: ""
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad() {
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  },
+
+
+  loadimage(e: WechatMiniprogram.CustomEvent) {
+    const width: number = e.detail.width;
+    const height: number = e.detail.height;
+    this.setData({
+      height: 750 * (height / width)
+    })
+  },
+
+  getPay() {
+    app.createOrder({
+      success: (res: any) => {
+        console.log('支付:', res);
+        wx.requestPayment({
+          timeStamp: res.timeStamp,
+          nonceStr: res.nonceStr,
+          package: res.package,
+          paySign: res.paySign,
+          signType: res.signType,
+          success(res) {
+            console.log("pay--->", res);
+          },
+          fail(err) {
+            console.log("err---> ", err);
+          }
+        })
+      },
+    })
+
+  },
+  getPhoneNumber(e: WechatMiniprogram.CustomEvent) {
+    console.log(e)
+    app.getPhone({
+      data: {
+        code: e.detail.code
+      },
+      header: {},
+      success: () => { }
+    })
+  },
+  face() {
+    wx.navigateTo({
+      url: "/pages/faceRecognition/index"
+    })
+  },
+  faceVK(){
+    wx.navigateTo({
+      url: "/pages/faceRecognitionVk/index"
+    })
+  },
+  tonamtve() {
+    wx.navigateTo({
+      url: "/pages/index/index"
+    })
+  },
+  getVideo() {
+    app.getVideo({
+      success: (res: any) => {
+        this.setData({
+          videoSrc: res.url
+        });
+        wx.downloadFile({
+          url: res.url,
+          success: (res) =>{
+            wx.saveVideoToPhotosAlbum({
+              filePath: res.tempFilePath,
+              success: () => {
+                wx.showToast({
+                  title: "保存成功",
+                  icon: "none"
+                })
+              }
+            })
+          }
+        })
+      }
+    })
+  },
+})

+ 12 - 0
miniprogram/pages/tool/index.wxml

@@ -0,0 +1,12 @@
+<!--pages/home/index.wxml-->
+<view class="home">
+  <image class="top" style="height:{{height}}rpx" bindload="loadimage" src="../../assets/image/0.jpg" mode="scaleToFill" />
+  <button bindtap="getPay" type="primary">支付</button> 
+  <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">获取手机号</button>
+  <button bindtap="face" type="primary">人脸录制</button>
+  <button bindtap="faceVK" type="primary">人脸录制vk</button>
+  <button bindtap="getVideo">获得视频</button>
+  <button bindtap="tonamtve" type="primary">index</button>
+
+  <video src="{{videoSrc}}"/>
+</view>

+ 9 - 1
miniprogram/utils/request.ts

@@ -2,6 +2,9 @@ import {base} from "../config/index"
 import { errHttp } from "./util";
 
 export default function request(params:WechatMiniprogram.requestParamsData) {
+  wx.showLoading({
+    title: ""
+  })
   return wx.request({
     url: base.url + params.url,
     data: params.data,
@@ -17,9 +20,14 @@ export default function request(params:WechatMiniprogram.requestParamsData) {
     },
     method: params.method || "GET",
     fail: err =>{
-      console.log(err)
+      console.log(err);
+      wx.showToast({
+        title: err.errMsg || "请稍后再试",
+        icon:"none"
+      })
     },
     complete: () => {
+      wx.hideLoading()
     }
   })
 }

+ 3 - 1
project.config.json

@@ -19,7 +19,9 @@
     },
     "condition": false,
     "es6": true,
-    "enhance": true
+    "enhance": true,
+    "postcss": true,
+    "minified": true
   },
   "simulatorType": "wechat",
   "simulatorPluginLibVersion": {},

+ 29 - 1
project.private.config.json

@@ -10,7 +10,35 @@
       "list": [
         {
           "name": "",
-          "pathName": "pages/faceRecognitionVk/index",
+          "pathName": "pages/entry/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/tool/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/home/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/downloadPage/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/faceRecognition/index",
           "query": "",
           "launchMode": "default",
           "scene": null

+ 2 - 1
typings/index.d.ts

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

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

@@ -3,9 +3,7 @@ declare namespace WechatMiniprogram {
   interface requestParamsData {
     url?: string;
     data?: Object;
-    header?: {
-      
-    };
+    header?: {};
     method?:  "GET" | "OPTIONS" | "HEAD" | "POST" | "PUT" | "DELETE" | "TRACE" | "CONNECT" | undefined;
     dataType?: 'json' | '其他';
     success:AccessCompleteCallback