| 
					
				 | 
			
			
				@@ -12,7 +12,7 @@ Page({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     index: 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     curStu: {}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     classList: [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      { img: '/images/kc.png', title: '今日课程', num: '0', url:"/pages/schedule/schedule" }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      { img: '/images/kc.png', title: '今日课程', num: '0', url: "/pages/schedule/schedule" }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       { img: '/images/jtzy.png', title: '今日作业', num: '0' }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       { img: '/images/cq.png', title: '出勤率', num: '0%' }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ], 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -30,6 +30,8 @@ Page({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     userList: [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     userItems: [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     orgItems: [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    stuShowList: [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    teaShowList: [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   //切换身份 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -85,7 +87,7 @@ Page({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  toPage:function(e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  toPage: function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     wx.navigateTo({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       url: e.currentTarget.dataset.url, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -147,15 +149,43 @@ Page({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   strLen(s) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return (s ? s.length : 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return (s ? s.length : 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  loadVideoInfo: function (videos, personType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let urls = urlDef.urls 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    videos.forEach(v => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      util.apiPost(urls.video_loadInfo + v.videoId).then((rs) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        v.imgUrl = rs.img 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        v.playUrl = rs.url 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (personType == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          this.setData({ 'stuShowList': videos }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (personType == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          this.setData({ 'teaShowList': videos }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  queryVideoShow: function (personType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const urls = urlDef.urls; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //获取登录用户数据, 并加载首页数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    util.apiPost(urls.person_video_list, { 'q.orgId': this.data.curStu.orgId, 'q.doPersonId': this.data.curStu.studentId, 'q.personType': personType, 'q.sortBy': 'rand', 'q.limit4': 'true' }).then(rs => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      this.loadVideoInfo(rs, personType) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  queryStudentShow: function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.queryVideoShow(0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  queryTeacherShow: function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.queryVideoShow(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   loadIndexData: function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     const urls = urlDef.urls; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     //获取登录用户数据, 并加载首页数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     util.apiPost(urls.get_cur_user, {}).then(rs => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // console.log(JSON.stringify(rs)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      let userItems = rs.attr.others; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      let orgItems = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      let userItems = rs.attr.others 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      let orgItems = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       userItems.forEach(u => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let exists = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         orgItems.some(o => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -163,65 +193,96 @@ Page({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             exists = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (!exists) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          orgItems.push({ orgId: u.orgId, orgName: u.orgName }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          orgItems.push({ orgId: u.orgId, orgName: u.orgName }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (u.id === rs.id) { // 当前用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          this.setData({ 'curStu': { studentId: u.studentId, orgId: u.orgId } }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          let student = { studentId: u.studentId, orgId: u.orgId } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          this.setData({ 'curStu': student }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // 放入 strong中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          wx.setStorageSync('student', student); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (this.strLen(u.imageUrl) === 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          u.imageUrl = '/images/head.png'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          u.imageUrl = '/images/head.png' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          u.imageUrl = urls.oss_file + 'image/' + u.imageUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          u.imageUrl = urls.oss_file + 'image/' + u.imageUrl 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      this.setData({ 'userItems': userItems, 'orgItems': orgItems }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      this.setData({ 'userItems': userItems, 'orgItems': orgItems }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      let personId = rs.attr.personId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      let orgId = rs.attr.orgId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      let today = util.curTime().substring(0, 10).replace(/\//g, '-'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      let personId = rs.attr.personId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      let orgId = rs.attr.orgId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      let today = util.curTime().substring(0, 10).replace(/\//g, '-') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // banner 图片 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       util.apiPost(urls.get_advert, { '&q.use': 1, 'q.orgId': orgId, 'q.exceptStatus': 2 }).then(r => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // console.log('banner : ' + JSON.stringify(r)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.setData({ 'bannerList': r }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.setData({ 'bannerList': r }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // 今日课程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       util.apiPost(urls.leave_get_classes_date, { 'q.studentId': personId, 'q.attenceDate': today }).then(r => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // console.log('今日课程 : ' + JSON.stringify(r)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.setData({ 'classList[0].num': (r ? r.length : 0) }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.setData({ 'classList[0].num': (r ? r.length : 0) }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // 作业未提交 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       util.apiPost(urls.my_homework, { 'q.studentId': personId, 'q.status': 0 }).then(r => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // console.log('作业未提交 : ' + JSON.stringify(r)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.setData({ 'classList[1].num': (r ? r.length : 0) }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.setData({ 'classList[1].num': (r ? r.length : 0) }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // 出勤率 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       util.apiPost(urls.get_attendance_rate, { 'q.studentId': personId }).then(r => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        console.log('出勤率 : ' + JSON.stringify(r)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // console.log('出勤率 : ' + JSON.stringify(r)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let attendRate = 0, alreadyCount = 0, shouldCount = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (r != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           r.forEach(it => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (it.isAttend === '1') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              alreadyCount = it.num; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              alreadyCount = it.num 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } else if (it.isAttend === '0') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              shouldCount = it.num; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              shouldCount = it.num 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        let t = (alreadyCount + shouldCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let t = (alreadyCount + shouldCount) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (t > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          attendRate = alreadyCount * 100 / t; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          attendRate = alreadyCount * 100 / t 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        console.log(attendRate) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.setData({ 'classList[2].num': attendRate.toFixed(2) + '%' }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.setData({ 'classList[2].num': attendRate.toFixed(2) + '%' }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      this.queryVideoShow(0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      this.queryVideoShow(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  doThumbsUp: function (o) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const urls = urlDef.urls; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let pid = this.data.curStu.studentId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let pt = o.detail.personType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let vid = o.detail.videoId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let entity = { videoId: vid, personId: pid, personType: pt, actionType: 1 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    util.apiPost(urls.person_video_view_save, entity, 'application/json').then(rs => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (pt == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.data.stuShowList.map(o => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if (o.videoId == vid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            o.goodCount += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.setData({ 'stuShowList': this.data.stuShowList }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (pt == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.data.teaShowList.map(o => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if (o.videoId == vid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            o.goodCount += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.setData({ 'teaShowList': this.data.teaShowList }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }).catch(e => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      console.log(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }) 
			 |