index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. <template>
  2. <div id="report_container">
  3. <view class="head"></view>
  4. <img class="boy" src="https://img.shuimuai.com/m_sign_chengji_boy%402x.png"/>
  5. <view class="user">
  6. <view class="up">
  7. <view class="left">
  8. <img :src="userinfo.portrait"/>
  9. <view>
  10. <text>{{ record.user_name }}</text>
  11. <text>{{ userinfo.level_name }}</text>
  12. </view>
  13. </view>
  14. <view class="right" @click="to_game_records">
  15. <img src="https://img.shuimuai.com/m_icon_chengji%402x.png"/>
  16. <text>成绩记录</text>
  17. </view>
  18. </view>
  19. <view class="down">
  20. <view>{{ record.att_average }}</view>
  21. <view>专注力得分</view>
  22. </view>
  23. </view>
  24. <!-- 训练时长和训练设备-->
  25. <view class="po1 padding-lr margin-top-xl">
  26. <van-row>
  27. <van-col span="11">
  28. <view>
  29. <text>训练时长</text>
  30. <text class="text-bold text-xl"> &nbsp; {{ record.play_time }}</text>
  31. </view>
  32. </van-col>
  33. <van-col span="11" offset="2">
  34. <view>
  35. <text>训练设备</text>
  36. <text class="text-bold text-xl">&nbsp; {{ record.name }}</text>
  37. </view>
  38. </van-col>
  39. </van-row>
  40. </view>
  41. <view>
  42. <van-divider contentPosition="left" borderColor="#E98F36">
  43. <van-image src="https://img.shuimuai.com/line.png" alt="" width="40" height="40"></van-image>
  44. </van-divider>
  45. </view>
  46. <!-- 专注力维持区间、受干扰次数,专注力最大爆发值、专注力启动时长-->
  47. <view class="margin-tb">
  48. <van-row>
  49. <van-col span="16">
  50. <van-row>
  51. <van-col span="12">
  52. <view class="detail">
  53. <view>
  54. <view>{{ record.scope_diff }}</view>
  55. <view>专注力维持区间</view>
  56. </view>
  57. </view>
  58. </van-col>
  59. <van-col span="12">
  60. <view class="detail">
  61. <view>
  62. <view>{{ record.interfere }}</view>
  63. <view>受干扰次数</view>
  64. </view>
  65. </view>
  66. </van-col>
  67. </van-row>
  68. <van-row>
  69. <van-col span="12">
  70. <view class="detail">
  71. <view>
  72. <view>{{ record.burst }}</view>
  73. <view>专注力最大爆发值</view>
  74. </view>
  75. </view>
  76. </van-col>
  77. <van-col span="12">
  78. <view class="detail">
  79. <view>
  80. <view>{{ record.start }}</view>
  81. <view>专注力启动时长</view>
  82. </view>
  83. </view>
  84. </van-col>
  85. </van-row>
  86. </van-col>
  87. <van-col span="5">
  88. <view class="text-center">
  89. <view class="hight_pie_chart">
  90. <mpvue-echarts :echarts="echarts" :onInit="hight_att_charts" canvasId="demo-canvas1"/>
  91. </view>
  92. <view class="detail">
  93. <view>
  94. <view>{{ record.height }}%</view>
  95. <view>高专注力占比</view>
  96. </view>
  97. </view>
  98. </view>
  99. </van-col>
  100. </van-row>
  101. </view>
  102. <view class="bar">
  103. <view>
  104. <view class="line"></view>
  105. <view class="title">专注力要素分析</view>
  106. </view>
  107. </view>
  108. <view class="radar_chart">
  109. <mpvue-echarts :echarts="echarts" :onInit="radar_charts" canvasId="demo-canvas2"/>
  110. </view>
  111. <view class="">
  112. <view class="bar">
  113. <view>
  114. <view class="line"></view>
  115. <view class="title">报告分析</view>
  116. </view>
  117. </view>
  118. <view class="conclution">{{ record.content }}</view>
  119. <view class="conclution">{{ record.content2 }}</view>
  120. <view class="bar">
  121. <view>
  122. <view class="line"></view>
  123. <view class="title">训练建议</view>
  124. </view>
  125. </view>
  126. <view class="conclution">{{ record.advise }}</view>
  127. </view>
  128. <view class="bar">
  129. <view>
  130. <view class="line"></view>
  131. <view class="title">专注力数值曲线</view>
  132. </view>
  133. </view>
  134. <view class="chart">
  135. <mpvue-echarts :echarts="echarts" :onInit="attCharts" canvasId="demo-canvas"/>
  136. </view>
  137. <view class="section_container" v-if="is_cut">
  138. <van-tabs
  139. :active="0"
  140. color="#6858C4"
  141. type="card"
  142. @change="changeMin"
  143. >
  144. <van-tab
  145. :name="index"
  146. :title="(5*index)+'-'+(5*(index+1)) + '分钟'" v-for="(section,index) in data_section"
  147. :key="index"></van-tab>
  148. </van-tabs>
  149. </view>
  150. <view class="cu-bar bg-white">
  151. <view class="action">
  152. <text class="cuIcon-titles text-primary"></text>
  153. <text class="">专注力数值累计比例</text>
  154. </view>
  155. </view>
  156. <view class="chart">
  157. <mpvue-echarts
  158. :echarts="echarts"
  159. :onInit="pie_charts"
  160. canvasId="demo-canvas-1"
  161. />
  162. </view>
  163. <!-- <view class="sheet">-->
  164. <!-- <view class="left">-->
  165. <!-- <view>专注力训练设备: {{ record.name }}</view>-->
  166. <!-- <view>核销方式:-->
  167. <!-- <text v-if="record.consumption_type==1">次卡</text>-->
  168. <!-- <text v-if="record.consumption_type==2">时间卡</text>-->
  169. <!-- </view>-->
  170. <!-- <view>会员游玩时间: {{ record.play_time }}</view>-->
  171. <!-- </view>-->
  172. <!-- <view class="right">-->
  173. <!-- <view>专注力训练时长: {{ record.play_time }}</view>-->
  174. <!-- </view>-->
  175. <!-- </view>-->
  176. <van-toast id="van-toast"/>
  177. </div>
  178. </template>
  179. <script>
  180. import mpvueEcharts from 'mpvue-echarts'
  181. import echarts from '../../../static/echarts.min';
  182. import util, {
  183. filterPieData,
  184. formatSeconds,
  185. getHightPieChartOption,
  186. getPieChartsOption,
  187. getRadarChartOption
  188. } from '../../utils/index'
  189. import {gameDetail, gameLineChart} from "../../requests/game";
  190. import game_store from "../../store/game";
  191. import Toast from '../../../static/vant/toast/toast';
  192. var att_charts,
  193. hight_att_pie_charts,
  194. radar_charts,
  195. $pie_charts,
  196. $this
  197. // 大脑图表初始化
  198. function initAttChart(canvas, width, height) {
  199. att_charts = echarts.init(canvas, null, {
  200. width: width,
  201. height: height
  202. });
  203. canvas.setChart(att_charts);
  204. var option = util.getLineOption([0], [0]); // ECharts 配置项
  205. att_charts.setOption(option);
  206. return att_charts; // 返回 chart 后可以自动绑定触摸操作
  207. }
  208. // 大脑图表初始化
  209. function initHightPieChart(canvas, width, height) {
  210. hight_att_pie_charts = echarts.init(canvas, null, {
  211. width: width,
  212. height: height
  213. });
  214. canvas.setChart(hight_att_pie_charts);
  215. var option = getHightPieChartOption(0); // ECharts 配置项
  216. hight_att_pie_charts.setOption(option);
  217. return hight_att_pie_charts; // 返回 chart 后可以自动绑定触摸操作
  218. }
  219. // 大脑图表初始化
  220. function initRadarChart(canvas, width, height) {
  221. radar_charts = echarts.init(canvas, null, {
  222. width: width,
  223. height: height
  224. });
  225. canvas.setChart(radar_charts);
  226. var option = getRadarChartOption(0); // ECharts 配置项
  227. radar_charts.setOption(option);
  228. return radar_charts; // 返回 chart 后可以自动绑定触摸操作
  229. }
  230. function initPieChart(canvas, width, height) {
  231. $pie_charts = echarts.init(canvas, null, {
  232. width: width,
  233. height: height,
  234. });
  235. canvas.setChart($pie_charts);
  236. var option = getPieChartsOption(); // ECharts 配置项
  237. $pie_charts.setOption(option);
  238. return $pie_charts; // 返回 chart 后可以自动绑定触摸操作
  239. }
  240. export default {
  241. name: "index_container",
  242. components: {
  243. mpvueEcharts
  244. },
  245. data() {
  246. return {
  247. // 0:未选择 1:时间 2:次数
  248. // 折线图
  249. attCharts: initAttChart,
  250. hight_att_charts: initHightPieChart,
  251. radar_charts: initRadarChart,
  252. pie_charts: initPieChart,
  253. echarts,
  254. record: {},
  255. userinfo: {},
  256. record_id: 0,
  257. //是否截断数据
  258. is_cut: false,
  259. //数据截断数
  260. data_section: 0,
  261. //数据集合
  262. data_lines: []
  263. }
  264. },
  265. methods: {
  266. // 获取游戏报告
  267. get_report($record_id) {
  268. $this.record = {}
  269. Toast.loading({
  270. forbidClick: true,
  271. message: "加载中",
  272. duration: 0
  273. })
  274. setTimeout(() => {
  275. gameDetail($record_id).then((res) => {
  276. console.log('get_game_detail', res)
  277. Toast.clear()
  278. let $res = res.data;
  279. $this.record = $res.data
  280. let $options = getHightPieChartOption($this.record.height)
  281. hight_att_pie_charts.setOption($options)
  282. //设置雷达图
  283. $options = getRadarChartOption([
  284. $this.record.att_average,
  285. $this.record.att_scope,
  286. $this.record.att_burst,
  287. $this.record.att_interfere,
  288. $this.record.att_start,
  289. $this.record.att_height
  290. ])
  291. radar_charts.setOption($options)
  292. let $pie_data = filterPieData($this.record.level);
  293. let $pie_option = getPieChartsOption($pie_data);
  294. $pie_charts.setOption($pie_option);
  295. //5分钟阶段
  296. let $five_min = 5 * 60
  297. $this.is_cut = $this.record.play_time > $five_min
  298. if ($this.is_cut) {
  299. //截断得数量
  300. $this.data_section = Math.ceil($this.record.play_time / $five_min)
  301. }
  302. $this.record.play_time = formatSeconds($this.record.play_time)
  303. },
  304. (err) => {
  305. Toast.fail('错误代码:' + res.code + ',联系客服')
  306. }
  307. )
  308. }, 800)
  309. },
  310. get_game_line($record_id) {
  311. let $params = {
  312. 'game_record_id': $record_id,
  313. }
  314. gameLineChart($params).then((res) => {
  315. let $res = res.data;
  316. let $option = {}
  317. setTimeout(() => {
  318. let $line_data = $res.data.line
  319. if ($this.is_cut) {
  320. //需要截断数据
  321. let $more_than_count = $line_data.length % $this.data_section
  322. let i = 0
  323. //根据多出来的数 删除结尾得数量
  324. for (i = 0; i < $more_than_count; i++) {
  325. $line_data.pop()
  326. }
  327. $this.data_lines = []
  328. //获取每一组得数据长度
  329. let $item_len = $line_data.length / $this.data_section
  330. for (i = 0; i < $this.data_section; i++) {
  331. $this.data_lines.push($line_data.slice(i * $item_len, (i + 1) * $item_len))
  332. }
  333. $option = util.getLineOption($this.data_lines[0], [0])
  334. } else {
  335. $option = util.getLineOption($line_data, [0])
  336. }
  337. att_charts.setOption($option)
  338. }, 1000)
  339. },
  340. (err) => {
  341. Toast.fail('错误代码:' + res.code + ',联系客服')
  342. })
  343. },
  344. to_game_records() {
  345. mpvue.navigateTo({
  346. url: "/pages/game_record/main"
  347. })
  348. },
  349. // 切换时间查看线 数据
  350. changeMin($e) {
  351. let $index = $e.mp.detail.name
  352. let $option = util.getLineOption($this.data_lines[$index], [0])
  353. att_charts.setOption($option)
  354. }
  355. }
  356. ,
  357. mounted() {
  358. $this.userinfo = wx.getStorageSync('userinfo')
  359. //设置游戏时间长
  360. wx.removeStorageSync('played_time')
  361. $this.get_report($this.record_id)
  362. $this.get_game_line($this.record_id)
  363. },
  364. created() {
  365. $this = this;
  366. },
  367. onLoad(options) {
  368. $this.record_id = options.id ? options.id : game_store.getters.getGameRecordId()
  369. }
  370. }
  371. </script>
  372. <style scoped>
  373. /* 头部椭圆 */
  374. .head {
  375. width: 442px;
  376. height: 385px;
  377. background-color: #4b3ab0;
  378. border-radius: 50%;
  379. position: absolute;
  380. left: -34px;
  381. top: -252px;
  382. z-index: -1;
  383. }
  384. /* 头部个人信息 */
  385. image.boy {
  386. width: 110px;
  387. height: 111px;
  388. position: absolute;
  389. left: 225px;
  390. top: 45px;
  391. }
  392. .user {
  393. width: 100%;
  394. }
  395. .user .up {
  396. width: 100%;
  397. height: 40px;
  398. margin-top: 9px;
  399. display: flex;
  400. align-items: center;
  401. justify-content: space-between;
  402. color: #fff;
  403. }
  404. .user .up .left {
  405. height: 40px;
  406. display: flex;
  407. align-items: center;
  408. justify-content: start;
  409. }
  410. .user .up .left image {
  411. width: 40px;
  412. height: 40px;
  413. margin-left: 17px;
  414. margin-right: 8px;
  415. }
  416. .user .up .left view {
  417. height: 40px;
  418. display: flex;
  419. flex-direction: column;
  420. align-items: flex-start;
  421. justify-content: space-between;
  422. }
  423. .user .up .left view text:first-child {
  424. font-size: 15px;
  425. font-weight: bold;
  426. }
  427. .user .up .left view text:last-child {
  428. font-size: 13px;
  429. }
  430. .user .up .right {
  431. height: 40px;
  432. }
  433. .user .up .right image {
  434. width: 14px;
  435. height: 15px;
  436. vertical-align: middle;
  437. margin-right: 4px;
  438. }
  439. .user .up .right text {
  440. font-size: 12px;
  441. text-decoration: underline;
  442. margin-right: 10px;
  443. }
  444. .user .down {
  445. width: 100%;
  446. height: 82px;
  447. display: flex;
  448. flex-direction: column;
  449. align-items: center;
  450. justify-content: start;
  451. }
  452. .user .down view:first-child {
  453. font-size: 45px;
  454. color: #FFD800;
  455. font-weight: bold;
  456. }
  457. .user .down view:last-child {
  458. font-size: 10px;
  459. color: #C7C4D8;
  460. margin-top: -5px;
  461. }
  462. /* 详细数据 */
  463. .detail {
  464. width: 100%;
  465. height: 102px;
  466. /*display: flex;*/
  467. /*align-items: center;*/
  468. /*justify-content: space-around;*/
  469. }
  470. .detail view {
  471. display: flex;
  472. flex-direction: column;
  473. align-items: center;
  474. justify-content: space-around;
  475. color: #6C6C6C;
  476. font-size: 10px;
  477. }
  478. .detail view view:first-child {
  479. color: #000;
  480. font-size: 30px;
  481. }
  482. /* 小标题 */
  483. .bar {
  484. width: 100%;
  485. height: 10px;
  486. display: flex;
  487. align-items: center;
  488. justify-content: space-between;
  489. padding: 0 7px;
  490. box-sizing: border-box;
  491. margin: 11px 0;
  492. }
  493. .bar view {
  494. display: flex;
  495. align-items: center;
  496. justify-content: start;
  497. }
  498. .conclution {
  499. width: 100%;
  500. padding: 5px 19px 8px;
  501. font-size: 12px;
  502. color: #6c6c6c;
  503. box-sizing: border-box;
  504. }
  505. .conclution_title {
  506. font-weight: 600;
  507. color: #000;
  508. }
  509. .bar .line {
  510. width: 4px;
  511. height: 15px;
  512. background-color: #5D4DB8;
  513. margin-right: 7px;
  514. }
  515. .bar .title {
  516. color: #010101;
  517. font-size: 15px;
  518. }
  519. /* 图表 */
  520. #mychart-dom-multi-line {
  521. width: 360px;
  522. height: 193px;
  523. }
  524. .chart {
  525. margin: 0 auto;
  526. width: 360px;
  527. height: 193px;
  528. background: #f3f3f3;
  529. opacity: 0.6;
  530. border-radius: 10px;
  531. box-shadow: 0px 6px 11px #dadada;
  532. }
  533. /*雷达图*/
  534. .radar_chart {
  535. margin: 0 auto;
  536. width: 360px;
  537. height: 293px;
  538. background: #f3f3f3;
  539. opacity: 0.6;
  540. border-radius: 10px;
  541. box-shadow: 0px 6px 11px #dadada;
  542. }
  543. .hight_pie_chart {
  544. margin: 0 auto;
  545. width: 100px;
  546. height: 100px;
  547. background: #f3f3f3;
  548. /*border-radius: 10px;*/
  549. /*box-shadow: 0px 6px 11px #dadada;*/
  550. }
  551. /* 核销详情 */
  552. .sheet {
  553. color: #6D6D6D;
  554. font-size: 12px;
  555. display: flex;
  556. padding: 0 16px;
  557. box-sizing: border-box;
  558. }
  559. .sheet .left,
  560. .sheet .right {
  561. height: 95px;
  562. display: flex;
  563. flex-direction: column;
  564. align-items: flex-start;
  565. justify-content: space-between;
  566. }
  567. .sheet .left {
  568. width: 195px;
  569. }
  570. .content_card {
  571. border-radius: 10px;
  572. box-shadow: 0px 6px 11px #dadada;
  573. }
  574. </style>