learning_report.js 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. // pages/learning_report/learning_report.js
  2. import F2 from '../../utils/f2-canvas/lib/f2';
  3. import { throttle} from '../../utils/util.js'
  4. const wxCharts = require('../../utils/wxcharts-min.js')
  5. const { getGlobalAttributeValue, post, globalData, sharePageDefaultCtl, redirectCtl, navigateCtl } = getApp()
  6. const { baseImgUrl, thumbnail } = globalData
  7. /**
  8. * 判断是否是空对象
  9. */
  10. const isEmptyObj = v => {
  11. if (v !== null && typeof v === 'object') {
  12. for (const i in v)
  13. return false
  14. return true
  15. }
  16. return true
  17. }
  18. /**
  19. * 判断是否是函数
  20. */
  21. const isFn = v => {
  22. return typeof v === 'function'
  23. }
  24. /**
  25. * 进度条颜色RGB
  26. */
  27. const greenRGB = '89, 221, 122'
  28. const yellowRGB = '253, 215, 99'
  29. const redRGB = '255, 100, 101'
  30. const grayRGB = '208, 213, 230'
  31. const purpleRGB = '119, 138, 220'
  32. const blackRGB = '57, 57, 57'
  33. const blueRGB = '84, 179, 236'
  34. Page({
  35. /**
  36. * 页面的初始数据
  37. */
  38. data: {
  39. baseImgUrl,
  40. thumbnail,
  41. greenRGB,
  42. yellowRGB,
  43. redRGB,
  44. grayRGB,
  45. purpleRGB,
  46. blackRGB,
  47. blueRGB,
  48. opts: {
  49. lazyLoad: true,
  50. },
  51. footerData: {
  52. actIndex: 1,
  53. list: [
  54. {
  55. text: '首页',
  56. url: '../../image/shou_ye_hui.png',
  57. actUrl: '../../image/shou_ye.png',
  58. src: 'homework_list',
  59. id: 'homework_list'
  60. },
  61. {
  62. text: '学习成长报告',
  63. url: '../../image/xue_qing_hui.png',
  64. actUrl: '../../image/xue_qing.png',
  65. src: 'learning_report',
  66. id: 'learning_report'
  67. },
  68. {
  69. text: '我的',
  70. url: '../../image/wo_de_hui.png',
  71. actUrl: '../../image/wo_de.png',
  72. src: 'me',
  73. id: 'me'
  74. }
  75. ]
  76. },
  77. navIndex: 0,
  78. navList: [
  79. {
  80. text: '周报',
  81. isLoaded: false,
  82. subjectIndex: 0,
  83. subjectList: [
  84. {
  85. subject: '语文',
  86. knowledgePointMasteryDetail: '',
  87. knowledgePointGoodNumber: 0,
  88. knowledgePointGeneralNumber: 0,
  89. knowledgePointPoorNumber: 0,
  90. // "learningScore": 82,
  91. // "knowledgePointProportionList": [
  92. // {
  93. // "knowledgeName": "适得府君书解放路",
  94. // "proportion": 0.55
  95. // },
  96. // {
  97. // "knowledgeName": "适得府君解君书解放路",
  98. // "proportion": 0.15
  99. // },
  100. // {
  101. // "knowledgeName": "适得府放路",
  102. // "proportion": 0.85
  103. // },
  104. // {
  105. // "knowledgeName": "适解放路",
  106. // "proportion": 0.95
  107. // },
  108. // {
  109. // "knowledgeName": "适a路",
  110. // "proportion": 1
  111. // },
  112. // {
  113. // "knowledgeName": "适b路",
  114. // "proportion": 0.75
  115. // },
  116. // {
  117. // "knowledgeName": "适c路",
  118. // "proportion": 0.74
  119. // },
  120. // ],
  121. // "otherKnowledgePointProportionList": [
  122. // {
  123. // "knowledgeName": "适得府君书解放路",
  124. // "proportion": 0.25
  125. // },
  126. // {
  127. // "knowledgeName": "适得府君解君书解放路",
  128. // "proportion": 0.25
  129. // },
  130. // {
  131. // "knowledgeName": "适得府放路",
  132. // "proportion": 0.25
  133. // },
  134. // {
  135. // "knowledgeName": "适解放路",
  136. // "proportion": 0.25
  137. // },
  138. // {
  139. // "knowledgeName": "适路",
  140. // "proportion": 0.25
  141. // },
  142. // ],
  143. // "knowledgePointMasteryList": [
  144. // {
  145. // "knowledgeName": "sdf",
  146. // "mastery": 0.85,
  147. // "knowHowDetailList": [
  148. // {
  149. // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
  150. // "knowledgeVersion": "1"
  151. // }
  152. // ]
  153. // },
  154. // {
  155. // "knowledgeName": "aafsdf",
  156. // "mastery": 0.84,
  157. // "knowHowDetailList": [
  158. // {
  159. // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
  160. // "knowledgeVersion": "1"
  161. // }
  162. // ]
  163. // },
  164. // {
  165. // "knowledgeName": "fffffffffffff",
  166. // "mastery": 0.75,
  167. // "knowHowDetailList": [
  168. // {
  169. // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
  170. // "knowledgeVersion": "1"
  171. // }
  172. // ]
  173. // },
  174. // {
  175. // "knowledgeName": "fffffffffffff",
  176. // "mastery": 0.25,
  177. // "knowHowDetailList": [
  178. // {
  179. // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
  180. // "knowledgeVersion": "1"
  181. // }
  182. // ]
  183. // },
  184. // ]
  185. },
  186. {
  187. subject: '数学',
  188. knowledgePointMasteryDetail: '',
  189. knowledgePointGoodNumber: 0,
  190. knowledgePointGeneralNumber: 0,
  191. knowledgePointPoorNumber: 0,
  192. // "learningScore": 82,
  193. // "knowledgePointProportionList": [
  194. // {
  195. // "knowledgeName": "",
  196. // "proportion": 0.25
  197. // }
  198. // ],
  199. // "otherKnowledgePointProportionList": [
  200. // {
  201. // "knowledgeName": "",
  202. // "proportion": 0.25
  203. // }
  204. // ],
  205. // "knowledgePointMasteryList": [
  206. // {
  207. // "knowledgeName": "",
  208. // "mastery": 0.25,
  209. // "knowHowDetailList": [
  210. // {
  211. // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
  212. // "knowledgeVersion": "1"
  213. // }
  214. // ]
  215. // }
  216. // ]
  217. },
  218. {
  219. subject: '英语',
  220. knowledgePointMasteryDetail: '',
  221. knowledgePointGoodNumber: 0,
  222. knowledgePointGeneralNumber: 0,
  223. knowledgePointPoorNumber: 0,
  224. // "learningScore": 82,
  225. // "knowledgePointProportionList": [
  226. // {
  227. // "knowledgeName": "",
  228. // "proportion": 0.25
  229. // }
  230. // ],
  231. // "otherKnowledgePointProportionList": [
  232. // {
  233. // "knowledgeName": "",
  234. // "proportion": 0.25
  235. // }
  236. // ],
  237. // "knowledgePointMasteryList": [
  238. // {
  239. // "knowledgeName": "",
  240. // "mastery": 0.25,
  241. // "knowHowDetailList": [
  242. // {
  243. // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
  244. // "knowledgeVersion": "1"
  245. // }
  246. // ]
  247. // }
  248. // ]
  249. },
  250. ],
  251. nodataObj: {
  252. text: '暂无数据',
  253. padding: '',
  254. image: '../../assets/task_nodata.png'
  255. },
  256. },
  257. {
  258. text: '月报',
  259. isLoaded: false,
  260. subjectIndex: 0,
  261. // "learningScore": 82,
  262. // "lastMonth": "9",
  263. // "increasedScore": 11,
  264. // "transcendedStudentProportion": 0.4,
  265. // "averageUsedTime": 82,
  266. subjectList: [
  267. // {
  268. // "subject": "语文",
  269. // "learnedUnitList": [
  270. // {
  271. // "unitName": "《古诗两首》"
  272. // }
  273. // ],
  274. // "weakKnowledgePointMasteryList": [
  275. // {
  276. // "knowledgeName": "sdf",
  277. // "mastery": 0.85,
  278. // "knowHowDetailList": [
  279. // {
  280. // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
  281. // "knowledgeVersion": "1"
  282. // }
  283. // ]
  284. // },
  285. // {
  286. // "knowledgeName": "aafsdf",
  287. // "mastery": 0.84,
  288. // "knowHowDetailList": [
  289. // {
  290. // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
  291. // "knowledgeVersion": "1"
  292. // }
  293. // ]
  294. // },
  295. // {
  296. // "knowledgeName": "fffffffffffff",
  297. // "mastery": 0.75,
  298. // "knowHowDetailList": [
  299. // {
  300. // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
  301. // "knowledgeVersion": "1"
  302. // }
  303. // ]
  304. // },
  305. // {
  306. // "knowledgeName": "fffffffffffff",
  307. // "mastery": 0.25,
  308. // "knowHowDetailList": [
  309. // {
  310. // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
  311. // "knowledgeVersion": "1"
  312. // }
  313. // ]
  314. // },
  315. // ]
  316. // },
  317. // {
  318. // "subject": "数学",
  319. // "learnedUnitList": [
  320. // {
  321. // "unitName": "《古诗两首》"
  322. // }
  323. // ],
  324. // "weakKnowledgePointMasteryList": [
  325. // {
  326. // "knowledgeName": "",
  327. // "mastery": 0.25
  328. // }
  329. // ]
  330. // },
  331. // {
  332. // "subject": "英语",
  333. // "learnedUnitList": [
  334. // {
  335. // "unitName": "《古诗两首》"
  336. // }
  337. // ],
  338. // "weakKnowledgePointMasteryList": [
  339. // {
  340. // "knowledgeName": "",
  341. // "mastery": 0.25
  342. // }
  343. // ]
  344. // },
  345. ],
  346. // "subjectKnowledgeInfoList": [
  347. // {
  348. // "subject": "语文",
  349. // "learnedUnitList": [
  350. // {
  351. // "unitName": "《古诗两首》"
  352. // }
  353. // ],
  354. // "weakKnowledgePointMasteryList": [
  355. // {
  356. // "knowledgeName": "",
  357. // "mastery": 0.25
  358. // }
  359. // ]
  360. // }
  361. // ],
  362. nodataObj: {
  363. text: '暂无数据',
  364. padding: '',
  365. image: '../../assets/task_nodata.png'
  366. },
  367. },
  368. {
  369. text: '学期',
  370. isLoaded: false,
  371. accuracyArray: [
  372. {
  373. name: '所有人平均正确率',
  374. color: 'rgba(124, 129, 157, 1)',
  375. },
  376. {
  377. name: '个人正确率',
  378. color: 'rgba(255, 100, 101, 1)',
  379. },
  380. ],
  381. subjectIndex: 0,
  382. // "vipId": "1475682f-739b-48af-8e10-b91d5537a38e",
  383. // "studentName": "陈小二",
  384. // "studentImg": "/2017/04/12/348b4d74-e105-42d7-b9ca-dbfac10b1cf8.jpg",
  385. // "labels": ["古灵精怪", "注意力集中", "团结友爱", "上课认真"],
  386. // "overallSituation": [
  387. // "语文存在严重的拼写错误,对此我们建议多对孩子的语文作业督促",
  388. // "数学存在严重的拼写错误,对此我们建议多对孩子的数学作业督促"
  389. // ],
  390. // "subjectList": ["语文", "数学", "英语"],
  391. subjectList: [
  392. // {
  393. // subject: '语文',
  394. // isShowLeaningSuggest: false,
  395. // "knowledge": {
  396. // "dimension": [
  397. // "维度1",
  398. // "维度2",
  399. // "维度3",
  400. // "维度4",
  401. // "维度5",
  402. // "维度1",
  403. // "维度2",
  404. // "维度3",
  405. // "维度4",
  406. // "维度5"
  407. // ],
  408. // "thisMonthTrueCount": [
  409. // 10,
  410. // 100,
  411. // 60,
  412. // 70,
  413. // 100,
  414. // 10,
  415. // 100,
  416. // 60,
  417. // 70,
  418. // 100,
  419. // ],
  420. // "overallAvgTrueCount": [
  421. // 40,
  422. // 20,
  423. // 60,
  424. // 70,
  425. // 200,
  426. // 40,
  427. // 20,
  428. // 60,
  429. // 70,
  430. // 200
  431. // ],
  432. // "diagnostic": "教师使用教堂用语是为了提高学生的口语",
  433. // "leaningSuggest": [
  434. // {
  435. // "title": "线性代数题目如何蒙中?",
  436. // "content": "三长一短选最短"
  437. // },
  438. // {
  439. // "title": "线性代数题目如何蒙中?",
  440. // "content": "三短一长选最长"
  441. // },
  442. // {
  443. // "title": "线性代数题目如何蒙中?",
  444. // "content": "不确定选b"
  445. // }
  446. // ]
  447. // },
  448. // "knowledgePoint": [
  449. // {
  450. // "noKnowledgePoint": [
  451. // {
  452. // "celebrities": [
  453. // "骄傲、谦虚、懦弱、灰尘、捧场、时代、价钱"
  454. // ],
  455. // "name": "认识11个生字,会写13个字"
  456. // },
  457. // {
  458. // "celebrities": [
  459. // "守护、植株、等待、宋朝、耕耘、触电、颈项、解释、其中、希冀"
  460. // ],
  461. // "name": "认识11个生字,会写14个生字"
  462. // }
  463. // ],
  464. // "percent": 91,
  465. // "style": "字词",
  466. // "totalNum": 8,
  467. // "wrongNum": 8
  468. // },
  469. // {
  470. // "noKnowledgePoint": [
  471. // {
  472. // "celebrities": [
  473. // "骄傲、谦虚、懦弱、灰尘、捧场、时代、价钱"
  474. // ],
  475. // "name": "认识11个生字,会写13个字"
  476. // },
  477. // {
  478. // "celebrities": [
  479. // "守护、植株、等待、宋朝、耕耘、触电、颈项、解释、其中、希冀"
  480. // ],
  481. // "name": "认识11个生字,会写14个生字"
  482. // }
  483. // ],
  484. // "percent": 63,
  485. // "style": "词",
  486. // "totalNum": 8,
  487. // "wrongNum": 8
  488. // }
  489. // ],
  490. // "homeworkAccuracyRateList": [
  491. // {
  492. // "date": "04.02",
  493. // "rate": 35,
  494. // color: `rgba(${redRGB},1)`
  495. // },
  496. // {
  497. // "date": "04.02",
  498. // "rate": 65,
  499. // color: `rgba(${yellowRGB},1)`
  500. // },
  501. // {
  502. // "date": "04.02",
  503. // "rate": 90,
  504. // color: `rgba(${greenRGB},1)`
  505. // },
  506. // {
  507. // "date": "04.02",
  508. // "rate": 100,
  509. // color: `rgba(${greenRGB},1)`
  510. // },
  511. // {
  512. // "date": "04.02",
  513. // "rate": 80,
  514. // color: `rgba(${yellowRGB},1)`
  515. // },
  516. // {
  517. // "date": "04.02",
  518. // "rate": 0,
  519. // color: `rgba(${redRGB},1)`
  520. // },
  521. // {
  522. // "date": "04.02",
  523. // "rate": 59,
  524. // color: `rgba(${redRGB},1)`
  525. // },
  526. // ]
  527. // },
  528. // {
  529. // subject: '数学',
  530. // },
  531. // {
  532. // subject: '英语',
  533. // },
  534. ],
  535. nodataObj: {
  536. text: '暂无数据',
  537. padding: '',
  538. image: '../../assets/task_nodata.png'
  539. },
  540. },
  541. ]
  542. },
  543. /**
  544. * 生命周期函数--监听页面加载
  545. */
  546. onLoad: function (options) {
  547. const { status = 0, vipId = '',serviceType=-1 } = options
  548. options.status = status
  549. options.serviceType = serviceType
  550. options.vipId = vipId || getGlobalAttributeValue(`parentVipId-${getGlobalAttributeValue('userId')}`)
  551. // 周报,月报
  552. // options.vipId = vipId || 'e150dfb8-da9d-45bb-9587-9cac09dad6c7'
  553. // 学期报
  554. // options.vipId = vipId || '6d246891-b885-4c56-921c-7f98c4ba0c49'
  555. // 张正坤的vipid
  556. // options.vipId = '297ec62e-1d6b-41ae-b980-7fe5ef3d702d'
  557. // options.vipId = '297ec62e-1d6b-41ae-b980-7fe5ef3d702d'
  558. const temp = {}
  559. temp['options'] = options
  560. temp['navIndex'] = status ? status - 1 : 0
  561. this.setData(temp)
  562. console.log(temp)
  563. },
  564. /**
  565. * 生命周期函数--监听页面初次渲染完成
  566. */
  567. onReady: function () {
  568. },
  569. /**
  570. * 生命周期函数--监听页面显示
  571. */
  572. onShow: function () {
  573. this.getData()
  574. },
  575. /**
  576. * 生命周期函数--监听页面隐藏
  577. */
  578. onHide: function () {
  579. },
  580. /**
  581. * 生命周期函数--监听页面卸载
  582. */
  583. onUnload: function () {
  584. },
  585. /**
  586. * 页面相关事件处理函数--监听用户下拉动作
  587. */
  588. onPullDownRefresh: function () {
  589. this.getData(() => {
  590. wx.stopPullDownRefresh()
  591. })
  592. },
  593. /**
  594. * 页面上拉触底事件的处理函数
  595. */
  596. onReachBottom: function () {
  597. },
  598. /**
  599. * 用户点击右上角分享
  600. */
  601. onShareAppMessage: function () {
  602. if (isFn(sharePageDefaultCtl)) sharePageDefaultCtl()
  603. },
  604. /**
  605. * 底部导航跳转
  606. */
  607. redirectCtl,
  608. /**
  609. * 路由跳转
  610. */
  611. navigateCtl,
  612. /**
  613. * 获取数据
  614. */
  615. getData: function (cb) {
  616. const { navIndex = 0 } = this.data
  617. switch (navIndex) {
  618. case 0:
  619. this.getWeekReport(cb)
  620. break
  621. case 1:
  622. this.getMonthReport(cb)
  623. break
  624. case 2:
  625. this.getDataOfSituation(cb)
  626. break
  627. }
  628. },
  629. /**
  630. * 获取周报数据
  631. */
  632. getWeekReport: function (cb) {
  633. const postData = { fn: this.getWeekReport, param: { ...arguments } }
  634. const { navList = [], navIndex = 0, options = {} } = this.data
  635. const { vipId = '' } = options
  636. const { subjectIndex = 0, subjectList = [] } = navList[navIndex] || {}
  637. const { subject = '' } = subjectList[subjectIndex] || {}
  638. // 当已存在数据的情况下,不用请求接口数据
  639. const { learningScore = 0, knowledgePointProportionList = [], otherKnowledgePointProportionList = [], moduleList = [] } = subjectList[subjectIndex] || {}
  640. if (learningScore && knowledgePointProportionList.length && otherKnowledgePointProportionList.length && moduleList.length) {
  641. this.drawRingCanvasOfKnowledgePoint()
  642. if (isFn(cb)) cb()
  643. return
  644. }
  645. post('/api/curator/curator/V1/weeklyReport', { vipId, subject }, 0, postData).then(res => {
  646. const {
  647. learningScore = 0,
  648. totalKnowledgeNum = 0,
  649. masterWellKnowledgeNum = 0,
  650. masterInfirmlyKnowledgeNum = 0,
  651. notMasteredKnowledgeNum = 0,
  652. knowledgePointProportionList = [],
  653. otherKnowledgePointProportionList = [],
  654. moduleList = []
  655. } = res.data || {}
  656. // 设置默认知识点掌握情况及对应的数量
  657. // const {
  658. // knowledgePointGoodNumber = 0,
  659. // knowledgePointGeneralNumber = 0,
  660. // knowledgePointPoorNumber = 0
  661. // } = (list => {
  662. // let knowledgePointGoodNumber = 0
  663. // let knowledgePointGeneralNumber = 0
  664. // let knowledgePointPoorNumber = 0
  665. // for (const v of list) {
  666. // const { mastery = 0 } = v
  667. // const num = ~~(mastery * 100)
  668. // if (num >= 85) {
  669. // knowledgePointGoodNumber++
  670. // } else if (num < 85 && num >= 60) {
  671. // knowledgePointGeneralNumber++
  672. // } else {
  673. // knowledgePointPoorNumber++
  674. // }
  675. // }
  676. // return {
  677. // knowledgePointGoodNumber,
  678. // knowledgePointGeneralNumber,
  679. // knowledgePointPoorNumber
  680. // }
  681. // })(knowledgePointMasteryList)
  682. // 知识点掌握情况
  683. const knowledgePointMasteryDetail = learningScore >= 95 ? '优秀' : learningScore >= 85 ? '良好' : learningScore >= 75 ? '一般' : '欠佳'
  684. const temp = {}
  685. temp[`navList[${navIndex}].isLoaded`] = true
  686. temp[`navList[${navIndex}].subjectList[${subjectIndex}].learningScore`] = learningScore
  687. temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePointProportionList`] = knowledgePointProportionList
  688. temp[`navList[${navIndex}].subjectList[${subjectIndex}].otherKnowledgePointProportionList`] = otherKnowledgePointProportionList
  689. temp[`navList[${navIndex}].subjectList[${subjectIndex}].moduleList`] = moduleList
  690. temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePointMasteryDetail`] = knowledgePointMasteryDetail
  691. temp[`navList[${navIndex}].subjectList[${subjectIndex}].totalKnowledgeNum`] = totalKnowledgeNum
  692. temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePointGoodNumber`] = masterWellKnowledgeNum
  693. temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePointGeneralNumber`] = masterInfirmlyKnowledgeNum
  694. temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePointPoorNumber`] = notMasteredKnowledgeNum
  695. this.setData(temp)
  696. this.drawRingCanvasOfKnowledgePoint()
  697. if (isFn(cb)) cb()
  698. }).catch (() => {
  699. const temp = {}
  700. temp[`navList[${navIndex}].isLoaded`] = true
  701. this.setData(temp)
  702. if (isFn(cb)) cb()
  703. })
  704. },
  705. /**
  706. * 获取月报数据
  707. */
  708. getMonthReport: function (cb) {
  709. const postData = { fn: this.getMonthReport, param: { ...arguments } }
  710. const { navList = [], navIndex = 0, options = {} } = this.data
  711. const { vipId = '' } = options
  712. // 当已存在数据的情况下,不用请求接口数据
  713. const { subjectList = [] } = navList[navIndex] || {}
  714. if (subjectList.length) {
  715. if (isFn(cb)) cb()
  716. return
  717. }
  718. post('/api/curator/curator/V1/monthlyReport', { vipId }, 0, postData).then(res => {
  719. const {
  720. learningScore = 0,
  721. lastMonth = '',
  722. increasedScore = 0,
  723. transcendedStudentProportion = 0,
  724. averageUsedTime = 0,
  725. subjectKnowledgeInfoList = []
  726. } = res.data || {}
  727. const temp = {}
  728. temp[`navList[${navIndex}].isLoaded`] = true
  729. temp[`navList[${navIndex}].learningScore`] = learningScore
  730. temp[`navList[${navIndex}].lastMonth`] = lastMonth
  731. temp[`navList[${navIndex}].increasedScore`] = increasedScore
  732. temp[`navList[${navIndex}].transcendedStudentProportion`] = transcendedStudentProportion
  733. temp[`navList[${navIndex}].averageUsedTime`] = averageUsedTime
  734. temp[`navList[${navIndex}].subjectList`] = subjectKnowledgeInfoList
  735. this.setData(temp)
  736. if (isFn(cb)) cb()
  737. }).catch(() => {
  738. const temp = {}
  739. temp[`navList[${navIndex}].isLoaded`] = true
  740. this.setData(temp)
  741. if (isFn(cb)) cb()
  742. })
  743. },
  744. /**
  745. * 获取学情初始数据
  746. */
  747. getDataOfSituation: function (cb) {
  748. const postData = { fn: this.getDataOfSituation, param: { ...arguments } }
  749. const { navList = [], navIndex = 0, options = {} } = this.data
  750. const { vipId = '' } = options
  751. // 当已存在数据的情况下,不用请求接口数据
  752. const { subjectList = [], studentName = '', studentImg = '', labels = [], overallSituation = [] } = navList[navIndex] || {}
  753. if (subjectList.length && studentName && studentImg && labels.length && overallSituation.length) {
  754. this.getSubjectOfSituation(cb)
  755. return
  756. }
  757. post('/api/curator/curator/V1/learningSituationAbstract', { vipId }, 0, postData).then(res => {
  758. const { studentName = '', studentImg = '', labels = [], overallSituation = [], subjects = [] } = res.data || {}
  759. const temp = {}
  760. temp[`navList[${navIndex}].studentName`] = studentName
  761. temp[`navList[${navIndex}].studentImg`] = studentImg
  762. temp[`navList[${navIndex}].labels`] = labels
  763. temp[`navList[${navIndex}].overallSituation`] = overallSituation
  764. temp[`navList[${navIndex}].subjects`] = subjects
  765. temp[`navList[${navIndex}].subjectList`] = (res => {
  766. const arr = []
  767. for (const v of res) {
  768. arr.push({ subject: v })
  769. }
  770. return arr
  771. })(subjects)
  772. this.setData(temp)
  773. if (subjects.length > 0) {
  774. this.getSubjectOfSituation(cb)
  775. } else {
  776. const temp = {}
  777. temp[`navList[${navIndex}].isLoaded`] = true
  778. this.setData(temp)
  779. if (isFn(cb)) cb()
  780. }
  781. }).catch(() => {
  782. const temp = {}
  783. temp[`navList[${navIndex}].isLoaded`] = true
  784. this.setData(temp)
  785. if (isFn(cb)) cb()
  786. })
  787. },
  788. /**
  789. * 获取单科学情详情
  790. */
  791. getSubjectOfSituation: function (cb) {
  792. const postData = { fn: this.getSubjectOfSituation, param: { ...arguments } }
  793. const { navList = [], navIndex = 0, options = {} } = this.data
  794. const { vipId = '' } = options
  795. const { subjectIndex = 0, subjectList = [] } = navList[navIndex] || {}
  796. const { subject = '', semester = 0, grade = '' } = subjectList[subjectIndex] || {}
  797. // 当已存在数据的情况下,不用请求接口数据
  798. const { knowledge = {}, knowledgePoint = [], homeworkAccuracyRateList = [] } = subjectList[subjectIndex] || {}
  799. if (!isEmptyObj(knowledge) && knowledgePoint.length && homeworkAccuracyRateList.length) {
  800. this.drawRadarCanvasOfKnowledge()
  801. this.drawRingCanvasOfKnowledgePointMastery()
  802. if (isFn(cb)) cb()
  803. return
  804. }
  805. post('/api/curator/curator/V1/learningSituationDetailNew', { vipId, subject, semester, grade }, 0, postData).then(res => {
  806. const { knowledge = '', knowledgePoint = '', homeworkAccuracyRateList = [] } = res.data
  807. const temp = {}
  808. temp[`navList[${navIndex}].isLoaded`] = true
  809. temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledge`] = knowledge
  810. temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePoint`] = knowledgePoint
  811. temp[`navList[${navIndex}].subjectList[${subjectIndex}].homeworkAccuracyRateList`] = homeworkAccuracyRateList
  812. this.setData(temp)
  813. this.drawRadarCanvasOfKnowledge()
  814. this.drawRingCanvasOfKnowledgePointMastery()
  815. if (isFn(cb)) cb()
  816. }).catch(() => {
  817. const temp = {}
  818. temp[`navList[${navIndex}].isLoaded`] = true
  819. this.setData(temp)
  820. if (isFn(cb)) cb()
  821. })
  822. },
  823. /**
  824. * 选择切换项
  825. */
  826. selectNavIndexCtl:throttle(function (e) {
  827. const { index } = e.currentTarget.dataset
  828. const { navIndex = 0, navList = [] } = this.data || {}
  829. const { subjectList = [] } = navList[index] || {}
  830. if (navIndex == index) return
  831. const temp = {}
  832. temp[`navIndex`] = index
  833. this.setData(temp)
  834. this.getData()
  835. },500),
  836. /**
  837. * 选择切换学情科目项
  838. */
  839. selectSubjectIndexCtl: function (e) {
  840. const { index } = e.currentTarget.dataset
  841. const { navList = [], navIndex = 0 } = this.data
  842. const { subjectList = [], subjectIndex = 0 } = navList[navIndex] || {}
  843. if (subjectIndex == index) return
  844. const temp = {}
  845. temp[`navList[${navIndex}].subjectIndex`] = index
  846. this.setData(temp)
  847. this.getData()
  848. },
  849. /**
  850. * 获取容器高度,使页面滚动到容器底部
  851. */
  852. pageScrollToBottom: function () {
  853. wx.createSelectorQuery().select('#wrapper').boundingClientRect(function (rect) {
  854. wx.pageScrollTo({
  855. scrollTop: rect.bottom
  856. })
  857. }).exec()
  858. },
  859. /**
  860. * 切换显示未掌握知识点
  861. */
  862. toggleShowNoknowledgePointCtl: function (e) {
  863. const { index = 0 } = e.currentTarget.dataset
  864. const { navList = [], navIndex = 0 } = this.data
  865. const { subjectList = [], subjectIndex = 0 } = navList[navIndex] || {}
  866. const { knowledgePoint = [] } = subjectList[subjectIndex] || {}
  867. const { isShowNoknowledgePoint = false } = knowledgePoint[index] || {}
  868. const temp = {}
  869. temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePoint[${index}].isShowNoknowledgePoint`] = !isShowNoknowledgePoint
  870. this.setData(temp)
  871. },
  872. /**
  873. * 切换显示学习建议
  874. */
  875. toggleLeaningSuggestCtl: function () {
  876. const { navList = [], navIndex = 0 } = this.data
  877. const { subjectList = [], subjectIndex = 0 } = navList[navIndex] || {}
  878. const { isShowLeaningSuggest = false } = subjectList[subjectIndex] || {}
  879. const temp = {}
  880. temp[`navList[${navIndex}].subjectList[${subjectIndex}].isShowLeaningSuggest`] = !isShowLeaningSuggest
  881. this.setData(temp)
  882. },
  883. /**
  884. * 绘制知识点圆环
  885. */
  886. drawRingCanvasOfKnowledgePoint: function () {
  887. const { navList = [], navIndex = 0 } = this.data
  888. const { subjectList = [], subjectIndex = 0 } = navList[navIndex] || {}
  889. const { knowledgePointProportionList = [] } = subjectList[subjectIndex] || {}
  890. if (knowledgePointProportionList.length === 0) return
  891. this.selectComponent('#knowledgePointRingCanvas').init(function (canvas, width, height) {
  892. // 数据
  893. const data = (list => {
  894. const arr = []
  895. for (const v of list) {
  896. const { knowledgeName = '', proportion = 0 } = v
  897. arr.push({
  898. const: 'const',
  899. type: knowledgeName,
  900. percent: ~~(+proportion * 100)
  901. })
  902. }
  903. return arr
  904. })(knowledgePointProportionList)
  905. // 生成画布
  906. const chart = new F2.Chart({
  907. el: canvas,
  908. width,
  909. height
  910. })
  911. chart.source(data)
  912. chart.coord('polar', {
  913. transposed: true,
  914. radius: 0.9,
  915. innerRadius: 0.5
  916. })
  917. chart.axis(false)
  918. chart.legend(false)
  919. chart.tooltip(true)
  920. chart.interval().position('const*percent').adjust('stack').color('type', [
  921. `rgba(${greenRGB}, 1)`,
  922. `rgba(${yellowRGB}, 1)`,
  923. `rgba(${redRGB}, 1)`,
  924. `rgba(${purpleRGB}, 1)`])
  925. chart.pieLabel({
  926. sidePadding: 30,
  927. activeShape: true,
  928. label1: function label1(data) {
  929. return {
  930. text: data.percent + '%',
  931. fill: `rgba(${blueRGB}, 1)`,
  932. fontWeight: 'bold'
  933. };
  934. },
  935. label2: function label2(data) {
  936. return {
  937. text: data.type.length > 3 ? data.type.substring(0, 3) + '...' : data.type,
  938. fill: `rgba(${blackRGB}, 1)`,
  939. fontWeight: 'bold'
  940. };
  941. },
  942. onClick: function onClick(e) {
  943. const { data = {} } = e
  944. console.log(data)
  945. }
  946. });
  947. chart.render()
  948. return chart
  949. })
  950. },
  951. /**
  952. * 绘制雷达图
  953. */
  954. drawRadarCanvasOfKnowledge: function () {
  955. const { navList = [], navIndex = 0 } = this.data
  956. const { subjectList = [], subjectIndex = 0, accuracyArray = [] } = navList[navIndex] || {}
  957. const { knowledge = {} } = subjectList[subjectIndex] || {}
  958. if (isEmptyObj(knowledge)) return
  959. const Fn = (obj, canvasId, arr) => {
  960. if (!canvasId) return
  961. const { dimension = [], thisMonthTrueCount = [], overallAvgTrueCount = [] } = obj
  962. new wxCharts({
  963. animation: true,
  964. canvasId,
  965. type: 'radar',
  966. categories: dimension,
  967. series: ((arr, data) => {
  968. for (let i in arr) {
  969. arr[i].data = data[i]
  970. }
  971. return arr
  972. })(arr, [overallAvgTrueCount, thisMonthTrueCount]),
  973. width: 300,
  974. height: 300,
  975. dataPointShape: false,
  976. legend: false,
  977. extra: {
  978. radar: {
  979. max: 100,//雷达数值的最大值
  980. gridColor: '#D0D5E6',
  981. labelColor: '#7C819D'
  982. }
  983. }
  984. })
  985. }
  986. Fn(knowledge, 'knowledgeRadarCanvas', accuracyArray)
  987. },
  988. /**
  989. * 绘制圆环进度条
  990. */
  991. drawRingCanvasOfKnowledgePointMastery: function () {
  992. const { navList = [], navIndex = 0 } = this.data
  993. const { subjectList = [], subjectIndex = 0, accuracyArray = [] } = navList[navIndex] || {}
  994. const { knowledgePoint = {} } = subjectList[subjectIndex] || {}
  995. if (isEmptyObj(knowledgePoint)) return
  996. const Fn = (canvasId = '', percent = 0) => {
  997. if (!canvasId) return
  998. // 计算圆环颜色
  999. const color = percent < 15||percent==15 ? greenRGB : percent < 40||percent==40 ? yellowRGB : redRGB
  1000. // 配置项参数
  1001. const startColor = `rgba(${color}, 1)`
  1002. const endColor = `rgba(${color}, 1)`
  1003. const baseColor = `rgba(${grayRGB}, 1)`
  1004. const width = 29
  1005. const height = 29
  1006. const minWidth = 25
  1007. const baseLineWidth = 6
  1008. const actLineWidth = 8
  1009. const actLineCap = 'round'
  1010. const fontSize = 12
  1011. const textAlign = 'center'
  1012. const baseLine = 'middle'
  1013. const fontColor = `rgba(${blackRGB}, 1)`
  1014. // 初始化画布
  1015. const ctx = wx.createCanvasContext(canvasId)
  1016. const grd = ctx.createLinearGradient(width / 2, 0, width / 2, height)
  1017. grd.addColorStop(0, endColor)
  1018. grd.addColorStop(1, startColor)
  1019. // 圆环边框
  1020. ctx.beginPath()
  1021. ctx.arc(width, height, minWidth, 0, 2 * Math.PI)
  1022. ctx.setStrokeStyle(baseColor)
  1023. ctx.setLineWidth(baseLineWidth)
  1024. ctx.stroke()
  1025. // 圆环
  1026. if (percent > 0) {
  1027. ctx.beginPath()
  1028. ctx.arc(width, height, minWidth, -Math.PI / 2, Math.PI * 2 * percent / 100 - Math.PI / 2, false)
  1029. ctx.setStrokeStyle(grd)
  1030. ctx.setLineWidth(actLineWidth)
  1031. ctx.setLineCap(actLineCap)
  1032. ctx.stroke()
  1033. }
  1034. // 占比值
  1035. ctx.setFontSize(fontSize)
  1036. ctx.setTextAlign(textAlign)
  1037. ctx.setTextBaseline(baseLine)
  1038. ctx.setFillStyle(fontColor)
  1039. ctx.fillText(`${percent}%`, width, height)
  1040. ctx.draw()
  1041. }
  1042. for (let i in knowledgePoint) {
  1043. Fn(`knowledgePointMasteryRingCanvas-${i}`, ~~knowledgePoint[i].percent)
  1044. }
  1045. },
  1046. /**
  1047. * 返回上一页
  1048. */
  1049. backBook:function(){
  1050. wx.navigateBack({
  1051. delta: 1,
  1052. })
  1053. }
  1054. })