art.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. /**
  7. * productionData 分项data
  8. * questionsData 疑问data
  9. * courseData 科目信息
  10. * num1 分享得值
  11. * num2 科目得值
  12. * position 定位id值
  13. * questionsdian 点的显示
  14. * list 更改后时间的值
  15. * lessonListHeight 定义高度
  16. * previewHeight 定义高度
  17. * productionMore和questionsMore展开是否显示
  18. * strategy 更改<br>
  19. * 其他的页面组件就看这个就行了 基本上都是都是一样的
  20. */
  21. Page({
  22. data: {
  23. productionData: {},
  24. questionsData: {},
  25. courseData: {},
  26. num1: 0,
  27. num2: 0,
  28. position: '',
  29. questionsdian: '',
  30. list: [],
  31. lessonListHeight: '',
  32. previewHeight: '',
  33. productionMore: '',
  34. questionsMore: '',
  35. wxObjectives: [],
  36. canvasHeight: '',
  37. flag: true,
  38. materialData: []
  39. },
  40. /* 区分答疑和分享 */
  41. distinction: function(type, columnId, pageNo, pageSize, success) {
  42. login.getOpenidSessionKey(function(res) {
  43. //console.log(res.data.data.uid);
  44. APIClient.getProductionSchedule({
  45. uid: res.data.data.uid
  46. }, {
  47. "type": type,
  48. "category": columnId,
  49. "pageNo": pageNo,
  50. "pageSize": pageSize
  51. }).success(success)
  52. }, function() {
  53. });
  54. },
  55. /*点击加载更多*/
  56. onMyEvent: function(e){
  57. let type = e.currentTarget.dataset.type;
  58. const columnId = util.column('6').columnId;
  59. if(type == 1) {
  60. this.data.num1++
  61. this.setData({
  62. num1: this.data.num1
  63. })
  64. this.distinction(type, columnId, 1, 5*this.data.num1, res => {
  65. if(res.data.success) {
  66. console.log(res.data.data)
  67. this.setData({
  68. questionsData: res.data.data,
  69. })
  70. if(res.data.data) {
  71. this.setData({
  72. questionsdian: util.replyNo(res.data.data.list)
  73. })
  74. if(5*this.data.num1 > res.data.data.totalSize) {
  75. this.setData({
  76. questionsMore: ''
  77. })
  78. }
  79. }
  80. }
  81. });
  82. }
  83. if(type == 2) {
  84. this.data.num2++
  85. this.setData({
  86. num: this.data.num2
  87. })
  88. this.distinction(type, columnId, 1, 5*this.data.num2, res => {
  89. if(res.data.success) {
  90. console.log(res.data.data)
  91. this.setData({
  92. productionData: res.data.data,
  93. })
  94. if(5*this.data.num2 > res.data.data.totalSize) {
  95. this.setData({
  96. productionMore: ''
  97. })
  98. }
  99. }
  100. });
  101. }
  102. },
  103. /*点击获取canvas高度*/
  104. onGetHeight: function (e) {
  105. const canvasHeight = this.selectComponent("#chat").data.canvasHeight;
  106. this.setData({
  107. canvasHeight,
  108. })
  109. },
  110. /*点击定位*/
  111. location: function (e) {
  112. const position = e.currentTarget.dataset.id;
  113. console.log(position)
  114. this.setData({
  115. position
  116. })
  117. },
  118. onLoad: function (options) {
  119. //this.chat = this.selectComponent("#chat");
  120. const columnId = util.column('6').columnId;
  121. /* 分享 */
  122. this.distinction(2, columnId, 1, 2, res => {
  123. if(res.data.success) {
  124. console.log(res.data.data)
  125. this.setData({
  126. productionData: res.data.data
  127. })
  128. if(res.data.data) {
  129. if(res.data.data.totalSize > 2) {
  130. this.setData({
  131. productionMore: true
  132. })
  133. }
  134. }
  135. }
  136. });
  137. /* 答疑 */
  138. this.distinction(1, columnId, 1, 2, res => {
  139. if(res.data.success) {
  140. console.log(res.data.data)
  141. this.setData({
  142. questionsData: res.data.data
  143. })
  144. if(res.data.data) {
  145. this.setData({
  146. questionsdian: util.replyNo(res.data.data.list)
  147. })
  148. if(res.data.data.totalSize > 2) {
  149. this.setData({
  150. questionsMore: true
  151. })
  152. }
  153. }
  154. }
  155. });
  156. /*科目信息*/
  157. login.getOpenidSessionKey((res) => {
  158. APIClient.getEachSchedule({
  159. uid: res.data.data.uid
  160. }, {
  161. "category": 6
  162. }).success((res) => {
  163. const lessonListLength = util.studyPageTime(res.data.data.lessonPage.list).length;
  164. const previewLength = util.filter(res.data.data.lessonPage.list).length;
  165. console.log(res)
  166. if(lessonListLength > 4) {
  167. this.setData({
  168. lessonListHeight: 280
  169. })
  170. }
  171. if(previewLength > 4){
  172. this.setData({
  173. previewHeight: 280
  174. })
  175. }
  176. this.setData({
  177. courseData: res.data.data,
  178. materialData: util.filter(res.data.data.lessonPage.list),
  179. list: util.studyPageTime(res.data.data.lessonPage.list),
  180. wxObjectives: util.strategy(res.data.data.weekCourseConfig.wxObjectives)
  181. })
  182. })
  183. }, () => {
  184. this.setData({
  185. flag: !this.data.flag
  186. })
  187. });
  188. },
  189. onShow: function () {
  190. },
  191. keep: function () {
  192. },
  193. /* 转发*/
  194. onShareAppMessage: function (ops) {
  195. if (ops.from === 'button') {
  196. // 来自页面内转发按钮
  197. console.log(ops.target)
  198. }
  199. const postId = ops.target.dataset.postid;
  200. const imageUrl= ops.target.dataset.imageurl[0];
  201. return {
  202. title: '小学王者班',
  203. path: `pages/transmit/transmit?ind=7&postId=${postId}`,
  204. imageUrl,
  205. success: function (res) {
  206. // 转发成功
  207. console.log("转发成功:" + JSON.stringify(res));
  208. },
  209. fail: function (res) {
  210. // 转发失败
  211. console.log("转发失败:" + JSON.stringify(res));
  212. }
  213. }
  214. },
  215. /*获取个人信息弹框*/
  216. jurisdiction: function () {
  217. this.setData({
  218. flag: !this.data.flag
  219. })
  220. this.onLoad();
  221. },
  222. })