tabbarPage.vue 2.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
      <van-loading size="40px" type="spinner"></van-loading>
    </div>
  </div>
</template>

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

程默 committed
22 23 24 25 26 27 28 29 30 31 32 33 34
export default {
  props: {
    index: {
      type: Number,
      default: 1,
    },
  },
  data() {
    return {
      link: process.env.BASE_URL,
      page: "/",
      params: "?mixid=" + this.$store.state.mixid,
      ss: "",
chengzhichun committed
35 36
      timestamp:"",
      isMiniPage : false
程默 committed
37 38 39 40
    };
  },
  computed: {
    pageUrl() {
41
      console.log(this.link,'******',this.page,'-------',this.params,'++++++++')
程默 committed
42 43 44 45
      return (
        this.link +
        this.page +
        this.params +
程默 committed
46
        `&native_test=1&tabbar=${this.index}&location_obj=${wx.getStorageSync(
程默 committed
47 48
          "location"
        )}` +
程默 committed
49
        this.ss+this.timestamp
程默 committed
50 51 52 53
      );
    },
  },
  onLoad(options) {
李嘉林 committed
54
    let tabIndex = this.index>=this.mpApp.globalData.footerVal.componentData.list.length?this.mpApp.globalData.footerVal.componentData.list.length-1:this.index;
55
    this.params = this.$options.data.call(this).params
程默 committed
56 57
    let ss = wx.getStorageSync("sessionid");
    this.ss = ss ? `&sessionid=${ss}` : "";
程智春 committed
58
    
程默 committed
59 60 61
    if (!ss) {
      this.params += this.params.includes("logOut") ? "" : "&logOut=true";
    }
程智春 committed
62 63 64 65

    if(wx.getStorageSync("workBox")){
      this.params += `&workBox=${wx.getStorageSync("workBox")}`
    }
程默 committed
66 67
    // tabbar 跳转
    let homeIndex = checkTabbarPage("/");
李嘉林 committed
68 69 70
    homeIndex != 0 && homeIndex == tabIndex && (tabIndex = 0);
    console.log(this.mpApp.globalData.footerVal,tabIndex,this.mpApp.globalData.footerVal.componentData.list.length,'--this.mpApp.globalData.footerVal')
    if (this.mpApp.globalData.footerVal.componentData.list[tabIndex].link) {
程默 committed
71
      this.page = getUrlofLink(
李嘉林 committed
72
        this.mpApp.globalData.footerVal.componentData.list[tabIndex].link
程默 committed
73
      );
程默 committed
74
      let query=serialize(options)
75
      console.log(query,'==================', this.params,'-----------------')
程默 committed
76
      this.params+=query?'&'+query:''
程默 committed
77
    }
chengzhichun committed
78
     let  reg = /^\/pages\//;
李嘉林 committed
79 80 81
    console.log(this.pageUrl,'pageUrl======================',this.mpApp.globalData.footerVal.componentData.list[tabIndex].link)
    if (this.mpApp.globalData.footerVal.componentData.list[tabIndex].link) {
      if(reg.test(this.mpApp.globalData.footerVal.componentData.list[tabIndex].link.link)){
chengzhichun committed
82
        wx.reLaunch({
李嘉林 committed
83
          url: this.mpApp.globalData.footerVal.componentData.list[tabIndex].link.link,
chengzhichun committed
84 85 86
        });
      }
    }
程默 committed
87 88 89 90 91 92 93 94 95 96
  },
  methods: {
    handleError(data) {
      wx.showLoading({
        title: "网页加载失败 请右上角刷新",
      });
    },
  },
};
</script>