art.js 5.9 KB

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