historyClass.js 6.4 KB

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