tabbarPage.vue 1.79 KB
Newer Older
程默 committed
1 2 3 4 5 6
<!--
 tabbar
-->
<template>
  <div>
    <web-view :src="pageUrl" @error="handleError"></web-view>
程默 committed
7 8
    <div style="width: 100%;height: 90vh;display: flex;justify-content: center;align-items: center;"
    >
程默 committed
9 10 11 12 13 14 15 16 17 18
      <van-loading size="40px" type="spinner"></van-loading>
    </div>
  </div>
</template>

<script>
import {
  getUrlofLink,
  checkTabbarPage,
} from "../utils/mayi.js";
程默 committed
19 20
import { serialize} from "@/utils/index";

程默 committed
21 22 23 24 25 26 27 28 29 30 31 32 33
export default {
  props: {
    index: {
      type: Number,
      default: 1,
    },
  },
  data() {
    return {
      link: process.env.BASE_URL,
      page: "/",
      params: "?mixid=" + this.$store.state.mixid,
      ss: "",
程默 committed
34
      timestamp:""
程默 committed
35 36 37 38 39 40 41 42
    };
  },
  computed: {
    pageUrl() {
      return (
        this.link +
        this.page +
        this.params +
程默 committed
43
        `&native_test=1&tabbar=${this.index}&location_obj=${wx.getStorageSync(
程默 committed
44 45
          "location"
        )}` +
程默 committed
46
        this.ss+this.timestamp
程默 committed
47 48 49 50 51 52
      );
    },
  },
  onLoad(options) {
    let ss = wx.getStorageSync("sessionid");
    this.ss = ss ? `&sessionid=${ss}` : "";
程智春 committed
53
    
程默 committed
54 55 56
    if (!ss) {
      this.params += this.params.includes("logOut") ? "" : "&logOut=true";
    }
程智春 committed
57 58 59 60

    if(wx.getStorageSync("workBox")){
      this.params += `&workBox=${wx.getStorageSync("workBox")}`
    }
程默 committed
61 62 63 64 65 66 67
    // tabbar 跳转
    let homeIndex = checkTabbarPage("/");
    homeIndex != 0 && homeIndex == this.index && (this.index = 0);
    if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
      this.page = getUrlofLink(
        this.mpApp.globalData.footerVal.componentData.list[this.index].link
      );
程默 committed
68 69
      let query=serialize(options)
      this.params+=query?'&'+query:''
程默 committed
70 71 72 73 74 75 76 77 78 79 80
    }
  },
  methods: {
    handleError(data) {
      wx.showLoading({
        title: "网页加载失败 请右上角刷新",
      });
    },
  },
};
</script>