index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <div class="reportContainer">
  3. <div v-if="data_length>=15">
  4. <web-view :src="webUrl" @load="webLoading"></web-view>
  5. </div>
  6. <div v-else style="padding:400rpx 20rpx 0 20rpx;">
  7. 本次训练有效数据不足,无法分析并生成有效报告,请确保训练时脑机佩戴正确,网络状况良好,且训练时长不能太短。
  8. </div>
  9. <van-toast id="van-toast"/>
  10. </div>
  11. </template>
  12. <script>
  13. import store from '@/store/index';
  14. import game_store from "@/store/game";
  15. var $this;
  16. export default {
  17. name: "reportContainer",
  18. data() {
  19. return {
  20. report_id: 0,
  21. data_length: 15,
  22. webUrl: ""
  23. }
  24. },
  25. methods: {
  26. webLoading(params) {
  27. console.log("报告页面web-view加载完成")
  28. wx.hideLoading();
  29. }
  30. },
  31. created() {
  32. $this = this;
  33. },
  34. onLoad(options) {
  35. wx.showLoading({
  36. title: "加载中",
  37. mask: true,
  38. duration: 5000
  39. })
  40. $this.report_id = options.id
  41. ? options.id
  42. : game_store.getters.getGameRecordId();
  43. if (options.size && options.size > 0) {
  44. $this.data_length = options.size;
  45. }
  46. if($this.data_length < 15){
  47. wx.hideLoading();
  48. } else {
  49. let mode = options.mode ? options.mode : wx.getStorageSync('report_mode')
  50. let $userinfo = wx.getStorageSync("userinfo")
  51. $this.webUrl = `${process.env.REPORT_URI}?mode=${mode}&token=${store.getters.get_token()}&record_id=${options.id}&nickName=${$userinfo.user_name}&mp=1`
  52. console.log($this.webUrl);
  53. }
  54. },
  55. onUnload(){
  56. wx.removeStorageSync("mode")
  57. }
  58. }
  59. </script>