1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108 |
- // pages/learning_report/learning_report.js
- import F2 from '../../utils/f2-canvas/lib/f2';
- import { throttle} from '../../utils/util.js'
- const wxCharts = require('../../utils/wxcharts-min.js')
- const { getGlobalAttributeValue, post, globalData, sharePageDefaultCtl, redirectCtl, navigateCtl } = getApp()
- const { baseImgUrl, thumbnail } = globalData
- /**
- * 判断是否是空对象
- */
- const isEmptyObj = v => {
- if (v !== null && typeof v === 'object') {
- for (const i in v)
- return false
- return true
- }
- return true
- }
- /**
- * 判断是否是函数
- */
- const isFn = v => {
- return typeof v === 'function'
- }
- /**
- * 进度条颜色RGB
- */
- const greenRGB = '89, 221, 122'
- const yellowRGB = '253, 215, 99'
- const redRGB = '255, 100, 101'
- const grayRGB = '208, 213, 230'
- const purpleRGB = '119, 138, 220'
- const blackRGB = '57, 57, 57'
- const blueRGB = '84, 179, 236'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- baseImgUrl,
- thumbnail,
- greenRGB,
- yellowRGB,
- redRGB,
- grayRGB,
- purpleRGB,
- blackRGB,
- blueRGB,
- opts: {
- lazyLoad: true,
- },
- footerData: {
- actIndex: 1,
- list: [
- {
- text: '首页',
- url: '../../image/shou_ye_hui.png',
- actUrl: '../../image/shou_ye.png',
- src: 'homework_list',
- id: 'homework_list'
- },
- {
- text: '学习成长报告',
- url: '../../image/xue_qing_hui.png',
- actUrl: '../../image/xue_qing.png',
- src: 'learning_report',
- id: 'learning_report'
- },
- {
- text: '我的',
- url: '../../image/wo_de_hui.png',
- actUrl: '../../image/wo_de.png',
- src: 'me',
- id: 'me'
- }
- ]
- },
- navIndex: 0,
- navList: [
- {
- text: '周报',
- isLoaded: false,
- subjectIndex: 0,
- subjectList: [
- {
- subject: '语文',
- knowledgePointMasteryDetail: '',
- knowledgePointGoodNumber: 0,
- knowledgePointGeneralNumber: 0,
- knowledgePointPoorNumber: 0,
- // "learningScore": 82,
- // "knowledgePointProportionList": [
- // {
- // "knowledgeName": "适得府君书解放路",
- // "proportion": 0.55
- // },
- // {
- // "knowledgeName": "适得府君解君书解放路",
- // "proportion": 0.15
- // },
- // {
- // "knowledgeName": "适得府放路",
- // "proportion": 0.85
- // },
- // {
- // "knowledgeName": "适解放路",
- // "proportion": 0.95
- // },
- // {
- // "knowledgeName": "适a路",
- // "proportion": 1
- // },
- // {
- // "knowledgeName": "适b路",
- // "proportion": 0.75
- // },
- // {
- // "knowledgeName": "适c路",
- // "proportion": 0.74
- // },
- // ],
- // "otherKnowledgePointProportionList": [
- // {
- // "knowledgeName": "适得府君书解放路",
- // "proportion": 0.25
- // },
- // {
- // "knowledgeName": "适得府君解君书解放路",
- // "proportion": 0.25
- // },
- // {
- // "knowledgeName": "适得府放路",
- // "proportion": 0.25
- // },
- // {
- // "knowledgeName": "适解放路",
- // "proportion": 0.25
- // },
- // {
- // "knowledgeName": "适路",
- // "proportion": 0.25
- // },
- // ],
- // "knowledgePointMasteryList": [
- // {
- // "knowledgeName": "sdf",
- // "mastery": 0.85,
- // "knowHowDetailList": [
- // {
- // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
- // "knowledgeVersion": "1"
- // }
- // ]
- // },
- // {
- // "knowledgeName": "aafsdf",
- // "mastery": 0.84,
- // "knowHowDetailList": [
- // {
- // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
- // "knowledgeVersion": "1"
- // }
- // ]
- // },
- // {
- // "knowledgeName": "fffffffffffff",
- // "mastery": 0.75,
- // "knowHowDetailList": [
- // {
- // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
- // "knowledgeVersion": "1"
- // }
- // ]
- // },
- // {
- // "knowledgeName": "fffffffffffff",
- // "mastery": 0.25,
- // "knowHowDetailList": [
- // {
- // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
- // "knowledgeVersion": "1"
- // }
- // ]
- // },
- // ]
- },
- {
- subject: '数学',
- knowledgePointMasteryDetail: '',
- knowledgePointGoodNumber: 0,
- knowledgePointGeneralNumber: 0,
- knowledgePointPoorNumber: 0,
- // "learningScore": 82,
- // "knowledgePointProportionList": [
- // {
- // "knowledgeName": "",
- // "proportion": 0.25
- // }
- // ],
- // "otherKnowledgePointProportionList": [
- // {
- // "knowledgeName": "",
- // "proportion": 0.25
- // }
- // ],
- // "knowledgePointMasteryList": [
- // {
- // "knowledgeName": "",
- // "mastery": 0.25,
- // "knowHowDetailList": [
- // {
- // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
- // "knowledgeVersion": "1"
- // }
- // ]
- // }
- // ]
- },
- {
- subject: '英语',
- knowledgePointMasteryDetail: '',
- knowledgePointGoodNumber: 0,
- knowledgePointGeneralNumber: 0,
- knowledgePointPoorNumber: 0,
- // "learningScore": 82,
- // "knowledgePointProportionList": [
- // {
- // "knowledgeName": "",
- // "proportion": 0.25
- // }
- // ],
- // "otherKnowledgePointProportionList": [
- // {
- // "knowledgeName": "",
- // "proportion": 0.25
- // }
- // ],
- // "knowledgePointMasteryList": [
- // {
- // "knowledgeName": "",
- // "mastery": 0.25,
- // "knowHowDetailList": [
- // {
- // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
- // "knowledgeVersion": "1"
- // }
- // ]
- // }
- // ]
- },
- ],
- nodataObj: {
- text: '暂无数据',
- padding: '',
- image: '../../assets/task_nodata.png'
- },
- },
- {
- text: '月报',
- isLoaded: false,
- subjectIndex: 0,
- // "learningScore": 82,
- // "lastMonth": "9",
- // "increasedScore": 11,
- // "transcendedStudentProportion": 0.4,
- // "averageUsedTime": 82,
- subjectList: [
- // {
- // "subject": "语文",
- // "learnedUnitList": [
- // {
- // "unitName": "《古诗两首》"
- // }
- // ],
- // "weakKnowledgePointMasteryList": [
- // {
- // "knowledgeName": "sdf",
- // "mastery": 0.85,
- // "knowHowDetailList": [
- // {
- // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
- // "knowledgeVersion": "1"
- // }
- // ]
- // },
- // {
- // "knowledgeName": "aafsdf",
- // "mastery": 0.84,
- // "knowHowDetailList": [
- // {
- // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
- // "knowledgeVersion": "1"
- // }
- // ]
- // },
- // {
- // "knowledgeName": "fffffffffffff",
- // "mastery": 0.75,
- // "knowHowDetailList": [
- // {
- // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
- // "knowledgeVersion": "1"
- // }
- // ]
- // },
- // {
- // "knowledgeName": "fffffffffffff",
- // "mastery": 0.25,
- // "knowHowDetailList": [
- // {
- // "knowHowDetailId": "d4bf0c0f-2c19-4881-a18f-3b15ea0a7290",
- // "knowledgeVersion": "1"
- // }
- // ]
- // },
- // ]
- // },
- // {
- // "subject": "数学",
- // "learnedUnitList": [
- // {
- // "unitName": "《古诗两首》"
- // }
- // ],
- // "weakKnowledgePointMasteryList": [
- // {
- // "knowledgeName": "",
- // "mastery": 0.25
- // }
- // ]
- // },
- // {
- // "subject": "英语",
- // "learnedUnitList": [
- // {
- // "unitName": "《古诗两首》"
- // }
- // ],
- // "weakKnowledgePointMasteryList": [
- // {
- // "knowledgeName": "",
- // "mastery": 0.25
- // }
- // ]
- // },
- ],
- // "subjectKnowledgeInfoList": [
- // {
- // "subject": "语文",
- // "learnedUnitList": [
- // {
- // "unitName": "《古诗两首》"
- // }
- // ],
- // "weakKnowledgePointMasteryList": [
- // {
- // "knowledgeName": "",
- // "mastery": 0.25
- // }
- // ]
- // }
- // ],
- nodataObj: {
- text: '暂无数据',
- padding: '',
- image: '../../assets/task_nodata.png'
- },
- },
- {
- text: '学期',
- isLoaded: false,
- accuracyArray: [
- {
- name: '所有人平均正确率',
- color: 'rgba(124, 129, 157, 1)',
- },
- {
- name: '个人正确率',
- color: 'rgba(255, 100, 101, 1)',
- },
- ],
- subjectIndex: 0,
- // "vipId": "1475682f-739b-48af-8e10-b91d5537a38e",
- // "studentName": "陈小二",
- // "studentImg": "/2017/04/12/348b4d74-e105-42d7-b9ca-dbfac10b1cf8.jpg",
- // "labels": ["古灵精怪", "注意力集中", "团结友爱", "上课认真"],
- // "overallSituation": [
- // "语文存在严重的拼写错误,对此我们建议多对孩子的语文作业督促",
- // "数学存在严重的拼写错误,对此我们建议多对孩子的数学作业督促"
- // ],
- // "subjectList": ["语文", "数学", "英语"],
- subjectList: [
- // {
- // subject: '语文',
- // isShowLeaningSuggest: false,
- // "knowledge": {
- // "dimension": [
- // "维度1",
- // "维度2",
- // "维度3",
- // "维度4",
- // "维度5",
- // "维度1",
- // "维度2",
- // "维度3",
- // "维度4",
- // "维度5"
- // ],
- // "thisMonthTrueCount": [
- // 10,
- // 100,
- // 60,
- // 70,
- // 100,
- // 10,
- // 100,
- // 60,
- // 70,
- // 100,
- // ],
- // "overallAvgTrueCount": [
- // 40,
- // 20,
- // 60,
- // 70,
- // 200,
- // 40,
- // 20,
- // 60,
- // 70,
- // 200
- // ],
- // "diagnostic": "教师使用教堂用语是为了提高学生的口语",
- // "leaningSuggest": [
- // {
- // "title": "线性代数题目如何蒙中?",
- // "content": "三长一短选最短"
- // },
- // {
- // "title": "线性代数题目如何蒙中?",
- // "content": "三短一长选最长"
- // },
- // {
- // "title": "线性代数题目如何蒙中?",
- // "content": "不确定选b"
- // }
- // ]
- // },
- // "knowledgePoint": [
- // {
- // "noKnowledgePoint": [
- // {
- // "celebrities": [
- // "骄傲、谦虚、懦弱、灰尘、捧场、时代、价钱"
- // ],
- // "name": "认识11个生字,会写13个字"
- // },
- // {
- // "celebrities": [
- // "守护、植株、等待、宋朝、耕耘、触电、颈项、解释、其中、希冀"
- // ],
- // "name": "认识11个生字,会写14个生字"
- // }
- // ],
- // "percent": 91,
- // "style": "字词",
- // "totalNum": 8,
- // "wrongNum": 8
- // },
- // {
- // "noKnowledgePoint": [
- // {
- // "celebrities": [
- // "骄傲、谦虚、懦弱、灰尘、捧场、时代、价钱"
- // ],
- // "name": "认识11个生字,会写13个字"
- // },
- // {
- // "celebrities": [
- // "守护、植株、等待、宋朝、耕耘、触电、颈项、解释、其中、希冀"
- // ],
- // "name": "认识11个生字,会写14个生字"
- // }
- // ],
- // "percent": 63,
- // "style": "词",
- // "totalNum": 8,
- // "wrongNum": 8
- // }
- // ],
- // "homeworkAccuracyRateList": [
- // {
- // "date": "04.02",
- // "rate": 35,
- // color: `rgba(${redRGB},1)`
- // },
- // {
- // "date": "04.02",
- // "rate": 65,
- // color: `rgba(${yellowRGB},1)`
- // },
- // {
- // "date": "04.02",
- // "rate": 90,
- // color: `rgba(${greenRGB},1)`
- // },
- // {
- // "date": "04.02",
- // "rate": 100,
- // color: `rgba(${greenRGB},1)`
- // },
- // {
- // "date": "04.02",
- // "rate": 80,
- // color: `rgba(${yellowRGB},1)`
- // },
- // {
- // "date": "04.02",
- // "rate": 0,
- // color: `rgba(${redRGB},1)`
- // },
- // {
- // "date": "04.02",
- // "rate": 59,
- // color: `rgba(${redRGB},1)`
- // },
- // ]
- // },
- // {
- // subject: '数学',
- // },
- // {
- // subject: '英语',
- // },
- ],
- nodataObj: {
- text: '暂无数据',
- padding: '',
- image: '../../assets/task_nodata.png'
- },
- },
- ]
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- const { status = 0, vipId = '',serviceType=-1 } = options
- options.status = status
- options.serviceType = serviceType
- options.vipId = vipId || getGlobalAttributeValue(`parentVipId-${getGlobalAttributeValue('userId')}`)
- // 周报,月报
- // options.vipId = vipId || 'e150dfb8-da9d-45bb-9587-9cac09dad6c7'
- // 学期报
- // options.vipId = vipId || '6d246891-b885-4c56-921c-7f98c4ba0c49'
- // 张正坤的vipid
- // options.vipId = '297ec62e-1d6b-41ae-b980-7fe5ef3d702d'
- // options.vipId = '297ec62e-1d6b-41ae-b980-7fe5ef3d702d'
- const temp = {}
- temp['options'] = options
- temp['navIndex'] = status ? status - 1 : 0
- this.setData(temp)
- console.log(temp)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getData()
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.getData(() => {
- wx.stopPullDownRefresh()
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- if (isFn(sharePageDefaultCtl)) sharePageDefaultCtl()
- },
- /**
- * 底部导航跳转
- */
- redirectCtl,
- /**
- * 路由跳转
- */
- navigateCtl,
- /**
- * 获取数据
- */
- getData: function (cb) {
- const { navIndex = 0 } = this.data
- switch (navIndex) {
- case 0:
- this.getWeekReport(cb)
- break
- case 1:
- this.getMonthReport(cb)
- break
- case 2:
- this.getDataOfSituation(cb)
- break
- }
- },
- /**
- * 获取周报数据
- */
- getWeekReport: function (cb) {
- const postData = { fn: this.getWeekReport, param: { ...arguments } }
- const { navList = [], navIndex = 0, options = {} } = this.data
- const { vipId = '' } = options
- const { subjectIndex = 0, subjectList = [] } = navList[navIndex] || {}
- const { subject = '' } = subjectList[subjectIndex] || {}
- // 当已存在数据的情况下,不用请求接口数据
- const { learningScore = 0, knowledgePointProportionList = [], otherKnowledgePointProportionList = [], moduleList = [] } = subjectList[subjectIndex] || {}
- if (learningScore && knowledgePointProportionList.length && otherKnowledgePointProportionList.length && moduleList.length) {
- this.drawRingCanvasOfKnowledgePoint()
- if (isFn(cb)) cb()
- return
- }
- post('/api/curator/curator/V1/weeklyReport', { vipId, subject }, 0, postData).then(res => {
- const {
- learningScore = 0,
- totalKnowledgeNum = 0,
- masterWellKnowledgeNum = 0,
- masterInfirmlyKnowledgeNum = 0,
- notMasteredKnowledgeNum = 0,
- knowledgePointProportionList = [],
- otherKnowledgePointProportionList = [],
- moduleList = []
- } = res.data || {}
- // 设置默认知识点掌握情况及对应的数量
- // const {
- // knowledgePointGoodNumber = 0,
- // knowledgePointGeneralNumber = 0,
- // knowledgePointPoorNumber = 0
- // } = (list => {
- // let knowledgePointGoodNumber = 0
- // let knowledgePointGeneralNumber = 0
- // let knowledgePointPoorNumber = 0
- // for (const v of list) {
- // const { mastery = 0 } = v
- // const num = ~~(mastery * 100)
- // if (num >= 85) {
- // knowledgePointGoodNumber++
- // } else if (num < 85 && num >= 60) {
- // knowledgePointGeneralNumber++
- // } else {
- // knowledgePointPoorNumber++
- // }
- // }
- // return {
- // knowledgePointGoodNumber,
- // knowledgePointGeneralNumber,
- // knowledgePointPoorNumber
- // }
- // })(knowledgePointMasteryList)
- // 知识点掌握情况
- const knowledgePointMasteryDetail = learningScore >= 95 ? '优秀' : learningScore >= 85 ? '良好' : learningScore >= 75 ? '一般' : '欠佳'
- const temp = {}
- temp[`navList[${navIndex}].isLoaded`] = true
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].learningScore`] = learningScore
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePointProportionList`] = knowledgePointProportionList
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].otherKnowledgePointProportionList`] = otherKnowledgePointProportionList
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].moduleList`] = moduleList
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePointMasteryDetail`] = knowledgePointMasteryDetail
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].totalKnowledgeNum`] = totalKnowledgeNum
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePointGoodNumber`] = masterWellKnowledgeNum
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePointGeneralNumber`] = masterInfirmlyKnowledgeNum
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePointPoorNumber`] = notMasteredKnowledgeNum
- this.setData(temp)
- this.drawRingCanvasOfKnowledgePoint()
- if (isFn(cb)) cb()
- }).catch (() => {
- const temp = {}
- temp[`navList[${navIndex}].isLoaded`] = true
- this.setData(temp)
- if (isFn(cb)) cb()
- })
- },
- /**
- * 获取月报数据
- */
- getMonthReport: function (cb) {
- const postData = { fn: this.getMonthReport, param: { ...arguments } }
- const { navList = [], navIndex = 0, options = {} } = this.data
- const { vipId = '' } = options
- // 当已存在数据的情况下,不用请求接口数据
- const { subjectList = [] } = navList[navIndex] || {}
- if (subjectList.length) {
- if (isFn(cb)) cb()
- return
- }
- post('/api/curator/curator/V1/monthlyReport', { vipId }, 0, postData).then(res => {
- const {
- learningScore = 0,
- lastMonth = '',
- increasedScore = 0,
- transcendedStudentProportion = 0,
- averageUsedTime = 0,
- subjectKnowledgeInfoList = []
- } = res.data || {}
- const temp = {}
- temp[`navList[${navIndex}].isLoaded`] = true
- temp[`navList[${navIndex}].learningScore`] = learningScore
- temp[`navList[${navIndex}].lastMonth`] = lastMonth
- temp[`navList[${navIndex}].increasedScore`] = increasedScore
- temp[`navList[${navIndex}].transcendedStudentProportion`] = transcendedStudentProportion
- temp[`navList[${navIndex}].averageUsedTime`] = averageUsedTime
- temp[`navList[${navIndex}].subjectList`] = subjectKnowledgeInfoList
- this.setData(temp)
- if (isFn(cb)) cb()
- }).catch(() => {
- const temp = {}
- temp[`navList[${navIndex}].isLoaded`] = true
- this.setData(temp)
- if (isFn(cb)) cb()
- })
- },
- /**
- * 获取学情初始数据
- */
- getDataOfSituation: function (cb) {
- const postData = { fn: this.getDataOfSituation, param: { ...arguments } }
- const { navList = [], navIndex = 0, options = {} } = this.data
- const { vipId = '' } = options
- // 当已存在数据的情况下,不用请求接口数据
- const { subjectList = [], studentName = '', studentImg = '', labels = [], overallSituation = [] } = navList[navIndex] || {}
- if (subjectList.length && studentName && studentImg && labels.length && overallSituation.length) {
- this.getSubjectOfSituation(cb)
- return
- }
- post('/api/curator/curator/V1/learningSituationAbstract', { vipId }, 0, postData).then(res => {
- const { studentName = '', studentImg = '', labels = [], overallSituation = [], subjects = [] } = res.data || {}
- const temp = {}
- temp[`navList[${navIndex}].studentName`] = studentName
- temp[`navList[${navIndex}].studentImg`] = studentImg
- temp[`navList[${navIndex}].labels`] = labels
- temp[`navList[${navIndex}].overallSituation`] = overallSituation
- temp[`navList[${navIndex}].subjects`] = subjects
- temp[`navList[${navIndex}].subjectList`] = (res => {
- const arr = []
- for (const v of res) {
- arr.push({ subject: v })
- }
- return arr
- })(subjects)
- this.setData(temp)
- if (subjects.length > 0) {
- this.getSubjectOfSituation(cb)
- } else {
- const temp = {}
- temp[`navList[${navIndex}].isLoaded`] = true
- this.setData(temp)
- if (isFn(cb)) cb()
- }
- }).catch(() => {
- const temp = {}
- temp[`navList[${navIndex}].isLoaded`] = true
- this.setData(temp)
- if (isFn(cb)) cb()
- })
- },
- /**
- * 获取单科学情详情
- */
- getSubjectOfSituation: function (cb) {
- const postData = { fn: this.getSubjectOfSituation, param: { ...arguments } }
- const { navList = [], navIndex = 0, options = {} } = this.data
- const { vipId = '' } = options
- const { subjectIndex = 0, subjectList = [] } = navList[navIndex] || {}
- const { subject = '', semester = 0, grade = '' } = subjectList[subjectIndex] || {}
- // 当已存在数据的情况下,不用请求接口数据
- const { knowledge = {}, knowledgePoint = [], homeworkAccuracyRateList = [] } = subjectList[subjectIndex] || {}
- if (!isEmptyObj(knowledge) && knowledgePoint.length && homeworkAccuracyRateList.length) {
- this.drawRadarCanvasOfKnowledge()
- this.drawRingCanvasOfKnowledgePointMastery()
- if (isFn(cb)) cb()
- return
- }
- post('/api/curator/curator/V1/learningSituationDetailNew', { vipId, subject, semester, grade }, 0, postData).then(res => {
- const { knowledge = '', knowledgePoint = '', homeworkAccuracyRateList = [] } = res.data
- const temp = {}
- temp[`navList[${navIndex}].isLoaded`] = true
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledge`] = knowledge
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePoint`] = knowledgePoint
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].homeworkAccuracyRateList`] = homeworkAccuracyRateList
- this.setData(temp)
- this.drawRadarCanvasOfKnowledge()
- this.drawRingCanvasOfKnowledgePointMastery()
- if (isFn(cb)) cb()
- }).catch(() => {
- const temp = {}
- temp[`navList[${navIndex}].isLoaded`] = true
- this.setData(temp)
- if (isFn(cb)) cb()
- })
- },
- /**
- * 选择切换项
- */
- selectNavIndexCtl:throttle(function (e) {
- const { index } = e.currentTarget.dataset
- const { navIndex = 0, navList = [] } = this.data || {}
- const { subjectList = [] } = navList[index] || {}
- if (navIndex == index) return
- const temp = {}
- temp[`navIndex`] = index
- this.setData(temp)
- this.getData()
- },500),
- /**
- * 选择切换学情科目项
- */
- selectSubjectIndexCtl: function (e) {
- const { index } = e.currentTarget.dataset
- const { navList = [], navIndex = 0 } = this.data
- const { subjectList = [], subjectIndex = 0 } = navList[navIndex] || {}
- if (subjectIndex == index) return
- const temp = {}
- temp[`navList[${navIndex}].subjectIndex`] = index
- this.setData(temp)
- this.getData()
- },
- /**
- * 获取容器高度,使页面滚动到容器底部
- */
- pageScrollToBottom: function () {
- wx.createSelectorQuery().select('#wrapper').boundingClientRect(function (rect) {
- wx.pageScrollTo({
- scrollTop: rect.bottom
- })
- }).exec()
- },
- /**
- * 切换显示未掌握知识点
- */
- toggleShowNoknowledgePointCtl: function (e) {
- const { index = 0 } = e.currentTarget.dataset
- const { navList = [], navIndex = 0 } = this.data
- const { subjectList = [], subjectIndex = 0 } = navList[navIndex] || {}
- const { knowledgePoint = [] } = subjectList[subjectIndex] || {}
- const { isShowNoknowledgePoint = false } = knowledgePoint[index] || {}
- const temp = {}
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].knowledgePoint[${index}].isShowNoknowledgePoint`] = !isShowNoknowledgePoint
- this.setData(temp)
- },
- /**
- * 切换显示学习建议
- */
- toggleLeaningSuggestCtl: function () {
- const { navList = [], navIndex = 0 } = this.data
- const { subjectList = [], subjectIndex = 0 } = navList[navIndex] || {}
- const { isShowLeaningSuggest = false } = subjectList[subjectIndex] || {}
- const temp = {}
- temp[`navList[${navIndex}].subjectList[${subjectIndex}].isShowLeaningSuggest`] = !isShowLeaningSuggest
- this.setData(temp)
- },
- /**
- * 绘制知识点圆环
- */
- drawRingCanvasOfKnowledgePoint: function () {
- const { navList = [], navIndex = 0 } = this.data
- const { subjectList = [], subjectIndex = 0 } = navList[navIndex] || {}
- const { knowledgePointProportionList = [] } = subjectList[subjectIndex] || {}
- if (knowledgePointProportionList.length === 0) return
- this.selectComponent('#knowledgePointRingCanvas').init(function (canvas, width, height) {
- // 数据
- const data = (list => {
- const arr = []
- for (const v of list) {
- const { knowledgeName = '', proportion = 0 } = v
- arr.push({
- const: 'const',
- type: knowledgeName,
- percent: ~~(+proportion * 100)
- })
- }
- return arr
- })(knowledgePointProportionList)
- // 生成画布
- const chart = new F2.Chart({
- el: canvas,
- width,
- height
- })
- chart.source(data)
- chart.coord('polar', {
- transposed: true,
- radius: 0.9,
- innerRadius: 0.5
- })
- chart.axis(false)
- chart.legend(false)
- chart.tooltip(true)
- chart.interval().position('const*percent').adjust('stack').color('type', [
- `rgba(${greenRGB}, 1)`,
- `rgba(${yellowRGB}, 1)`,
- `rgba(${redRGB}, 1)`,
- `rgba(${purpleRGB}, 1)`])
- chart.pieLabel({
- sidePadding: 30,
- activeShape: true,
- label1: function label1(data) {
- return {
- text: data.percent + '%',
- fill: `rgba(${blueRGB}, 1)`,
- fontWeight: 'bold'
- };
- },
- label2: function label2(data) {
- return {
- text: data.type.length > 3 ? data.type.substring(0, 3) + '...' : data.type,
- fill: `rgba(${blackRGB}, 1)`,
- fontWeight: 'bold'
- };
- },
- onClick: function onClick(e) {
- const { data = {} } = e
- console.log(data)
- }
- });
- chart.render()
- return chart
- })
- },
- /**
- * 绘制雷达图
- */
- drawRadarCanvasOfKnowledge: function () {
- const { navList = [], navIndex = 0 } = this.data
- const { subjectList = [], subjectIndex = 0, accuracyArray = [] } = navList[navIndex] || {}
- const { knowledge = {} } = subjectList[subjectIndex] || {}
- if (isEmptyObj(knowledge)) return
- const Fn = (obj, canvasId, arr) => {
- if (!canvasId) return
- const { dimension = [], thisMonthTrueCount = [], overallAvgTrueCount = [] } = obj
- new wxCharts({
- animation: true,
- canvasId,
- type: 'radar',
- categories: dimension,
- series: ((arr, data) => {
- for (let i in arr) {
- arr[i].data = data[i]
- }
- return arr
- })(arr, [overallAvgTrueCount, thisMonthTrueCount]),
- width: 300,
- height: 300,
- dataPointShape: false,
- legend: false,
- extra: {
- radar: {
- max: 100,//雷达数值的最大值
- gridColor: '#D0D5E6',
- labelColor: '#7C819D'
- }
- }
- })
- }
- Fn(knowledge, 'knowledgeRadarCanvas', accuracyArray)
- },
- /**
- * 绘制圆环进度条
- */
- drawRingCanvasOfKnowledgePointMastery: function () {
- const { navList = [], navIndex = 0 } = this.data
- const { subjectList = [], subjectIndex = 0, accuracyArray = [] } = navList[navIndex] || {}
- const { knowledgePoint = {} } = subjectList[subjectIndex] || {}
- if (isEmptyObj(knowledgePoint)) return
- const Fn = (canvasId = '', percent = 0) => {
- if (!canvasId) return
-
- // 计算圆环颜色
- const color = percent < 15||percent==15 ? greenRGB : percent < 40||percent==40 ? yellowRGB : redRGB
- // 配置项参数
- const startColor = `rgba(${color}, 1)`
- const endColor = `rgba(${color}, 1)`
- const baseColor = `rgba(${grayRGB}, 1)`
- const width = 29
- const height = 29
- const minWidth = 25
- const baseLineWidth = 6
- const actLineWidth = 8
- const actLineCap = 'round'
- const fontSize = 12
- const textAlign = 'center'
- const baseLine = 'middle'
- const fontColor = `rgba(${blackRGB}, 1)`
- // 初始化画布
- const ctx = wx.createCanvasContext(canvasId)
- const grd = ctx.createLinearGradient(width / 2, 0, width / 2, height)
- grd.addColorStop(0, endColor)
- grd.addColorStop(1, startColor)
- // 圆环边框
- ctx.beginPath()
- ctx.arc(width, height, minWidth, 0, 2 * Math.PI)
- ctx.setStrokeStyle(baseColor)
- ctx.setLineWidth(baseLineWidth)
- ctx.stroke()
- // 圆环
- if (percent > 0) {
- ctx.beginPath()
- ctx.arc(width, height, minWidth, -Math.PI / 2, Math.PI * 2 * percent / 100 - Math.PI / 2, false)
- ctx.setStrokeStyle(grd)
- ctx.setLineWidth(actLineWidth)
- ctx.setLineCap(actLineCap)
- ctx.stroke()
- }
- // 占比值
- ctx.setFontSize(fontSize)
- ctx.setTextAlign(textAlign)
- ctx.setTextBaseline(baseLine)
- ctx.setFillStyle(fontColor)
- ctx.fillText(`${percent}%`, width, height)
- ctx.draw()
- }
- for (let i in knowledgePoint) {
- Fn(`knowledgePointMasteryRingCanvas-${i}`, ~~knowledgePoint[i].percent)
- }
- },
- /**
- * 返回上一页
- */
- backBook:function(){
- wx.navigateBack({
- delta: 1,
- })
- }
- })
|