index.vue 16 KB

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