index.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. const app = require('../../utils/util.js');
  2. const tools = require('../../utils/tools.js');
  3. Page({
  4. data: {
  5. wqdataArr: 0,
  6. jjdataArr: 0,
  7. isNeedlogin: false,
  8. // 课程轮播
  9. bnrUrl: [{
  10. clasImg: app.globalData.imgUrl+"/images/zbfm.png"
  11. }],
  12. gridArr: [{
  13. url: "/images/icon1.png",
  14. name: "在线直播",
  15. isread: true
  16. }, {
  17. url: "/images/icon2.png",
  18. name: "在线录播",
  19. isread: true
  20. }, {
  21. url: "/images/icon3.png",
  22. name: "互动答疑",
  23. isread: true
  24. }, {
  25. url: "/images/icon4.png",
  26. name: "测试答卷",
  27. isread: true
  28. }],
  29. xczsArr: [],
  30. goGridArr: [
  31. '/pages/onlineClass/onlineClass',
  32. '/pages/demandCourses/demandCourses',
  33. '/pages/myInteractions/myInteractions',
  34. '/pages/testAnswer/testAnswer'
  35. ],
  36. active: 0,
  37. xcpArr: [],
  38. wdArr:[],
  39. notice:"",
  40. noticeVis:false,
  41. vType:["理论阵地","我的学院","特色课程","特色管理"],
  42. index_tf:[
  43. {title:"在线直播",img:app.globalData.imgUrl+"/images/index_icon_video.png",to:"/pages/onlineClass/onlineClass",isread: true},
  44. {title:"在线录播",img:app.globalData.imgUrl+"/images/index_icon_rec.png",to:"/pages/demandCourses/demandCourses",isread: true},
  45. {title:"互动答疑",img:app.globalData.imgUrl+"/images/index_icon_dialog.png",to:"/pages/myInteractions/myInteractions",isread: true},
  46. {title:"测试答卷",img:app.globalData.imgUrl+"/images/index_icon_test.png",to:"/pages/testAnswer/testAnswer",isread: true},
  47. ]
  48. },
  49. // 轮播点击去上课跳转到我的班级
  50. gomyClass(e) {
  51. if (e.currentTarget.dataset.item.isActive == 5) {
  52. wx.switchTab({
  53. url: '/pages/myClass/myClass',
  54. })
  55. }
  56. },
  57. // 即将开班
  58. gostartClass(e) {
  59. if (e.currentTarget.dataset.item !== 0) {
  60. wx.navigateTo({
  61. url: '/pages/startClass/startClass',
  62. })
  63. } else {
  64. wx.showModal({
  65. showCancel: false,
  66. content: "您还没有即将开班哦",
  67. success(res) {
  68. if (res.confirm) {
  69. wx.switchTab({
  70. url: '../index/index'
  71. })
  72. }
  73. }
  74. })
  75. }
  76. },
  77. // 往期开班
  78. goagoClass(e) {
  79. if (e.currentTarget.dataset.item !== 0) {
  80. wx.navigateTo({
  81. url: '/pages/agoClass/agoClass',
  82. })
  83. } else {
  84. wx.showModal({
  85. showCancel: false,
  86. content: "您还没有往期开班哦",
  87. success(res) {
  88. if (res.confirm) {
  89. wx.switchTab({
  90. url: '../index/index'
  91. })
  92. }
  93. }
  94. })
  95. }
  96. },
  97. // 宣传展示查看更多
  98. xczsMore() {
  99. wx.navigateTo({
  100. url: '/pages/exhibitionList/exhibitionList?id=0',
  101. })
  102. },
  103. // 每个宣传展示跳转详情页
  104. turnDetails(e) {
  105. let num = e.currentTarget.id;
  106. wx.navigateTo({
  107. url: '/pages/exhibitionList/exhibitionList?id=' + num,
  108. })
  109. },
  110. // 首页的四个点击
  111. goGrid(e) {
  112. wx.navigateTo({
  113. url: this.data.index_tf[e.currentTarget.dataset.id].to
  114. })
  115. },
  116. // banner图
  117. getBanner(sessionKey) {
  118. wx.request({
  119. url: app.globalData.publicUrl + '/wx/student/selAllClas',
  120. method: "post",
  121. data: {
  122. sessionKey
  123. },
  124. success: (res) => {
  125. if (res.data.data && res.data.data.claList.length != 0) {
  126. this.setData({
  127. bnrUrl: res.data.data.claList
  128. })
  129. }
  130. }
  131. })
  132. },
  133. // 即将开班有几个
  134. getjjLength(sessionKey) {
  135. wx.request({
  136. url: app.globalData.publicUrl + '/wx/student/selClasToo',
  137. method: "post",
  138. data: {
  139. sessionKey,
  140. isActive: "0"
  141. },
  142. success: (res) => {
  143. if (res.data.data)
  144. this.setData({
  145. jjdataArr: res.data.data.length
  146. })
  147. }
  148. })
  149. },
  150. // 往期开班有几个
  151. getwqLength(sessionKey) {
  152. wx.request({
  153. url: app.globalData.publicUrl + '/wx/student/selClasToo',
  154. method: "post",
  155. data: {
  156. sessionKey,
  157. isActive: "2"
  158. },
  159. success: (res) => {
  160. if (res.data.data)
  161. this.setData({
  162. wqdataArr: res.data.data.length
  163. })
  164. }
  165. })
  166. },
  167. // 四个宣传图
  168. getfour() {
  169. wx.request({
  170. url: app.globalData.publicUrl + '/wx/course/listCategory',
  171. method: "post",
  172. success: (res) => {
  173. this.setData({
  174. xczsArr: res.data.list
  175. })
  176. }
  177. })
  178. },
  179. // 四个宣传图onshow
  180. getfour1() {
  181. wx.request({
  182. url: app.globalData.publicUrl + '/wx/course/listCategory',
  183. method: "post",
  184. success: (res) => {
  185. if (this.data.xczsArr && this.data.xczsArr.length != 0) {
  186. if (this.data.xczsArr.sort().toString() != res.data.list.sort().toString()) {
  187. this.setData({
  188. xczsArr: res.data.list
  189. })
  190. }
  191. }
  192. }
  193. })
  194. },
  195. // 第一个小红点
  196. getRedPoint1(sessionKey) {
  197. let completeStatus1 = `index_tf[${0}].isread`;
  198. let completeStatus2 = `index_tf[${1}].isread`;
  199. wx.request({
  200. url: app.globalData.publicUrl + '/wx/course/undoneLogo',
  201. method: "post",
  202. data: {
  203. sessionKey
  204. },
  205. success: (res) => {
  206. if (res.data.code == 0 && res.data.isLive == true) {
  207. this.setData({
  208. [completeStatus1]: false
  209. })
  210. }
  211. if (res.data.code == 0 && res.data.isRecord == true) {
  212. this.setData({
  213. [completeStatus2]: false
  214. })
  215. }
  216. }
  217. })
  218. },
  219. // 第四个小红点
  220. getRedPoint4(sessionKey) {
  221. let completeStatus = `index_tf[${3}].isread`;
  222. wx.request({
  223. url: app.globalData.publicUrl + '/wx/exam/list',
  224. method: "post",
  225. data: {
  226. sessionKey,
  227. status: 0
  228. },
  229. success: (res) => {
  230. if (res.data.code == 0 && res.data.list.length > 0) {
  231. this.setData({
  232. [completeStatus]: false
  233. })
  234. } else {
  235. this.setData({
  236. [completeStatus]: true
  237. })
  238. }
  239. }
  240. })
  241. },
  242. goSeevideo(e) {
  243. let id = e.currentTarget.dataset.item.id
  244. wx.navigateTo({
  245. url: '/pages/dbVideo/dbVideo?id=' + id,
  246. })
  247. },
  248. onChange(event) {
  249. let tag = event.detail.name + 1;
  250. this.getVedioList(tag)
  251. },
  252. getVedioList(tag){
  253. var that=this;
  254. wx.request({
  255. method: "POST",
  256. url: app.globalData.publicUrl + '/wx/course/listByCourseTag?tag=' + tag,
  257. success: (e) => {
  258. that.setData({
  259. xcpArr: e.data.list,
  260. })
  261. }
  262. })
  263. },
  264. toNotice(){
  265. var that=this;
  266. wx.setStorage({
  267. data: that.data.noticeArr,
  268. key: 'noticeArr',
  269. success:()=>{
  270. wx.navigateTo({
  271. url: '../myNoticen/myNotice'
  272. })
  273. }
  274. })
  275. },
  276. getNotice(sessionKey){
  277. wx.request({
  278. url: app.globalData.publicUrl + '/wx/eduNoticeSee/afficheLists',
  279. method: "post",
  280. data: {
  281. sessionKey: sessionKey,
  282. //isSee: 1
  283. // isNotice: 0
  284. },
  285. success: (res) => {
  286. console.log(res);
  287. if (res.data.code == 0) {
  288. if (res.data.data.notReadAfficheList.length !== 0) {
  289. this.setData({
  290. noticeVis: true,
  291. noticeArr: res.data,
  292. notice: res.data.data.notReadAfficheList[0].noticeContent
  293. })
  294. } else {
  295. this.setData({
  296. noticeArr: res.data.data,
  297. noticeVis: false,
  298. })
  299. }
  300. } else {
  301. this.setData({
  302. noticeVis: false
  303. })
  304. }
  305. },
  306. fail: () => {
  307. this.setData({
  308. noticeVis: false
  309. })
  310. }
  311. })
  312. },
  313. async onShow() {
  314. const sessionKey = await tools.checkSessionAndLogin();
  315. // this.getBanner(sessionKey);
  316. this.getjjLength(sessionKey);
  317. this.getwqLength(sessionKey);
  318. this.getRedPoint1(sessionKey);
  319. this.getRedPoint4(sessionKey);
  320. this.getNotice(sessionKey);
  321. // this.getfour1();
  322. },
  323. async onLoad() {
  324. //this.getfour();
  325. this.getVedioList(this.data.active+1);
  326. },
  327. })