demandCourses.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const app = require('../../utils/util.js');
  2. Page({
  3. data: {
  4. lbArr: []
  5. },
  6. goIn(e) {
  7. var id = e.currentTarget.dataset.item.id
  8. wx.navigateTo({
  9. url: '../dbDetails/dbDetails?id=' + id
  10. })
  11. },
  12. getArr(sessionKey) {
  13. var _this = this;
  14. wx.request({
  15. url: app.globalData.publicUrl + '/wx/course/selectRecordBySessionKey',
  16. method: "post",
  17. data:{
  18. sessionKey:sessionKey
  19. },
  20. success: function (res) {
  21. console.log(res)
  22. _this.setData({
  23. lbArr: res.data.list
  24. })
  25. }
  26. })
  27. },
  28. onLoad: function () {
  29. var sessionKey = "";
  30. var _this = this;
  31. wx.checkSession({
  32. success: () => {
  33. sessionKey = wx.getStorageSync('sessionKey');
  34. _this.getArr(sessionKey)
  35. },
  36. fail() {
  37. console.log("我没有缓存并去登录请求")
  38. wx.login({
  39. success(res) {
  40. console.log(res);
  41. var code = res.code
  42. wx.request({
  43. url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  44. method: "get",
  45. data: {
  46. code
  47. },
  48. success: function (res) {
  49. sessionKey = res.data.sessionKey;
  50. wx.setStorageSync('sessionKey', res.data.sessionKey);
  51. _this.getArr(sessionKey)
  52. }
  53. })
  54. }
  55. })
  56. }
  57. })
  58. }
  59. })