index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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. <view class="bar">
  31. <view>
  32. <view class="line"></view>
  33. <view class="title">数据详情</view>
  34. </view>
  35. </view>
  36. <view class="detail">
  37. <view>
  38. <view>{{ record.att_max }}</view>
  39. <view>专注力最高分</view>
  40. <!-- <view>{{ record.interfere }} </view>
  41. <view>被干扰次数</view> -->
  42. </view>
  43. <view>
  44. <view>{{ record.scope_diff }}</view>
  45. <view>专注力广度</view>
  46. </view>
  47. </view>
  48. <view class="bar">
  49. <view>
  50. <view class="line"></view>
  51. <view class="title">基本脑波</view>
  52. </view>
  53. </view>
  54. <view class="chart">
  55. <mpvue-echarts
  56. :echarts="echarts"
  57. :onInit="attCharts"
  58. canvasId="demo-canvas"
  59. />
  60. </view>
  61. <view
  62. class="section_container"
  63. v-if="is_cut"
  64. >
  65. <van-tabs
  66. :active="0"
  67. color="#6858C4"
  68. type="card"
  69. @change="changeMin"
  70. >
  71. <van-tab
  72. :name="index"
  73. :title="(5*index)+'-'+(5*(index+1)) + '分钟'"
  74. v-for="(section,index) in data_section"
  75. :key="index"
  76. ></van-tab>
  77. </van-tabs>
  78. </view>
  79. <view class="conclution"> <text class="conclution_title">分析</text>: {{ record.content }}</view>
  80. <view class="conclution"> <text class="conclution_title">建议</text>: {{ record.advise }}</view>
  81. <view class="bar">
  82. <view>
  83. <view class="line"></view>
  84. <view class="title">核销详情</view>
  85. </view>
  86. </view>
  87. <view class="sheet">
  88. <view class="left">
  89. <view>专注力训练设备: {{ record.name }}</view>
  90. <view>核销方式:
  91. <text v-if="record.consumption_type==1">次卡</text>
  92. <text v-if="record.consumption_type==2">时间卡</text>
  93. </view>
  94. <view>会员游玩时间: {{ record.play_time }}</view>
  95. </view>
  96. <view class="right">
  97. <view>专注力训练时长: {{ record.play_time }}</view>
  98. </view>
  99. </view>
  100. <van-toast id="van-toast" />
  101. </div>
  102. </template>
  103. <script>
  104. import mpvueEcharts from "mpvue-echarts";
  105. import echarts from "../../../static/echarts.min";
  106. import util, { formatSeconds } from "../../utils/index";
  107. import { gameDetail, gameLineChart } from "../../requests/game";
  108. import game_store from "../../store/game";
  109. import Toast from "../../../static/vant/toast/toast";
  110. var att_charts, $this;
  111. // 大脑图表初始化
  112. function initAttChart(canvas, width, height) {
  113. att_charts = echarts.init(canvas, null, {
  114. width: width,
  115. height: height,
  116. });
  117. canvas.setChart(att_charts);
  118. var option = util.getLineOption([0], [0]); // ECharts 配置项
  119. att_charts.setOption(option);
  120. return att_charts; // 返回 chart 后可以自动绑定触摸操作
  121. }
  122. export default {
  123. name: "index_container",
  124. components: {
  125. mpvueEcharts,
  126. },
  127. data() {
  128. return {
  129. // 0:未选择 1:时间 2:次数
  130. // 折线图
  131. attCharts: initAttChart,
  132. echarts,
  133. record: {},
  134. userinfo: {},
  135. record_id: 0,
  136. //是否截断数据
  137. is_cut: false,
  138. //数据截断数
  139. data_section: 0,
  140. //数据集合
  141. data_lines: [],
  142. };
  143. },
  144. methods: {
  145. // 获取游戏报告
  146. get_report($record_id) {
  147. $this.record = {};
  148. Toast.loading({
  149. forbidClick: true,
  150. message: "加载中",
  151. duration: 0,
  152. });
  153. setTimeout(() => {
  154. gameDetail($record_id).then(
  155. (res) => {
  156. console.log("get_game_detail", res);
  157. Toast.clear();
  158. let $res = res.data;
  159. $this.record = $res.data;
  160. //5分钟阶段
  161. let $five_min = 5 * 60;
  162. $this.is_cut = $this.record.play_time > $five_min;
  163. if ($this.is_cut) {
  164. //截断得数量
  165. $this.data_section = Math.ceil(
  166. $this.record.play_time / $five_min
  167. );
  168. }
  169. $this.record.play_time = formatSeconds($this.record.play_time);
  170. },
  171. (err) => {
  172. Toast.fail("错误代码:" + res.code + ",联系客服");
  173. }
  174. );
  175. }, 800);
  176. },
  177. get_game_line($record_id) {
  178. let $params = {
  179. game_record_id: $record_id,
  180. };
  181. gameLineChart($params).then(
  182. (res) => {
  183. let $res = res.data;
  184. let $option = {};
  185. setTimeout(() => {
  186. let $line_data = $res.data.line;
  187. if ($this.is_cut) {
  188. //需要截断数据
  189. let $more_than_count = $line_data.length % $this.data_section;
  190. let i = 0;
  191. //根据多出来的数 删除结尾得数量
  192. for (i = 0; i < $more_than_count; i++) {
  193. $line_data.pop();
  194. }
  195. $this.data_lines = [];
  196. //获取每一组得数据长度
  197. let $item_len = $line_data.length / $this.data_section;
  198. for (i = 0; i < $this.data_section; i++) {
  199. $this.data_lines.push(
  200. $line_data.slice(i * $item_len, (i + 1) * $item_len)
  201. );
  202. }
  203. $option = util.getLineOption($this.data_lines[0], [0]);
  204. } else {
  205. $option = util.getLineOption($line_data, [0]);
  206. }
  207. att_charts.setOption($option);
  208. }, 1000);
  209. },
  210. (err) => {
  211. Toast.fail("错误代码:" + res.code + ",联系客服");
  212. }
  213. );
  214. },
  215. to_game_records() {
  216. mpvue.navigateTo({
  217. url: "/pages/game_record/main",
  218. });
  219. },
  220. // 切换时间查看线 数据
  221. changeMin($e) {
  222. let $index = $e.mp.detail.name;
  223. let $option = util.getLineOption($this.data_lines[$index], [0]);
  224. att_charts.setOption($option);
  225. },
  226. },
  227. mounted() {
  228. $this.userinfo = wx.getStorageSync("userinfo");
  229. //设置游戏时间长
  230. wx.removeStorageSync("played_time");
  231. $this.get_report($this.record_id);
  232. $this.get_game_line($this.record_id);
  233. console.log("进来时候获取到的信息", $this.record);
  234. },
  235. created() {
  236. $this = this;
  237. },
  238. onLoad(options) {
  239. $this.record_id = options.id
  240. ? options.id
  241. : game_store.getters.getGameRecordId();
  242. },
  243. };
  244. </script>
  245. <style scoped>
  246. /* 头部椭圆 */
  247. .head {
  248. width: 442px;
  249. height: 385px;
  250. background-color: #4b3ab0;
  251. border-radius: 50%;
  252. position: absolute;
  253. left: -34px;
  254. top: -252px;
  255. z-index: -1;
  256. }
  257. /* 头部个人信息 */
  258. image.boy {
  259. width: 110px;
  260. height: 111px;
  261. position: absolute;
  262. left: 225px;
  263. top: 45px;
  264. }
  265. .user {
  266. width: 100%;
  267. }
  268. .user .up {
  269. width: 100%;
  270. height: 40px;
  271. margin-top: 9px;
  272. display: flex;
  273. align-items: center;
  274. justify-content: space-between;
  275. color: #fff;
  276. }
  277. .user .up .left {
  278. height: 40px;
  279. display: flex;
  280. align-items: center;
  281. justify-content: start;
  282. }
  283. .user .up .left image {
  284. width: 40px;
  285. height: 40px;
  286. margin-left: 17px;
  287. margin-right: 8px;
  288. }
  289. .user .up .left view {
  290. height: 40px;
  291. display: flex;
  292. flex-direction: column;
  293. align-items: flex-start;
  294. justify-content: space-between;
  295. }
  296. .user .up .left view text:first-child {
  297. font-size: 15px;
  298. font-weight: bold;
  299. }
  300. .user .up .left view text:last-child {
  301. font-size: 13px;
  302. }
  303. .user .up .right {
  304. height: 40px;
  305. }
  306. .user .up .right image {
  307. width: 14px;
  308. height: 15px;
  309. vertical-align: middle;
  310. margin-right: 4px;
  311. }
  312. .user .up .right text {
  313. font-size: 12px;
  314. text-decoration: underline;
  315. margin-right: 10px;
  316. }
  317. .user .down {
  318. width: 100%;
  319. height: 82px;
  320. display: flex;
  321. flex-direction: column;
  322. align-items: center;
  323. justify-content: start;
  324. }
  325. .user .down view:first-child {
  326. font-size: 45px;
  327. color: #ffd800;
  328. font-weight: bold;
  329. }
  330. .user .down view:last-child {
  331. font-size: 10px;
  332. color: #c7c4d8;
  333. margin-top: -5px;
  334. }
  335. /* 详细数据 */
  336. .detail {
  337. width: 100%;
  338. height: 102px;
  339. display: flex;
  340. align-items: center;
  341. justify-content: space-around;
  342. }
  343. .detail view {
  344. display: flex;
  345. flex-direction: column;
  346. align-items: center;
  347. justify-content: space-around;
  348. color: #6c6c6c;
  349. font-size: 10px;
  350. }
  351. .detail view view:first-child {
  352. color: #000;
  353. font-size: 30px;
  354. }
  355. /* 小标题 */
  356. .bar {
  357. width: 100%;
  358. height: 10px;
  359. display: flex;
  360. align-items: center;
  361. justify-content: space-between;
  362. padding: 0 7px;
  363. box-sizing: border-box;
  364. margin: 11px 0;
  365. }
  366. .bar view {
  367. display: flex;
  368. align-items: center;
  369. justify-content: start;
  370. }
  371. .conclution {
  372. width: 100%;
  373. padding: 5px 19px 8px;
  374. font-size: 12px;
  375. color: #6c6c6c;
  376. box-sizing: border-box;
  377. }
  378. .conclution_title {
  379. font-weight: 600;
  380. color: #000;
  381. }
  382. .bar .line {
  383. width: 4px;
  384. height: 15px;
  385. background-color: #5d4db8;
  386. margin-right: 7px;
  387. }
  388. .bar .title {
  389. color: #010101;
  390. font-size: 15px;
  391. }
  392. /* 图表 */
  393. #mychart-dom-multi-line {
  394. width: 360px;
  395. height: 193px;
  396. }
  397. .chart {
  398. margin: 0 auto;
  399. width: 360px;
  400. height: 193px;
  401. background: #f3f3f3;
  402. opacity: 0.6;
  403. border-radius: 10px;
  404. box-shadow: 0px 6px 11px #dadada;
  405. }
  406. /* 核销详情 */
  407. .sheet {
  408. color: #6d6d6d;
  409. font-size: 12px;
  410. display: flex;
  411. padding: 0 16px;
  412. box-sizing: border-box;
  413. }
  414. .sheet .left,
  415. .sheet .right {
  416. height: 95px;
  417. display: flex;
  418. flex-direction: column;
  419. align-items: flex-start;
  420. justify-content: space-between;
  421. }
  422. .sheet .left {
  423. width: 195px;
  424. }
  425. </style>