historyClass.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. const app = require('../../utils/util.js');
  2. const tools = require('../../utils/tools.js');
  3. Page({
  4. data: {
  5. kcArr: [],
  6. showZhfk: true,
  7. istask: false
  8. },
  9. // 跳转直播点播页面
  10. goStudy(e) {
  11. console.log(e.currentTarget.dataset.item)
  12. let id = e.currentTarget.dataset.item.id
  13. let courseName = e.currentTarget.dataset.item.courseName
  14. let courseUrl = e.currentTarget.dataset.item.courseUrl
  15. let courseInfo = e.currentTarget.dataset.item.courseInfo
  16. console.log(id)
  17. if (e.currentTarget.dataset.item.isLive == 1) {
  18. if (e.currentTarget.dataset.item.isActive == 1) {
  19. wx.navigateTo({
  20. url: '../zbDetails/zbDetails?id=' + id
  21. })
  22. } else if (e.currentTarget.dataset.item.isActive == -1) {
  23. if (courseUrl == null || courseUrl == "") {
  24. wx.showModal({
  25. showCancel: false,
  26. content: "直播回放还未上传噢"
  27. })
  28. } else {
  29. wx.navigateTo({
  30. url: '../livePlayback/livePlayback?courseName=' + courseName + '&courseUrl=' + courseUrl + '&courseInfo=' + courseInfo
  31. })
  32. }
  33. } else {
  34. wx.showModal({
  35. showCancel: false,
  36. content: "直播还未开始哦"
  37. })
  38. return false;
  39. }
  40. } else {
  41. wx.navigateTo({
  42. url: '../videoPlayBack/videoPlayBack?id=' + id + '&courseUrl=' + courseUrl + '&courseInfo=' + courseInfo + '&courseName=' + courseName
  43. })
  44. }
  45. },
  46. // 获取列表
  47. getArr(sessionKey) {
  48. wx.request({
  49. url: app.globalData.publicUrl + '/wx/course/selectByClasId',
  50. method: "post",
  51. data: {
  52. sessionKey,
  53. clasId: this.data.id
  54. },
  55. success: (res) => {
  56. this.setData({
  57. kcArr: res.data.list
  58. });
  59. let result = [];
  60. if (res.data.list)
  61. for (let i = 0; i < res.data.list.length; i++) {
  62. result.push({
  63. courseTime: res.data.list[i].courseTime
  64. });
  65. }
  66. const timesArr = result.map((item) => {
  67. return item.courseTime;
  68. });
  69. let sfmArr = [];
  70. for (let i = 0; i < timesArr.length; i++) {
  71. let value = timesArr[i];
  72. const resultValue = this.handler(value);
  73. sfmArr.push({
  74. courseTime: resultValue
  75. })
  76. this.setData({
  77. sfmArr: sfmArr
  78. })
  79. }
  80. }
  81. })
  82. },
  83. // 处理时间
  84. handler(value) {
  85. //换算为秒 进制1000
  86. const second = Math.floor(value / 1000); //判断是否够1秒
  87. if (second < 1) {
  88. return "0秒";
  89. }
  90. const secondValue = second % 60; // 秒
  91. const minutes = Math.floor(second / 60); //判断是否够1分钟
  92. if (minutes < 1) {
  93. return `${secondValue}秒`;
  94. }
  95. const minutesValue = minutes % 60; //分
  96. const hours = Math.floor(minutes / 60); //判断是否够1小时
  97. if (hours < 1) {
  98. return `${minutesValue}分${secondValue}秒`;
  99. }
  100. const hoursValue = hours % 60; //小时
  101. return `${hoursValue}时${minutesValue}分${secondValue}秒`;
  102. },
  103. // 检查综合反馈是否填写完
  104. checkTaskList(sessionKey) {
  105. wx.request({
  106. url: app.globalData.publicUrl + '/wx/exam/status',
  107. method: "post",
  108. data: {
  109. sessionKey: sessionKey,
  110. clasId: this.data.id
  111. },
  112. success: (res) => {
  113. if (res.data.code == 0 && res.data.status == 1) {
  114. this.setData({
  115. istask: true
  116. })
  117. }
  118. }
  119. })
  120. },
  121. // 历史班综合反馈填写
  122. goWrite2() {
  123. if (this.data.istask) {
  124. wx.request({
  125. url: app.globalData.publicUrl + '/wx/exam/quesExamList',
  126. method: "post",
  127. data: {
  128. sessionKey: this.data.sessionKey,
  129. questSub: '1',
  130. clasId: this.data.id
  131. },
  132. success: (res) => {
  133. if (res.data.code == 0) {
  134. if (res.data.list[0]) {
  135. if (res.data.list[0].answersId) {
  136. wx.navigateTo({
  137. url: '/pages/feedBackDetail/feedBackDetail?answersId=' + res.data.list[0].answersId,
  138. })
  139. } else {
  140. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'feedBack');
  141. }
  142. }
  143. }
  144. }
  145. })
  146. } else {
  147. wx.request({
  148. url: app.globalData.publicUrl + '/wx/exam/quesExamList',
  149. method: "post",
  150. data: {
  151. sessionKey: this.data.sessionKey,
  152. questSub: '1',
  153. clasId: this.data.id
  154. },
  155. success: (res) => {
  156. if (res.data.code == 0) {
  157. if (res.data.list.length == 0) {
  158. wx.showModal({
  159. showCancel: false,
  160. content: '当前综合反馈还不可以填写哦!'
  161. })
  162. } else {
  163. if (res.data.list[0].answersId) {
  164. if (res.data.list[0].status == '1') {
  165. wx.navigateTo({
  166. url: '/pages/feedBackDetail/feedBackDetail?answersId=' + res.data.list[0].answersId,
  167. })
  168. } else {
  169. this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'feedBack');
  170. }
  171. } else {
  172. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'feedBack');
  173. }
  174. }
  175. }
  176. }
  177. })
  178. }
  179. },
  180. toPath(id, paperId, answersId, address, status) {
  181. wx.navigateTo({
  182. url: '/pages/' + address + '/' + address + '?id=' + id + '&paperId=' + paperId + '&answersId=' + answersId + '&status=' + status,
  183. })
  184. },
  185. beginKao(id, paperId, sessionKey, address) {
  186. wx.request({
  187. url: app.globalData.publicUrl + '/wx/exam/begin',
  188. method: "post",
  189. data: {
  190. sessionKey: sessionKey,
  191. id: id,
  192. paperId: paperId
  193. },
  194. success: (res) => {
  195. if (res.data.code == 0) {
  196. this.setData({
  197. status: res.data.status
  198. })
  199. this.toPath(id, paperId, res.data.answersId, address, );
  200. }
  201. }
  202. })
  203. },
  204. async onLoad(options) {
  205. const sessionKey = await tools.checkSessionAndLogin();
  206. this.setData({
  207. sessionKey: sessionKey,
  208. id: options.id,
  209. name: options.name,
  210. clasEnd: options.clasEnd
  211. })
  212. this.getArr(sessionKey);
  213. this.checkTaskList(sessionKey)
  214. let currrentTime = new Date().getTime()
  215. let endTime = new Date(this.data.clasEnd).getTime()
  216. let day = Math.floor((currrentTime - endTime) / 86400000);
  217. if (day > 7) {
  218. this.setData({
  219. showZhfk: false
  220. })
  221. }
  222. }
  223. })