Explorar o código

没人的课也自动跳走,防止阻塞生命周期

Changpeng Duan %!s(int64=5) %!d(string=hai) anos
pai
achega
deb865fa80
Modificáronse 5 ficheiros con 89 adicións e 16 borrados
  1. 6 0
      app/src/page/mainpage.vue
  2. 3 3
      tv/src/Mock/index.js
  3. 28 6
      tv/src/views/2pkRank.vue
  4. 49 6
      tv/src/views/3pkRank.vue
  5. 3 1
      tv/src/views/pk.vue

+ 6 - 0
app/src/page/mainpage.vue

@@ -64,6 +64,12 @@
         mounted() {
             this.getManagerSelfQuery();
             // this.alertInfo(document.body.clientWidth)
+            console.log(123);
+            // navigator.geolocation.getCurrentPosition(function (position) {
+            //   console.log(position.coords.longitude);
+            // },function (err) {
+            //     console.log(err);
+            // })
         },
         destroyed() {
         },

+ 3 - 3
tv/src/Mock/index.js

@@ -137,8 +137,8 @@ let testStudent = function (num, team) {
             IsNewUser: 0,
             MaxHr: 80,
             Name: "@cname",
-            PkSucessnum: '@integer(0, 999)',//胜场数
-            PkTotalnum: '@integer(0, 999)',//总场数
+            PkSucessnum: '1',//胜场数
+            PkTotalnum: '1',//总场数
             PlanId: 60,
             PureCalorieNoVo2: "@integer(1, 999)",
             Sex: 1,
@@ -386,7 +386,7 @@ if (t == 0) {
         }else if (LessonDp == 3) {
             Mock.mock(curheadapi + 'ClassStatQuery', 'post', getClassStat(0, 3));
             // 下课排名
-            Mock.mock(curheadapi + 'ClassUserRank', 'post', testStudent(6, 3));
+            Mock.mock(curheadapi + 'ClassUserRank', 'post', testStudent(12, 3));
         }
     }
 

+ 28 - 6
tv/src/views/2pkRank.vue

@@ -199,25 +199,44 @@
                 let blueSum = 0;
                 Rs.redUnite.map(function (item, t) {
                     redSum += parseFloat(item.Ck.toFixed(1));
-                    that.successCalc(item);
                 });
                 Rs.blueUnite.map(function (item, t) {
                     blueSum += parseFloat(item.Ck.toFixed(1));
-                    that.successCalc(item);
+                    // that.successCalc(item);
                 });
                 that.redSum = redSum.toFixed(1);
                 that.blueSum = blueSum.toFixed(1);
-
                 // 上报胜率结果
                 let groupNo = redSum >= blueSum ? 1 : 2;
                 that.PostAddPkInfo(PlanId, groupNo);
+                // 计算本场胜率
+                that.getWhoWin(Rs.redUnite, Rs.blueUnite, groupNo);
+            },
+            getWhoWin(redUnite, blueUnite, groupNo) {
+                let that = this;
+                if (groupNo == 1) {
+                    redUnite.map(function (item, t) {
+                        that.successCalc(item, 1);
+                    });
+                    blueUnite.map(function (item, t) {
+                        that.successCalc(item, 0);
+                    });
+                } else {
+                    redUnite.map(function (item, t) {
+                        that.successCalc(item, 0);
+                    });
+                    blueUnite.map(function (item, t) {
+                        that.successCalc(item, 1);
+                    });
+                }
             },
             // 插入胜率结果
