index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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. Toast.clear()
  277. let $res = res.data;
  278. $this.record = $res.data
  279. $this.record.play_time = formatSeconds($this.record.play_time)
  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. },
  303. (err) => {
  304. Toast.fail('错误代码:' + res.code + ',联系客服')
  305. }
  306. )
  307. }, 800)
  308. },
  309. get_game_line($record_id) {
  310. let $params = {
  311. 'game_record_id': $record_id,
  312. }
  313. gameLineChart($params).then((res) => {
  314. let $res = res.data;
  315. let $option = {}
  316. setTimeout(() => {
  317. let $line_data = $res.data.line
  318. if ($this.is_cut) {
  319. //需要截断数据
  320. let $more_than_count = $line_data.length % $this.data_section
  321. let i = 0
  322. //根据多出来的数 删除结尾得数量
  323. for (i = 0; i < $more_than_count; i++) {
  324. $line_data.pop()
  325. }
  326. $this.data_lines = []
  327. //获取每一组得数据长度
  328. let $item_len = $line_data.length / $this.data_section
  329. for (i = 0; i < $this.data_section; i++) {
  330. $this.data_lines.push($line_data.slice(i * $item_len, (i + 1) * $item_len))
  331. }
  332. $option = util.getLineOption($this.data_lines[0], [0])
  333. } else {
  334. $option = util.getLineOption($line_data, [0])
  335. }
  336. att_charts.setOption($option)
  337. }, 800)
  338. },
  339. (err) => {
  340. Toast.fail('错误代码:' + res.code + ',联系客服')
  341. })
  342. },
  343. to_game_records() {
  344. mpvue.navigateTo({
  345. url: "/pages/game_record/main"
  346. })
  347. },
  348. // 切换时间查看线 数据
  349. changeMin($e) {
  350. let $index = $e.mp.detail.name
  351. let $option = util.getLineOption($this.data_lines[$index], [0])
  352. att_charts.setOption($option)
  353. }
  354. }
  355. ,
  356. mounted() {
  357. $this.userinfo = wx.getStorageSync('userinfo')
  358. //设置游戏时间长
  359. wx.removeStorageSync('played_time')
  360. $this.get_report($this.record_id)
  361. $this.get_game_line($this.record_id)
  362. },
  363. created() {
  364. $this = this;
  365. },
  366. onLoad(options) {
  367. $this.record_id = options.id ? options.id : game_store.getters.getGameRecordId()
  368. }
  369. }
  370. </script>
  371. <style scoped>
  372. /* 头部椭圆 */
  373. .head {
  374. width: 442px;
  375. height: 385px;
  376. background-color: #4b3ab0;
  377. border-radius: 50%;
  378. position: absolute;
  379. left: -34px;
  380. top: -252px;
  381. z-index: -1;
  382. }
  383. /* 头部个人信息 */
  384. image.boy {
  385. width: 110px;
  386. height: 111px;
  387. position: absolute;
  388. left: 225px;
  389. top: 45px;
  390. }
  391. .user {
  392. width: 100%;
  393. }
  394. .user .up {
  395. width: 100%;
  396. height: 40px;
  397. margin-top: 9px;
  398. display: flex;
  399. align-items: center;
  400. justify-content: space-between;
  401. color: #fff;
  402. }
  403. .user .up .left {
  404. height: 40px;
  405. display: flex;
  406. align-items: center;
  407. justify-content: start;
  408. }
  409. .user .up .left image {
  410. width: 40px;
  411. height: 40px;
  412. margin-left: 17px;
  413. margin-right: 8px;
  414. }
  415. .user .up .left view {
  416. height: 40px;
  417. display: flex;
  418. flex-direction: column;
  419. align-items: flex-start;
  420. justify-content: space-between;
  421. }
  422. .user .up .left view text:first-child {
  423. font-size: 15px;
  424. font-weight: bold;
  425. }
  426. .user .up .left view text:last-child {
  427. font-size: 13px;
  428. }
  429. .user .up .right {
  430. height: 40px;
  431. }
  432. .user .up .right image {
  433. width: 14px;
  434. height: 15px;
  435. vertical-align: middle;
  436. margin-right: 4px;
  437. }
  438. .user .up .right text {
  439. font-size: 12px;
  440. text-decoration: underline;
  441. margin-right: 10px;
  442. }
  443. .user .down {
  444. width: 100%;
  445. height: 82px;
  446. display: flex;
  447. flex-direction: column;
  448. align-items: center;
  449. justify-content: start;
  450. }
  451. .user .down view:first-child {
  452. font-size: 45px;
  453. color: #FFD800;
  454. font-weight: bold;
  455. }
  456. .user .down view:last-child {
  457. font-size: 10px;
  458. color: #C7C4D8;
  459. margin-top: -5px;
  460. }
  461. /* 详细数据 */
  462. .detail {
  463. width: 100%;
  464. height: 102px;
  465. /*display: flex;*/
  466. /*align-items: center;*/
  467. /*justify-content: space-around;*/
  468. }
  469. .detail view {
  470. display: flex;
  471. flex-direction: column;
  472. align-items: center;
  473. justify-content: space-around;
  474. color: #6C6C6C;
  475. font-size: 10px;
  476. }
  477. .detail view view:first-child {
  478. color: #000;
  479. font-size: 30px;
  480. }
  481. /* 小标题 */
  482. .bar {
  483. width: 100%;
  484. height: 10px;
  485. display: flex;
  486. align-items: center;
  487. justify-content: space-between;
  488. padding: 0 7px;
  489. box-sizing: border-box;
  490. margin: 11px 0;
  491. }
  492. .bar view {
  493. display: flex;
  494. align-items: center;
  495. justify-content: start;
  496. }
  497. .conclution {
  498. width: 100%;
  499. padding: 5px 19px 8px;
  500. font-size: 12px;
  501. color: #6c6c6c;
  502. box-sizing: border-box;
  503. }
  504. .conclution_title {
  505. font-weight: 600;
  506. color: #000;
  507. }
  508. .bar .line {
  509. width: 4px;
  510. height: 15px;
  511. background-color: #5D4DB8;
  512. margin-right: 7px;
  513. }
  514. .bar .title {
  515. color: #010101;
  516. font-size: 15px;
  517. }
  518. /* 图表 */
  519. #mychart-dom-multi-line {
  520. width: 360px;
  521. height: 193px;
  522. }
  523. .chart {
  524. margin: 0 auto;
  525. width: 360px;
  526. height: 193px;
  527. background: #f3f3f3;
  528. opacity: 0.6;
  529. border-radius: 10px;
  530. box-shadow: 0px 6px 11px #dadada;
  531. }
  532. /*雷达图*/
  533. .radar_chart {
  534. margin: 0 auto;
  535. width: 360px;
  536. height: 293px;
  537. background: #f3f3f3;
  538. opacity: 0.6;
  539. border-radius: 10px;
  540. box-shadow: 0px 6px 11px #dadada;
  541. }
  542. .hight_pie_chart {
  543. margin: 0 auto;
  544. width: 100px;
  545. height: 100px;
  546. background: #f3f3f3;
  547. /*border-radius: 10px;*/
  548. /*box-shadow: 0px 6px 11px #dadada;*/
  549. }
  550. /* 核销详情 */
  551. .sheet {
  552. color: #6D6D6D;
  553. font-size: 12px;
  554. display: flex;
  555. padding: 0 16px;
  556. box-sizing: border-box;
  557. }
  558. .sheet .left,
  559. .sheet .right {
  560. height: 95px;
  561. display: flex;
  562. flex-direction: column;
  563. align-items: flex-start;
  564. justify-content: space-between;
  565. }
  566. .sheet .left {
  567. width: 195px;
  568. }
  569. .content_card {
  570. border-radius: 10px;
  571. box-shadow: 0px 6px 11px #dadada;
  572. }
  573. </style>