art.js 6.0 KB

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