-            successCalc(item) {
-                if (item.PkTotalnum == 0 || item.PkSucessnum == 0) {
+            successCalc(item, Victorl) {
+                // item.success = '胜' + (parseInt(item.PkSucessnum) + parseInt(Victorl)) + ' 总:' + (parseInt(item.PkTotalnum) + 1) + '结' + (parseFloat(parseInt(item.PkSucessnum) + parseInt(Victorl)) / (parseInt(item.PkTotalnum) + 1)) * 100
+                if (parseInt(item.PkTotalnum + Victorl) == 0) {
                     item.success = 0;
                 } else {
-                    let res = (parseFloat(parseFloat(item.PkSucessnum) / parseFloat(item.PkTotalnum)) * 100);
+                    let res = (parseFloat(parseInt(item.PkSucessnum) + parseInt(Victorl)) / (parseInt(item.PkTotalnum) + 1)) * 100;
                     if (res >= 100) {
                         item.success = 100;
                     } else {
@@ -254,6 +273,7 @@
                     } else {
                         this.students.CkSort = [];
                         this.students.CalSort = [];
+                        this.jumpWait(10);
                         if (json.Code == '999') {
                             // that.$router.push({path: '/'});
                         } else {
@@ -538,6 +558,7 @@
     li .CLEscore span {
         padding-left: 0.1rem;
         font-size: 0.6rem;
+        /*font-size: 12px;*/
     }
 
     li .CKscore {
@@ -612,6 +633,7 @@
         font-size: 0.4rem;
         color: #fff;
     }
+
     /deep/ .el-col {
         min-height: 1rem;
     }

+ 49 - 6
tv/src/views/3pkRank.vue

@@ -295,14 +295,50 @@
                     {name: "blue", val: that.blueSum},
                     {name: "yellow", val: that.yellowSum},
                 ];
-                that.getUnitRank(res, PlanId);
+                that.getUnitRank(res, PlanId,Rs);
+            },
+            getWhoWin(redUnite, blueUnite, yellowUnite, groupNo) {
+                let that = this;
+                if (groupNo == 1) {
+                    redUnite.map(function (item, t) {
+                        that.successCalc(item, 1);
+                    });
+                    blueUnite.map(function (item, t) {
+                        that.successCalc(item, 0);
+                    });
+                    yellowUnite.map(function (item, t) {
+                        that.successCalc(item, 0);
+                    });
+                } else if (groupNo == 2) {
+                    redUnite.map(function (item, t) {
+                        that.successCalc(item, 0);
+                    });
+                    blueUnite.map(function (item, t) {
+                        that.successCalc(item, 1);
+                    });
+                    yellowUnite.map(function (item, t) {
+                        that.successCalc(item, 0);
+                    });
+                } else if (groupNo == 3) {
+                    redUnite.map(function (item, t) {
+                        that.successCalc(item, 0);
+                    });
+                    blueUnite.map(function (item, t) {
+                        that.successCalc(item, 0);
+                    });
+                    yellowUnite.map(function (item, t) {
+                        that.successCalc(item, 1);
+                    });
+                }
             },
             // 插入胜率结果
-            successCalc(item) {
-                if (item.PkTotalnum == 0 || item.PkSucessnum == 0) {
+            successCalc(item,Victorl ) {
+                // item.success = '胜' + (parseInt(item.PkSucessnum) + parseInt(Victorl)) + ' 总:' + (parseInt(item.PkTotalnum) + 1) + '结' + (parseFloat(parseInt(item.PkSucessnum) + parseInt(Victorl)) / (parseInt(item.PkTotalnum) + 1)) * 100
+
+                if (parseInt(item.PkTotalnum + Victorl) == 0) {
                     item.success = 0;
                 } else {
-                    let res = (parseFloat(parseFloat(item.PkSucessnum) / parseFloat(item.PkTotalnum)) * 100);
+                    let res = (parseFloat(parseInt(item.PkSucessnum) + parseInt(Victorl)) / (parseInt(item.PkTotalnum) + 1)) * 100;
                     if (res >= 100) {
                         item.success = 100;
                     } else {
@@ -311,7 +347,7 @@
                 }
             },
             // 结果排序
-            getUnitRank(res, PlanId) {
+            getUnitRank(res, PlanId,Rs) {
                 let that = this;//这个that不要删
                 let sum = res.sort(function (a, b) {
                     return b.val - a.val;
@@ -335,7 +371,10 @@
                         groupNo = 3;
                         break
                 }
+                // 上报本场胜率
                 that.PostAddPkInfo(PlanId, groupNo);
+                // 计算本场胜率
+                that.getWhoWin(Rs.redUnite, Rs.blueUnite,Rs.yellowUnite, groupNo);
             },
             getClassUserRank() {
                 let that = this;
@@ -367,6 +406,7 @@
                         // this.students.CkSort = json.Rs.CkSort;
                         // this.students.CalSort = json.Rs.CalSort;
                     } else {
+                        this.jumpWait(10);
                         if (json.Code == '999') {
                             // that.$router.push({path: '/'});
                         } else {
@@ -390,7 +430,8 @@
                     if (json.Code == 0) {
                         console.log('竞技课程结果上传成功dpid:' + dpId + ' groupNo:' + groupNo);
                     } else {
-                        that.$message.error(json.Memo);
+                        console.log(json.Memo);
+                        // that.$message.error(json.Memo);
                     }
                 })
             }
@@ -694,11 +735,13 @@
 
     li .CLEscore em {
         font-size: 0.3rem;
+        /*font-size: 0;*/
     }
 
     li .CLEscore span {
         padding-left: 0.1rem;
         font-size: 0.3rem;
+        /*font-size: 12px;*/
     }
 
     li .CKscore {

+ 3 - 1
tv/src/views/pk.vue

@@ -22,7 +22,9 @@
                                     <i class="el-icon-female" v-if="s.Sex == 2"></i>
                                 </div>
                                 <div class="nameMd">{{ s.Name }}</div>
-                                <div class="namert"></div>
+                                <div class="namert">
+                                    <!--<img src="../static/img/comm/isPrivate.svg" alt="" v-if="s.isPrivate" style="float: right;margin-right: 0.2rem;margin-top: 0.1rem">-->
+                                </div>
                             </h5>
                             <div class="user">
                                 <div class="ult">