language.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // pages/art/art.js
  2. const app = getApp()
  3. const util = require('../../utils/util.js');
  4. const APIClient = require('../../utils/APIClient.js');
  5. const login = require('../../utils/loginSchedule.js');
  6. Page({
  7. data: {
  8. flag: false,
  9. questionsData: {},
  10. courseData: {},
  11. num1: 0,
  12. position: '',
  13. questionsdian: '',
  14. list: [],
  15. lessonListHeight: '',
  16. previewHeight: ''
  17. },
  18. /* 区分答疑和分享 */
  19. distinction: function(type, columnId, pageNo, pageSize, success) {
  20. login.getOpenidSessionKey(function(res) {
  21. //console.log(res.data.data.uid);
  22. APIClient.getProductionSchedule({
  23. uid: res.data.data.uid
  24. }, {
  25. "type": type,
  26. "columnId": columnId,
  27. "pageNo": pageNo,
  28. "pageSize": pageSize
  29. }).success(success)
  30. }, function() {
  31. wx.showModal({
  32. title: '提示',
  33. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  34. showCancel: false,
  35. success: function (res) {
  36. if (res.confirm) {
  37. console.log('用户点击确定')
  38. } else if (res.cancel) {
  39. console.log('用户点击取消')
  40. }
  41. }
  42. })
  43. });
  44. },
  45. /*加载更多点击*/
  46. onMyEvent: function(e){
  47. let type = e.currentTarget.dataset.type;
  48. const columnId = util.column('1').columnId;
  49. if(type == 1) {
  50. this.data.num1++
  51. this.setData({
  52. num1: this.data.num1
  53. })
  54. this.distinction(type, columnId, 1, 5*this.data.num1, res => {
  55. if(res.data.success) {
  56. console.log(res.data.data)
  57. this.setData({
  58. questionsData: res.data.data,
  59. })
  60. if(res.data.data) {
  61. this.setData({
  62. questionsdian: util.replyNo(res.data.data.list)
  63. })
  64. }
  65. }
  66. });
  67. }
  68. },
  69. /*点击定位*/
  70. location: function (e) {
  71. const position = e.currentTarget.dataset.id;
  72. console.log(position)
  73. this.setData({
  74. position: position
  75. })
  76. },
  77. onLoad: function (options) {
  78. },
  79. onShow: function () {
  80. const columnId = util.column('1').columnId;
  81. /* 答疑 */
  82. this.distinction(1, columnId, 1, 2, res => {
  83. if(res.data.success) {
  84. this.setData({
  85. questionsData: res.data.data,
  86. })
  87. if(res.data.data) {
  88. this.setData({
  89. questionsdian: util.replyNo(res.data.data.list)
  90. })
  91. }
  92. }
  93. });
  94. /*科目信息*/
  95. login.getOpenidSessionKey((res) => {
  96. //console.log(res.data.data.uid);
  97. APIClient.getEachSchedule({
  98. uid: res.data.data.uid
  99. }, {
  100. "category": 1
  101. }).success((res) => {
  102. const lessonListLength = res.data.data.lessonPage.list.length;
  103. const previewLength = util.preview(res.data.data.lessonPage.list).length;
  104. console.log(res)
  105. if(lessonListLength > 4) {
  106. this.setData({
  107. lessonListHeight: 280
  108. })
  109. }
  110. if(previewLength > 4){
  111. this.setData({
  112. previewHeight: 280
  113. })
  114. }
  115. this.setData({
  116. courseData: res.data.data,
  117. list: util.studyPageTime(res.data.data.lessonPage.list)
  118. })
  119. })
  120. }, function() {
  121. wx.showModal({
  122. title: '提示',
  123. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  124. showCancel: false,
  125. success: function (res) {
  126. if (res.confirm) {
  127. console.log('用户点击确定')
  128. } else if (res.cancel) {
  129. console.log('用户点击取消')
  130. }
  131. }
  132. })
  133. });
  134. },
  135. })