english.js 4.3 KB

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