index.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. const app1 = getApp();
  2. const app = require('../../utils/util.js');
  3. Page({
  4. data: {
  5. wqdataArr: 0,
  6. jjdataArr: 0,
  7. // kjShow: true,
  8. // 课程轮播
  9. "bnrUrl": [],
  10. gridArr: [{
  11. "url": "/images/icon1.png",
  12. "name": "在线直播",
  13. }, {
  14. "url": "/images/icon2.png",
  15. "name": "在线录播",
  16. }, {
  17. "url": "/images/icon3.png",
  18. "name": "互动答疑",
  19. }, {
  20. "url": "/images/icon4.png",
  21. "name": "测试答卷",
  22. }],
  23. xczsArr: []
  24. },
  25. gomyClass(e) {
  26. console.log(e.currentTarget.dataset.item.isActive, "我是测试跳转的")
  27. if (e.currentTarget.dataset.item.isActive == 5) {
  28. wx.switchTab({
  29. url: '/pages/myClass/myClass',
  30. })
  31. }
  32. },
  33. // 即将开班
  34. gostartClass(e) {
  35. if (e.currentTarget.dataset.item !== 0) {
  36. wx.navigateTo({
  37. url: '/pages/startClass/startClass',
  38. })
  39. } else {
  40. wx.showModal({
  41. showCancel: false,
  42. content: "您还没有即将开班哦",
  43. success(res) {
  44. if (res.confirm) {
  45. wx.switchTab({
  46. url: '../index/index'
  47. })
  48. }
  49. }
  50. })
  51. }
  52. },
  53. goagoClass(e) {
  54. if (e.currentTarget.dataset.item !== 0) {
  55. wx.navigateTo({
  56. url: '/pages/agoClass/agoClass',
  57. })
  58. } else {
  59. wx.showModal({
  60. showCancel: false,
  61. content: "您还没有往期开班哦",
  62. success(res) {
  63. if (res.confirm) {
  64. wx.switchTab({
  65. url: '../index/index'
  66. })
  67. }
  68. }
  69. })
  70. }
  71. },
  72. // 宣传展示查看更多
  73. xczsMore() {
  74. wx.navigateTo({
  75. url: '/pages/exhibitionList/exhibitionList?id=0',
  76. })
  77. },
  78. // 每个宣传展示跳转详情页
  79. turnDetails(e) {
  80. var num = e.currentTarget.id;
  81. wx.navigateTo({
  82. url: '/pages/exhibitionList/exhibitionList?id=' + num,
  83. })
  84. },
  85. // 首页的四个点击
  86. goGrid(e) {
  87. // console.log(e)
  88. if (e.currentTarget.dataset.id == 0) {
  89. wx.navigateTo({
  90. url: '/pages/onlineClass/onlineClass',
  91. })
  92. } else if (e.currentTarget.dataset.id == 1) {
  93. wx.navigateTo({
  94. url: '/pages/demandCourses/demandCourses',
  95. })
  96. } else if (e.currentTarget.dataset.id == 2) {
  97. wx.navigateTo({
  98. url: '/pages/myInteractions/myInteractions',
  99. })
  100. } else if (e.currentTarget.dataset.id == 3) {
  101. wx.navigateTo({
  102. url: '/pages/testAnswer/testAnswer',
  103. })
  104. }
  105. },
  106. // banner图
  107. getBanner(sessionKey) {
  108. var _this = this;
  109. wx.request({
  110. url: app.globalData.publicUrl2 + '/wx/student/selAllClas',
  111. method: "post",
  112. data: {
  113. sessionKey: sessionKey
  114. },
  115. success: function (res) {
  116. _this.setData({
  117. bnrUrl: res.data.data.claList
  118. })
  119. }
  120. })
  121. },
  122. // 即将开班
  123. getjjLength(sessionKey) {
  124. var _this = this;
  125. wx.request({
  126. url: app.globalData.publicUrl2 + '/wx/student/selClasToo',
  127. method: "post",
  128. data: {
  129. sessionKey: sessionKey,
  130. isActive: "0"
  131. },
  132. success: function (res) {
  133. // console.log(res.data.data.length, "我是即将开班的列表")
  134. if (res.data.data)
  135. _this.setData({
  136. jjdataArr: res.data.data.length
  137. })
  138. }
  139. })
  140. },
  141. // 往期开班
  142. getwqLength(sessionKey) {
  143. var _this = this;
  144. wx.request({
  145. url: app.globalData.publicUrl2 + '/wx/student/selClasToo',
  146. method: "post",
  147. data: {
  148. sessionKey: sessionKey,
  149. isActive: "2"
  150. },
  151. success: function (res) {
  152. // console.log(res, "我是往期开班的列表")
  153. if (res.data.data)
  154. _this.setData({
  155. wqdataArr: res.data.data.length
  156. })
  157. }
  158. })
  159. },
  160. // 四个宣传图
  161. getfour() {
  162. console.log("调取公开课")
  163. var _this = this;
  164. wx.request({
  165. url: app.globalData.publicUrl + '/wx/course/listCategory',
  166. method: "post",
  167. success: function (res) {
  168. console.log(res.data.list)
  169. _this.setData({
  170. xczsArr: res.data.list
  171. })
  172. },
  173. fail(res) {
  174. console.log(res, "调取请求公开课失败")
  175. }
  176. })
  177. },
  178. onReady: function () {},
  179. // onLoad() {
  180. // let _this = this;
  181. // console.log(app1.globalData.showAnimation)
  182. // if (app1.globalData.showAnimation == true) {
  183. // setTimeout(function () {
  184. // _this.setData({
  185. // kjShow: false,
  186. // })
  187. // }, 4000)
  188. // }
  189. // },
  190. // onUnload: function () {
  191. // app1.globalData.showAnimation = false;
  192. // console.log(app1.globalData.showAnimation,"false")
  193. // },
  194. // onHide: function () {
  195. // app1.globalData.showAnimation = false;
  196. // console.log(app1.globalData.showAnimation,"false")
  197. // },
  198. onShow: function () {
  199. var _this = this;
  200. wx.checkSession({
  201. success: () => {
  202. console.log("我有缓存")
  203. var sessionKey = wx.getStorageSync('sessionKey');
  204. if (sessionKey == "") {
  205. wx.login({
  206. success(res) {
  207. console.log(res);
  208. var code = res.code
  209. wx.request({
  210. url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  211. method: "get",
  212. data: {
  213. code
  214. },
  215. success: function (res) {
  216. sessionKey = res.data.sessionKey;
  217. wx.setStorageSync('sessionKey', res.data.sessionKey);
  218. _this.getBanner(sessionKey);
  219. _this.getjjLength(sessionKey);
  220. _this.getwqLength(sessionKey);
  221. _this.getfour();
  222. }
  223. })
  224. }
  225. })
  226. } else {
  227. _this.getBanner(sessionKey);
  228. _this.getjjLength(sessionKey);
  229. _this.getwqLength(sessionKey);
  230. _this.getfour();
  231. }
  232. },
  233. fail() {
  234. console.log("我没有缓存并去登录请求")
  235. wx.login({
  236. success(res) {
  237. console.log(res);
  238. var code = res.code
  239. wx.request({
  240. url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  241. method: "get",
  242. data: {
  243. code
  244. },
  245. success: function (res) {
  246. wx.setStorageSync('sessionKey', res.data.sessionKey);
  247. var sessionKey = res.data.sessionKey
  248. _this.getBanner(sessionKey);
  249. _this.getjjLength(sessionKey);
  250. _this.getwqLength(sessionKey);
  251. _this.getfour();
  252. }
  253. })
  254. }
  255. })
  256. }
  257. })
  258. }
  259. })