evaluationDetail.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. // pages/evaluationDetail/evaluationDetail.js
  2. const app = getApp()
  3. const util = require("../../utils/util")
  4. const urlDef = require("../../utils/urls")
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. tipList: [
  11. '人均:该学生在本班历次得分的平均值\r\n',
  12. '班平:该班级内多有学生得分的平均值\r\n',
  13. '满星:第一个数是该学生在本班级得满分的次数,第二个数是已评分的次数\r\n',
  14. ],
  15. curVideo: '',
  16. videoFlag: 0,
  17. videoContext: '',
  18. curAudio: '',
  19. curAudioIndex: -1,
  20. audioPause: 0,
  21. item: null
  22. },
  23. getTip: function () {
  24. var str = ''
  25. for (var i in this.data.tipList) {
  26. str += this.data.tipList[i]
  27. }
  28. wx.showModal({
  29. title: '调课说明',
  30. content: str,
  31. showCancel: false,//是否显示取消按钮
  32. cancelText: "否",//默认是“取消”
  33. cancelColor: '#999999',//取消文字的颜色
  34. confirmText: "我知道了",//默认是“确定”
  35. confirmColor: 'skyblue',//确定文字的颜色
  36. })
  37. },
  38. bindfullscreenchange: function () {
  39. if (this.data.videoFlag == 0) {
  40. this.setData({
  41. videoFlag: 1
  42. })
  43. } else {
  44. this.setData({
  45. videoFlag: 0,
  46. curVideo: ""
  47. })
  48. }
  49. },
  50. videoShow: function (e) {
  51. this.setData({
  52. curVideo: e.currentTarget.dataset.url
  53. })
  54. this.videoContext.requestFullScreen({ // 设置全屏时视频的方向,不指定则根据宽高比自动判断。
  55. direction: 90 // 屏幕逆时针90度
  56. });
  57. },
  58. showImg: function (e) {
  59. // var list = e.currentTarget.dataset.url
  60. wx.previewImage({
  61. urls: this.data.imgList,
  62. })
  63. },
  64. audioShow: function (e) {
  65. if (this.data.audioPause == 0 && this.data.curAudioIndex != e.currentTarget.dataset.index) {//播放语音,切换
  66. this.setData({
  67. curAudio: ""
  68. })
  69. this.setData({
  70. curAudioIndex: e.currentTarget.dataset.index,
  71. curAudio: e.currentTarget.dataset.url,
  72. })
  73. this.audioContext.play()
  74. this.setData({
  75. audioPause: 0
  76. })
  77. } else if (this.data.audioPause == 1 && this.data.curAudioIndex == e.currentTarget.dataset.index) {//暂停后恢复播放
  78. this.audioContext.play()
  79. this.setData({
  80. audioPause: 0
  81. })
  82. } else if (this.data.audioPause == 0 && this.data.curAudioIndex == e.currentTarget.dataset.index) {//暂停播放
  83. this.audioContext.pause()
  84. this.setData({
  85. audioPause: 1
  86. })
  87. }
  88. },
  89. bindended: function () {
  90. this.setData({
  91. audioPause: 0,
  92. curAudioIndex: -1,
  93. curAudio: ''
  94. })
  95. },
  96. bindpause: function () {
  97. this.setData({
  98. audioPause: 1
  99. })
  100. },
  101. /**
  102. * 生命周期函数--监听页面加载
  103. */
  104. onLoad: function (options) {
  105. this.audioContext = wx.createAudioContext('audio-play')
  106. this.videoContext = wx.createVideoContext('play-video');// 创建 video 上下文 VideoContext 对象。
  107. const urls = urlDef.urls;
  108. let it = JSON.parse(options.item)
  109. if (it.imageUrl) {
  110. it.imageUrl = urls.oss_file + 'image/' + it.imageUrl
  111. } else {
  112. it.imageUrl = "/images/head.png"
  113. }
  114. let attachs;
  115. try {
  116. if (it.evaluateAttach) {
  117. attachs = JSON.parse(it.evaluateAttach);
  118. } else {
  119. attachs = {};
  120. }
  121. } catch (e) {
  122. console.error(JSON.stringify(e));
  123. }
  124. let stu = wx.getStorageSync('student')
  125. util.apiPost(urls.query_student_star + '&q.orgId=' + stu.orgId + '&q.studentId='
  126. + stu.studentId + '&q.headId=' + it.id).then((st) => {
  127. it.stars = st;
  128. this.reloadItems(it)
  129. }, e => {
  130. console.log(e);
  131. });
  132. if (attachs) {
  133. it.images = attachs.images ? attachs.images : [];
  134. it.videos = attachs.videos ? attachs.videos : [];
  135. it.records = attachs.records ? attachs.records : [];
  136. it.images.forEach(rs => {
  137. rs.url = urls.oss_file + 'image/' + rs.url
  138. });
  139. it.records.forEach(rs => {
  140. rs.url = urls.oss_file + 'file/' + rs.url
  141. });
  142. // 加载视频封面
  143. it.videos.forEach(r => {
  144. util.apiPost(urls.video_loadInfo + r.url).then((rs) => {
  145. r.imgUrl = rs.img;
  146. r.playUrl = rs.url;
  147. this.reloadItems(it)
  148. });
  149. });
  150. this.setData({ item: it })
  151. }
  152. },
  153. /**
  154. * 生命周期函数--监听页面初次渲染完成
  155. */
  156. onReady: function () {
  157. },
  158. /**
  159. * 生命周期函数--监听页面显示
  160. */
  161. onShow: function () {
  162. },
  163. /**
  164. * 生命周期函数--监听页面隐藏
  165. */
  166. onHide: function () {
  167. },
  168. /**
  169. * 生命周期函数--监听页面卸载
  170. */
  171. onUnload: function () {
  172. },
  173. /**
  174. * 页面相关事件处理函数--监听用户下拉动作
  175. */
  176. onPullDownRefresh: function () {
  177. },
  178. /**
  179. * 页面上拉触底事件的处理函数
  180. */
  181. onReachBottom: function () {
  182. },
  183. /**
  184. * 用户点击右上角分享
  185. */
  186. onShareAppMessage: function () {
  187. },
  188. reloadItems: function (it) {
  189. this.setData({ item: it })
  190. },
  191. showImg: function (e) {
  192. var images = [];
  193. this.data.item.images.map(it => {
  194. images.push(it.url)
  195. })
  196. let url = e.currentTarget.dataset.url;
  197. console.log(url)
  198. wx.previewImage({
  199. urls: images,
  200. current: url
  201. })
  202. }
  203. })