evaluationDetail.js 5.2 KB

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