Przeglądaj źródła

课时统计、视频播放,老师秀,学生秀详情 ,数据对接

zhangshuling 3 lat temu
rodzic
commit
2c62a003e3

+ 28 - 23
pages/Components/selectDate/selectDate.js

@@ -1,7 +1,7 @@
 // pages/Components/selectDate/selectDate.js
 Component({
-  lifetimes:{
-    attached:function(){
+  lifetimes: {
+    attached: function () {
       var date = new Date()
       const year = date.getFullYear()
       const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
@@ -16,17 +16,22 @@ Component({
    * 组件的属性列表
    */
   properties: {
-
+    beginDate: {
+      type: String
+    },
+    endDate: {
+      type: String
+    }
   },
 
   /**
    * 组件的初始数据
    */
   data: {
-    beginDate: '2000-01-01',
+    beginDate: '2020-01-01',
     endDate: '2021-02-02',
-    initDate:'2000-01-01',
-    lastDate:'',
+    initDate: '2020-01-01',
+    lastDate: '',
     yFlag: false,
     animationBox: {},
     animationBg: {},
@@ -36,8 +41,8 @@ Component({
    * 组件的方法列表
    */
   methods: {
-    bindBeginDateChange:function(e){
-      if(e.detail.value > this.data.endDate){
+    bindBeginDateChange: function (e) {
+      if (e.detail.value > this.data.endDate) {
         this.setData({
           beginDate: this.data.endDate
         })
@@ -48,8 +53,8 @@ Component({
       }
     },
 
-    bindEndDateChange:function(e){
-      if(e.detail.value > this.data.endDate){
+    bindEndDateChange: function (e) {
+      if (e.detail.value > this.data.endDate) {
         this.setData({
           endDate: this.data.lastDate
         })
@@ -60,30 +65,30 @@ Component({
       }
     },
 
-    resetDate:function(){
+    resetDate: function () {
       this.setData({
         beginDate: this.data.initDate,
         endDate: this.data.lastDate
       })
-      const dateArr = [this.data.initDate,this.data.lastDate];
-      this.triggerEvent("getDates",dateArr);
+      const dateArr = [this.data.initDate, this.data.lastDate];
+      this.triggerEvent("getDates", dateArr);
       this.showSelect()
     },
 
-    submitDate:function(){
-      const dateArr = [this.data.beginDate,this.data.endDate];
-      this.triggerEvent("getDates",dateArr);
+    submitDate: function () {
+      const dateArr = [this.data.beginDate, this.data.endDate];
+      this.triggerEvent("getDates", dateArr);
       this.showSelect()
     },
 
-    showSelect:function(){
+    showSelect: function () {
       var animation = wx.createAnimation({
         timingFunction: 'linear',
       })
       this.animation = animation
       var num = 0
       var opacity = 0
-      if(this.data.yFlag == false){
+      if (this.data.yFlag == false) {
         num = 180
         opacity = 0.4
         this.setData({
@@ -98,19 +103,19 @@ Component({
       }
       animation.translateY(num).step()
       this.setData({
-        animationBox:animation.export()
+        animationBox: animation.export()
       })
-  
+
       var animation2 = wx.createAnimation({
         timingFunction: 'linear',
       })
       this.animation2 = animation2
-  
+
       animation2.opacity(opacity).step()
       this.setData({
-        animationBg:animation2.export()
+        animationBg: animation2.export()
       })
-  
+
     },
   }
 })

+ 2 - 3
pages/Components/showList/showList.js

@@ -36,11 +36,10 @@ Component({
       })
     },
     doPlay: function (e) {
-      let playUrl = e.currentTarget.dataset.url
       const index = e.currentTarget.dataset.index
-      const str = JSON.stringify(this.data.list[index])
+      let o = this.data.list[index]
       wx.navigateTo({
-        url: '/pages/playShow/playShow?str='+str,
+        url: '/pages/playShow/playShow?vid='+o.videoId,
       })
     }
   },

+ 44 - 7
pages/classTotalList/classTotalList.js

@@ -1,21 +1,27 @@
 // pages/classTotalList/classTotalList.js
+const app = getApp()
+const util = require("../../utils/util")
+const urlDef = require("../../utils/urls")
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    list:[
-      {},
-      {}
-    ]
+    list: [],
+    courseItems: [],
+    moneyItems: [],
+    loading: '上拉加载',
+    flag: 0,
+    pageNum: 0,
+    hasNextPage: true,
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    this.queryList()
   },
 
   /**
@@ -57,7 +63,11 @@ Page({
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
-
+    if (this.data.hasNextPage) {
+      let pn = this.data.pageNum
+      this.setData({ loading: '加载中', 'pageNum': ++pn })
+      this.queryList()
+    }
   },
 
   /**
@@ -65,5 +75,32 @@ Page({
    */
   onShareAppMessage: function () {
 
-  }
+  },
+  queryList: function () {
+    const urls = urlDef.urls;
+    let stu = wx.getStorageSync('student')
+    let params = { 'q.studentId': stu.studentId, 'q.orgId': stu.orgId }
+    params.pageNum = this.data.pageNum
+    util.apiPost(urls.get_course_report, params).then(rs => {
+      let list = rs.list
+      list.map(it => {
+        let item = Object.assign({}, it);
+        if (item.endDate) {
+          item.endDate = item.endDate.substring(0, 10)
+        }
+        if (it.billingMethod === 'T' || it.billingMethod === 'P') {
+          this.data.courseItems.push(item);
+        } else if (it.billingMethod === 'M') {
+          this.data.moneyItems.push(item);
+        }
+      })
+
+      this.setData({
+        'hasNextPage': rs.hasNextPage,
+        'loading': rs.hasNextPage ? '下拉刷新' : '没有更多数据',
+        'courseItems': this.data.courseItems,
+        'moneyItems': this.data.moneyItems
+      })
+    })
+  },
 })

+ 22 - 6
pages/classTotalList/classTotalList.wxml

@@ -1,19 +1,35 @@
 <view class="container">
   <view class="class-view">
     <view class="class-list">
-      <view class="class-box" wx:for="{{list}}" wx:key="index">
+      <view class="class-box" wx:for="{{courseItems}}" wx:key="index">
         <view class="class-content">
           <view class="class-detail">
-            <view class="class-title">小象钢琴</view>
-            <view class="class-used">已上课时:1次</view>
-            <view class="class-vaild">有效期至:2021.05.01</view>
+            <view class="class-title">{{item.classesName}}</view>
+            <view class="class-used">已上课时:{{item.attendNum}}次</view>
+            <view class="class-vaild">有效期至:{{item.endDate}}</view>
           </view>
           <view class="class-lastTotal">
-            <view class="class-lastNum">22</view>
+            <view class="class-lastNum">{{item.surplusNum}}</view>
             <view class="class-lastTitle">剩余课时</view>
           </view>
         </view>
-        <view class="class-tip">本课程请假余额 5 次</view>
+        <view class="class-tip">本课程请假余额 {{item.surplusLeaveNum}} 次</view>
+      </view>
+
+
+      <view class="class-box" wx:for="{{moneyItems}}" wx:key="index">
+        <view class="class-content">
+          <view class="class-detail">
+            <view class="class-title">{{item.classesName}}</view>
+            <view class="class-used">已上课时:{{item.attendNum}}次</view>
+            <view class="class-vaild">有效期至:{{item.endDate}}</view>
+          </view>
+          <view class="class-lastTotal">
+            <view class="class-lastNum">{{item.surplusMoney}}</view>
+            <view class="class-lastTitle">剩余金额</view>
+          </view>
+        </view>
+        <view class="class-tip">本课程请假余额 {{item.surplusLeaveNum}} 次</view>
       </view>
     </view>
   </view>

+ 11 - 1
pages/evaluation/evaluation.js

@@ -23,7 +23,7 @@ Page({
     let id = e.currentTarget.dataset.id;
     let item = this.data.list.filter(o => o.id == id)[0]
     wx.navigateTo({
-      url: '/pages/evaluationDetail/evaluationDetail?item='+JSON.stringify(item)
+      url: '/pages/evaluationDetail/evaluationDetail?item=' + JSON.stringify(item)
     })
   },
 
@@ -90,6 +90,16 @@ Page({
    */
   onShareAppMessage: function () {
 
+  },
+  getDates: function (e) {
+    this.setData({
+      list: [],
+      pageNum: 0,
+      beginDate: e.detail[0],
+      endDate: e.detail[1],
+      loading: '加载中'
+    })
+    this.queryList()
   },
   queryList: function () {
     const urls = urlDef.urls;

+ 1 - 1
pages/evaluation/evaluation.wxml

@@ -1,7 +1,7 @@
 <view class="container">
 
   <!-- 时间筛选 -->
-  <selectDate></selectDate>
+  <selectDate bind:getDates="getDates" beginDate="{{beginDate}}" endDate="{{endDate}}"></selectDate>
   <!-- end -->
 
   <view class="evaluation-view">

+ 2 - 2
pages/index/index.js

@@ -143,9 +143,9 @@ Page({
     })
   },
 
-  getMoreShow: function () {
+  getMoreShow: function (e) {
     wx.navigateTo({
-      url: '/pages/showVideoList/showVideoList',
+      url: '/pages/showVideoList/showVideoList?personType=' + e.currentTarget.dataset.type,
     })
   },
 

+ 2 - 2
pages/index/index.wxml

@@ -65,7 +65,7 @@
   <view class="show-view">
     <view class="title-view">
       <view class="title">学生秀</view>
-      <view class="more" bindtap="getMoreShow">更多</view>
+      <view class="more" bindtap="getMoreShow" data-type="0">更多</view>
     </view>
     <showView list="{{stuShowList}}" bind:callThumbsUp="doThumbsUp"></showView>
     <view class="reset-btn" bindtap="queryStudentShow">换一批</view>
@@ -76,7 +76,7 @@
    <view class="show-view">
     <view class="title-view">
       <view class="title">老师秀</view>
-      <view class="more" bindtap="getMoreShow">更多</view>
+      <view class="more" bindtap="getMoreShow" data-type="1">更多</view>
     </view>
     <showView list="{{teaShowList}}" bind:callThumbsUp="doThumbsUp"></showView>
     <view class="reset-btn" bindtap="queryTeacherShow">换一批</view>

+ 16 - 36
pages/makePiano/makePiano.js

@@ -22,40 +22,6 @@ Page({
       '18:00 ~ 20:00',
       '20:00 ~ 22:00',
     ],
-    objectArray: [
-      {
-        id: 0,
-        name: '全部时间'
-      },
-      {
-        id: 1,
-        name: '08:00 ~ 10:00'
-      },
-      {
-        id: 2,
-        name: '10:00 ~ 12:00'
-      },
-      {
-        id: 3,
-        name: '12:00 ~ 14:00'
-      },
-      {
-        id: 4,
-        name: '14:00 ~ 16:00'
-      },
-      {
-        id: 5,
-        name: '16:00 ~ 18:00'
-      },
-      {
-        id: 6,
-        name: '18:00 ~ 20:00'
-      },
-      {
-        id: 7,
-        name: '20:00 ~ 22:00'
-      }
-    ],
     index: 0,
     schoolList: [
     ],
@@ -64,7 +30,8 @@ Page({
     curStu: null,
     pageNum: 0,
     hasNextPage: true,
-    schoolIndex: 0
+    schoolIndex: 0,
+    timeScope: '0,0'
   },
 
   getWeek: function (e) {
@@ -81,7 +48,20 @@ Page({
       index: e.detail.value
     })
   },
+  selectTime: function () {
+    let timeScope = '0,0'
+    if (this.data.index > 0) {
+      timeScope = this.data.array[this.data.index].replace(/\s*/g, '').replace('~', ',').replace(/:00/g,'')
+    }
+    this.setData({ timeScope: timeScope })
+    this.showSelect()
 
+    this.setData({
+      pageNum: 0,
+      schoolList: []
+    })
+    this.queryList()
+  },
   localtionMethod: function () {
     var that = this
     wx.getLocation({
@@ -287,7 +267,7 @@ Page({
     let date = w.ds
     let week = w.ws
 
-    let params = { 'q.orgId': sid, 'q.studentId': this.data.curStu.studentId, 'q.date': date, 'q.week': week }
+    let params = { 'q.orgId': sid, 'q.studentId': this.data.curStu.studentId, 'q.date': date, 'q.week': week, 'q.timeScope': this.data.timeScope }
     // params['q.timeScope'] = ''; 时段
     util.apiPost(urls.query_school_attence, params).then(rs => {
       s.items = rs

+ 1 - 1
pages/makePiano/makePiano.wxml

@@ -15,7 +15,7 @@
       </view>
     </view>
     <view class="search-btn-view">
-      <view class="search-btn">确定</view>
+      <view class="search-btn" bindtap="selectTime">确定</view>
       <view class="reset-btn">重置</view>
     </view>
   </view>

+ 10 - 0
pages/piano/piano.js

@@ -90,6 +90,16 @@ Page({
    */
   onShareAppMessage: function () {
 
+  },
+  getDates: function (e) {
+    this.setData({
+      list: [],
+      pageNum: 0,
+      beginDate: e.detail[0],
+      endDate: e.detail[1],
+      loading: '加载中'
+    })
+    this.queryList()
   },
   queryList: function () {
     const urls = urlDef.urls;

+ 1 - 1
pages/piano/piano.wxml

@@ -1,7 +1,7 @@
 <view class="container">
 
   <!-- 时间筛选 -->
-  <selectDate></selectDate>
+  <selectDate bind:getDates="getDates" beginDate="{{beginDate}}" endDate="{{endDate}}"></selectDate>
   <!-- end -->
   
   <view class="piano-list">

+ 80 - 6
pages/playShow/playShow.js

@@ -1,22 +1,24 @@
 // pages/playShow/playShow.js
+const app = getApp()
+const util = require("../../utils/util")
+const urlDef = require("../../utils/urls")
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    item: null
+    id: null,
+    item: null,
+    creator: null
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    const item = JSON.stringify(options.str)
-    this.setData({
-      item
-    })
-
+    this.setData({ id: options.vid })
+    this.loadInfo()
   },
 
   /**
@@ -65,6 +67,78 @@ Page({
    * 用户点击右上角分享
    */
   onShareAppMessage: function () {
+    return {
+      title: '视频秀',
+      path: '/pages/playShow/playShow?vid=' + this.data.id,
+      image: this.data.item.imgUrl
+    }
+  },
+  loadInfo: function () {
+    const urls = urlDef.urls;
+    let stu = wx.getStorageSync('student');
+    this.setData({ curStu: stu })
+
+    util.apiPost(urls.person_video_list + '&q.videoId=' + this.data.id).then((rs) => {
+      if (rs && rs.length > 0) {
+        let o = rs[0]
+        o.viewsCount = this.formatCount(o.viewsCount)
+        this.setData({ item: o })
+        util.apiPost(urls.video_loadInfo + this.data.id).then((rs) => {
+          o.imgUrl = rs.img
+          o.playUrl = rs.url
+          this.setData({ item: o })
+        })
+
+
+        let goodEntity = { videoId: this.data.id, personId: stu.studentId, personType: 1 };
+        util.apiPost(urls.person_video_view_save, goodEntity, 'application/json').then(rs => {
+        }).catch(e => {
+        });
+      }
+    })
+
+    util.apiPost(urls.query_video_creator + '&q.id=' + this.data.id).then((rs) => {
+      let u = rs
+      if (rs) {
+        u.imageUrl = '/images/head.png'
+      } else {
+        u = {}
+        u.imageUrl = urls.oss_file + 'image/' + u.imageUrl
+      }
+      this.setData({ creator: u })
+    })
+
 
+  },
+  doThumbsUp: function () {
+    let o = this.data.item
+    const urls = urlDef.urls;
+    let pid = this.data.curStu.studentId;
+    let pt = o.personType;
+    let vid = o.videoId;
+    let entity = {
+      videoId: vid,
+      personId: pid,
+      personType: pt,
+      actionType: 1
+    };
+    util.apiPost(urls.person_video_view_save, entity, 'application/json').then(rs => {
+      o.goodCount += 1
+      this.setData({
+        'item': o
+      })
+    }).catch(e => {
+      console.log(e);
+    })
+  },
+  formatCount(n) {
+    if (n >= 100000000) {
+      return (n / 100000000).toFixed(2) + '亿';
+    } else if (n >= 10000) {
+      return (n / 10000).toFixed(2) + '万';
+    } else if (n >= 1000) {
+      return (n / 1000).toFixed(2) + '千';
+    }
+    return n;
   }
 })

+ 2 - 1
pages/playShow/playShow.wxml

@@ -5,9 +5,10 @@
 
   <view class="title">{{item.title}}</view>
   <view class="desc">{{item.content}}</view>
+  <view class="desc2">浏览次数: {{item.viewsCount}}</view>
 
   <view class="edit-view">
-    <view class="zan-view" bindtap="zanBtn">
+    <view class="zan-view" bindtap="doThumbsUp">
       <image src="/images/zan.png" wx:if="{{item.goodCount <= 0}}"></image>
       <image src="/images/cur-zan.png" wx:else></image>
       <view>点赞</view>

+ 5 - 0
pages/playShow/playShow.wxss

@@ -16,6 +16,11 @@
 .desc{
   color: #999;
 }
+.desc2{
+  color: #999;
+  font-size: 24rpx;
+  padding-left: 24rpx;
+}
 
 .zan-view image,.share-view image{
   width: 100rpx ;

+ 93 - 29
pages/showVideoList/showVideoList.js

@@ -1,25 +1,34 @@
 // pages/showVideoList/showVideoList.js
+const app = getApp()
+const util = require("../../utils/util")
+const urlDef = require("../../utils/urls")
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    switchTitle:['热门','最新','我发布的','我点赞的'],
-    list:[
-      {},
-      {},
-      {},
+    personType: 0,
+    index: 0,
+    switchTitle: ['热门', '最新', '我点赞的', '我发布的'],
+    list: [
     ],
     loading: '上拉加载',
     flag: 0,
+    pageNum: 0,
+    hasNextPage: true,
+    curStu: null,
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    let personType = options.personType;
+    if (personType == 1) {
+      this.setData({ switchTitle: ['热门', '最新', '我点赞的'] })
+    }
+    this.setData({ personType: personType })
   },
 
   /**
@@ -33,7 +42,7 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-
+    this.queryList();
   },
 
   /**
@@ -61,28 +70,10 @@ Page({
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
-    if (this.data.flag == 0) {
-      this.setData({
-        loading: '加载中',
-        flag: 1
-      })
-      setTimeout(() => {
-        this.setData({
-          list: [{},
-            {},
-            {},
-            {},
-            {},
-            {},
-            {},
-            {},
-            {},
-            {},
-          ],
-          loading: '没有更多数据',
-          flag: 2
-        })
-      }, 2000);
+    if (this.data.hasNextPage) {
+      let pn = this.data.pageNum
+      this.setData({ loading: '加载中', 'pageNum': ++pn })
+      this.queryList()
     }
   },
 
@@ -91,5 +82,78 @@ Page({
    */
   onShareAppMessage: function () {
 
+  },
+  selectIndex: function (i) {
+    this.setData({ index: i.detail, list: [], pageNum: 0 })
+    this.queryList()
+  },
+  queryList: function () {
+    const urls = urlDef.urls;
+    let stu = wx.getStorageSync('student');
+    if (stu) {
+      this.setData({ curStu: stu })
+      let url = urls.person_video_list;
+      let params = { 'q.personType': this.data.personType, 'q.orgId': stu.orgId, 'q.doPersonId': stu.studentId };
+      if (this.data.index == 0) {
+        params['q.sortBy'] = 'goodCount'// 最热 按点赞量来
+      } else if (this.data.index == 1) {
+        params['q.sortBy'] = 'createDate'
+      } else if (this.data.index == 2) {
+        params['q.goodPersonId'] = stu.studentId
+      } else if (this.data.index == 3) {
+        params['q.personId'] = stu.studentId
+      }
+
+      params.pageNum = this.data.pageNum
+      util.apiPost(url, params).then(rs => {
+        let list = rs.list
+        this.setData({
+          'hasNextPage': rs.hasNextPage,
+          'loading': rs.hasNextPage ? '下拉刷新' : '没有更多数据',
+          'list': this.data.list.concat(list)
+        })
+
+        let that = this;
+        list.map(v => {
+          util.apiPost(urls.video_loadInfo + v.videoId).then((rs) => {
+            v.imgUrl = rs.img
+            v.playUrl = rs.url
+            that.reloadVideos(v)
+          })
+        })
+      })
+    }
+  },
+  reloadVideos: function (v) {
+    this.data.list.map(o => {
+      if (o.videoId == v.videoId) {
+        o = v
+      }
+    })
+    this.setData({ list: this.data.list })
+  },
+  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 => {
+      this.data.list.map(o => {
+        if (o.videoId == vid) {
+          o.goodCount += 1
+        }
+      })
+      this.setData({
+        'list': this.data.list
+      })
+    }).catch(e => {
+      console.log(e);
+    })
   }
 })

+ 2 - 2
pages/showVideoList/showVideoList.wxml

@@ -1,12 +1,12 @@
 <view class="container">
 
 <!-- 顶部切换标题 -->
-  <switchTab arr="{{switchTitle}}"></switchTab>
+  <switchTab arr="{{switchTitle}}" bind:changeIndex="selectIndex"></switchTab>
   <!-- end -->
 
   <!-- 视频列表 -->
   <view class="show-view">
-    <showList list="{{list}}"></showList>
+    <showList list="{{list}}" bind:callThumbsUp="doThumbsUp"></showList>
   </view>
   <!-- end -->
 

+ 1 - 2
pages/task/task.js

@@ -50,14 +50,13 @@ Page({
   onLoad: function (options) {
     let bd = options.beginDate
     let ed = options.endDate
-    bd = '2020-01-01'
-    ed = '2021-03-01'
     if (bd && ed) {
       this.setData({ 'beginDate': bd, 'endDate': ed })
     } else {
       let today = util.curTime().substring(0, 10).replace(/\//g, '-')
       this.setData({ 'beginDate': today.substring(0, 8) + '01', 'endDate': today })
     }
+    
   },
 
   /**

+ 1 - 1
pages/task/task.wxml

@@ -1,7 +1,7 @@
 <view class="container">
 
   <!-- 时间筛选 -->
-  <selectDate bind:getDates="getDates"></selectDate>
+  <selectDate bind:getDates="getDates" beginDate="{{beginDate}}" endDate="{{endDate}}"></selectDate>
   <!-- end -->
   
   <!-- 顶部切换标题 -->