language.js 3.9 KB

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