art.js 7.7 KB

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