|
@@ -1,48 +1,104 @@
|
|
|
// pages/growUp/growUp.js
|
|
|
+const app = getApp()
|
|
|
+const util = require("../../utils/util")
|
|
|
+const urlDef = require("../../utils/urls")
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- src:'http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400',
|
|
|
- list:[
|
|
|
- {
|
|
|
- time: '2021-02-01 11:11',
|
|
|
- name: '报名课程:小象钢琴 1',
|
|
|
- desc: '来自我的足迹',
|
|
|
- },
|
|
|
- {
|
|
|
- time: '2021-02-02 11:11',
|
|
|
- name: '报名课程:小象钢琴 2',
|
|
|
- desc: '来自我的足迹',
|
|
|
- },
|
|
|
- {
|
|
|
- time: '2021-02-03 11:11',
|
|
|
- name: '发布新动态',
|
|
|
- desc: '来自我的足迹',
|
|
|
- type: '2'
|
|
|
- },
|
|
|
- {
|
|
|
- time: '2021-02-04 11:11',
|
|
|
- name: '取得新成绩:二月调考 88 分',
|
|
|
- desc: '来自我的足迹',
|
|
|
- type: '1'
|
|
|
- },
|
|
|
- {
|
|
|
- time: '2021-02-05 11:11',
|
|
|
- name: '报名课程:小象钢琴 3',
|
|
|
- desc: '来自我的足迹',
|
|
|
- },
|
|
|
- ]
|
|
|
- },
|
|
|
-
|
|
|
- getImg:function(e){
|
|
|
- // const list = [e.currentTarget.dataset.url]
|
|
|
- const list = ['https://file.schoolwisdoms.com/image/26cf1980-5b25-4c2e-af7f-376677d76033.jpg']
|
|
|
+ studentId: null,
|
|
|
+ orgId: null,
|
|
|
+ curVideo: '',
|
|
|
+ videoFlag: 0,
|
|
|
+ videoContext: '',
|
|
|
+ curAudio: '',
|
|
|
+ curAudioIndex: -1,
|
|
|
+ audioPause: 0,
|
|
|
+ list: [
|
|
|
+ ],
|
|
|
+ loading: '上拉加载',
|
|
|
+ flag: 0,
|
|
|
+ pageNum: 0,
|
|
|
+ hasNextPage: true,
|
|
|
+ },
|
|
|
+
|
|
|
+ bindfullscreenchange: function () {
|
|
|
+ if (this.data.videoFlag == 0) {
|
|
|
+ this.setData({
|
|
|
+ videoFlag: 1
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ videoFlag: 0,
|
|
|
+ curVideo: ""
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ videoShow: function (e) {
|
|
|
+ this.setData({
|
|
|
+ curVideo: e.currentTarget.dataset.url
|
|
|
+ })
|
|
|
+ this.videoContext.requestFullScreen({ // 设置全屏时视频的方向,不指定则根据宽高比自动判断。
|
|
|
+ direction: 90 // 屏幕逆时针90度
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ showImg: function (e) {
|
|
|
+ let id = e.currentTarget.dataset.id
|
|
|
+ var images = [];
|
|
|
+ this.data.list.map(it => {
|
|
|
+ if (it.id == id) {
|
|
|
+ let imgs = it.images
|
|
|
+ imgs.map(i => {
|
|
|
+ images.push(i.url)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
wx.previewImage({
|
|
|
- current: list[0],
|
|
|
- urls: list,
|
|
|
+ urls: images
|
|
|
+ })
|
|
|
+ },
|
|
|
+ audioShow: function (e) {
|
|
|
+ if (this.data.audioPause == 0 && this.data.curAudioIndex != e.currentTarget.dataset.index) {//播放语音,切换
|
|
|
+ this.setData({
|
|
|
+ curAudio: ""
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ curAudioIndex: e.currentTarget.dataset.index,
|
|
|
+ curAudio: e.currentTarget.dataset.url,
|
|
|
+
|
|
|
+ })
|
|
|
+ this.audioContext.play()
|
|
|
+ this.setData({
|
|
|
+ audioPause: 0
|
|
|
+ })
|
|
|
+ } else if (this.data.audioPause == 1 && this.data.curAudioIndex == e.currentTarget.dataset.index) {//暂停后恢复播放
|
|
|
+ this.audioContext.play()
|
|
|
+ this.setData({
|
|
|
+ audioPause: 0
|
|
|
+ })
|
|
|
+ } else if (this.data.audioPause == 0 && this.data.curAudioIndex == e.currentTarget.dataset.index) {//暂停播放
|
|
|
+ this.audioContext.pause()
|
|
|
+ this.setData({
|
|
|
+ audioPause: 1
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ bindended: function () {
|
|
|
+ this.setData({
|
|
|
+ audioPause: 0,
|
|
|
+ curAudioIndex: -1,
|
|
|
+ curAudio: ''
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ bindpause: function () {
|
|
|
+ this.setData({
|
|
|
+ audioPause: 1
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -50,7 +106,17 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
-
|
|
|
+ let sid = options.studentId
|
|
|
+ let oid = options.orgId
|
|
|
+ if (sid == null || oid == null) {
|
|
|
+ let stu = wx.getStorageSync('student')
|
|
|
+ sid = stu.studentId
|
|
|
+ oid = stu.orgId
|
|
|
+ }
|
|
|
+ this.audioContext = wx.createAudioContext('audio-play')
|
|
|
+ this.videoContext = wx.createVideoContext('play-video');// 创建 video 上下文 VideoContext 对象。
|
|
|
+ this.setData({ studentId: sid, orgId: oid })
|
|
|
+ this.queryList()
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -92,13 +158,97 @@ Page({
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
-
|
|
|
+ if (this.data.hasNextPage) {
|
|
|
+ let pn = this.data.pageNum
|
|
|
+ this.setData({ loading: '加载中', 'pageNum': ++pn })
|
|
|
+ this.queryList()
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function () {
|
|
|
-
|
|
|
+ return {
|
|
|
+ title: '成长足迹',
|
|
|
+ path: '/pages/growUp/growUp?studentId=' + this.data.studentId + '&orgId=' + this.data.orgId,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ queryList: function () {
|
|
|
+ const urls = urlDef.urls;
|
|
|
+ let params = { 'q.studentId': this.data.studentId, 'q.orgId': this.data.orgId }
|
|
|
+ params.pageNum = this.data.pageNum
|
|
|
+ util.apiPost(urls.query_student_evaluate, params).then(rs => {
|
|
|
+ let list = rs.list
|
|
|
+ list.map(it => {
|
|
|
+ if (it.beginTime) {
|
|
|
+ it.beginTime = it.beginTime.replace('T', ' ').substring(0, 16)
|
|
|
+ }
|
|
|
+ if (it.type === '1') {
|
|
|
+ util.apiPost(urls.query_student_star + '&q.orgId=' + this.data.orgId + '&q.studentId='
|
|
|
+ + this.data.studentId + '&q.headId=' + it.id).then((st) => {
|
|
|
+ it.star = st;
|
|
|
+ }, e => {
|
|
|
+ console.log(e);
|
|
|
+ });
|
|
|
+
|
|
|
+ let attachs;
|
|
|
+ try {
|
|
|
+ if (it.evaluateAttach) {
|
|
|
+ attachs = JSON.parse(it.evaluateAttach);
|
|
|
+ } else {
|
|
|
+ attachs = {};
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error(JSON.stringify(e));
|
|
|
+ }
|
|
|
+ if (attachs) {
|
|
|
+ it.images = attachs.images ? attachs.images : [];
|
|
|
+ it.videos = attachs.videos ? attachs.videos : [];
|
|
|
+ it.records = attachs.records ? attachs.records : [];
|
|
|
+
|
|
|
+ it.images.forEach(rs => {
|
|
|
+ rs.url = urls.oss_file + 'image/' + rs.url
|
|
|
+ });
|
|
|
+
|
|
|
+ it.records.forEach(rs => {
|
|
|
+ rs.url = urls.oss_file + 'file/' + rs.url
|
|
|
+ });
|
|
|
+
|
|
|
+ // 加载视频封面
|
|
|
+ it.videos.forEach(r => {
|
|
|
+ util.apiPost(urls.video_loadInfo + r.url).then((rs) => {
|
|
|
+ r.imgUrl = rs.img;
|
|
|
+ r.playUrl = rs.url;
|
|
|
+ this.reloadVideos(it)
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if (it.type === '4') {
|
|
|
+ util.apiPost(urls.video_loadInfo + it.evaluateAttach).then((rs) => {
|
|
|
+ it.imgUrl = rs.img;
|
|
|
+ it.playUrl = rs.url;
|
|
|
+ this.reloadVideos(it)
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ 'hasNextPage': rs.hasNextPage,
|
|
|
+ 'loading': rs.hasNextPage ? '下拉刷新' : '没有更多数据',
|
|
|
+ 'list': this.data.list.concat(list)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ reloadVideos: function (t) {
|
|
|
+ let list = this.data.list;
|
|
|
+ list.map(it => {
|
|
|
+ if (it.id == t.id) {
|
|
|
+ it = t;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.setData({ list: list })
|
|
|
}
|
|
|
})
|