12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <template>
- <div id="app">
- <router-view></router-view>
- </div>
- </template>
- <script>
- import { getWxConfig } from './api/index'
- import { checkIsLogin } from './api/login'
- import wx from "weixin-jsapi";
- export default {
- name: 'App',
- provide() {
- return {
- reload: this.reload
- }
- },
- data() {
- return {
- isRouterAlive: true
- }
- },
- async created() {
- if (this.$route.path !== "/Login") {
- const res = await checkIsLogin();
- if (res.msg !== "success") {
- this.$router.push({ path: '/Login' })
- }
- }
- window.localStorage.setItem('scanUrl', location.href.split('#')[0])
- const res = await getWxConfig({
- url: window.location.href
- })
-
- var timestamp = res.wxConfig.timestamp;
- var noncestr = res.wxConfig.nonceStr;
- var signature = res.wxConfig.signature;
- var appId = res.wxConfig.appId;
- var url = window.location.href
- wx.config({
- debug: false,
-
- appId: appId,
- timestamp: timestamp,
- nonceStr: noncestr,
- signature: signature,
- url,
- jsApiList: [
- "scanQRCode",
- ]
- });
- },
- methods: {
- reload() {
- this.isRouterAlive = false;
- this.$nextTick(function () {
- this.isRouterAlive = true;
- })
- }
- }
- }
- </script>
- <style scoped>
- #app {
- width: 100%;
- max-width: 7.5rem;
- margin: 0 auto;
- }
- </style>
|