index.js 7.5 KB

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