杨磊
2025-08-07 375513370cc01fcd976987d07797249600b0bb3e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<template>
  <div id="app">
    <router-view />
  </div>
</template>
 
<script>
import { watch } from "vue";
import { setSessionGuid, setNewView, storage } from "./assets/js/userAction";
import tool from "./assets/js/toolClass";
 
export default {
  name: "App",
  data() {
    return {
      imgsrc: require("@/assets/images/officialAccount.jpg"),
    };
  },
  created() {
    // 在移动端打开Pc网站时的提示
    if (
      window.navigator.userAgent.match(
        /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
      )
    ) {
      this.$alert(
        "<p style='text-align:left;'>请在PC端打开此网页,或扫描下方二维码关注我社公众号,单击菜单栏中的“教学服务”浏览相关信息、申请样书或下载教材配套的资源。</p><img src='" +
          this.imgsrc +
          "'>",
        "提示",
        {
          dangerouslyUseHTMLString: true,
          center: true,
          customClass: "msgbox",
        }
      );
    }
 
    //在页面加载时读取sessionStorage里的状态信息
    if (sessionStorage.getItem("store")) {
      this.$store.replaceState(
        Object.assign(
          {},
          this.$store.state,
          JSON.parse(sessionStorage.getItem("store"))
        )
      );
      sessionStorage.removeItem("store");
    }
 
    //在页面刷新时将vuex里的信息保存到sessionStorage里
    window.addEventListener("beforeunload", () => {
      sessionStorage.setItem("store", JSON.stringify(this.$store.state));
    });
  },
  watch: {
    $route(to, from) {
      // if (to.path.indexOf("AdminLogin") == -1 && from.path.indexOf("AdminLogin") == -1) {
      //   const detailList = ["/bookStore/detail", "teachingServices/detail"];
      //   if (detailList.includes(to.path)) {
      //     if (to.path == "/bookStore/detail") {
      //       setNewView("productId", to.query.id);
      //     } else {
      //       setNewView("cmsItemId", to.query.id);
      //     }
      //   }
      //   let sessionGuid = storage.get("sessionGuid");
      //   const token = tool.getCookie("websiteFrontToken");
      //   if (!sessionGuid) {
      //     setSessionGuid();
      //   }
      //   sessionStorage.setItem("fromPath", from.fullPath.substring(1));
      //   sessionStorage.setItem("toPath", to.fullPath.substring(1));
      // }
    },
  },
};
</script>
 
<style lang="less">
@import "~@/assets/css/base.css";
@import "~@/assets/css/common.css";
 
html,
body,
#app {
  width: 100%;
  height: 100%;
  background-color: #f1f8f4;
  .msgbox {
    width: 380px !important;
  }
}
</style>
<style lang="less">
// 富文本容器,保留富文本默认样式,所见即所得
.richTextBox {
  line-height: 1.4;
  font-size: 14px;
  * {
    margin: revert;
    padding: revert;
    border: revert;
    font: revert;
    vertical-align: revert;
  }
}
</style>
<style lang="less" scoped></style>