art.js 6.3 KB

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