art.js 5.7 KB

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