long
2024-06-26 911e0ed72a790ba054385ffe594262e123948691
src/App.vue
@@ -2,7 +2,12 @@
    <div id="app">
        <transition name="fade" mode="out-in">
            <!-- 页面,isRouterAlive 刷新用 -->
            <router-view v-if="isRouterAlive"/>
            <!-- <router-view v-if="isRouterAlive"/> -->
            <div>
                <keep-alive>
                    <router-view v-if="isRouterAlive" />
                </keep-alive>
            </div>
        </transition>
        <!-- Toast 提示 -->
@@ -24,10 +29,11 @@
// 入口参数
// 这里注释入口参数
import Login from '@/utils/jun_login.js'
// import Login from '@/utils/jun_login.js'
import wxsign from '@/utils/wxsign.js'
import Config from './config'
// import Config from './config'
// import xioFn from './utils/xio_fn.js'
// import eruda from 'eruda'
export default {
    name: 'App',
@@ -75,14 +81,16 @@
        }
    },
    mounted () {
        // console.log('/**********************/', eruda)
        // eruda && eruda.init()
        console.log('app amounted')
        // 避免刷新导致code重复使用
        let code = this.getQueryString('code') // 微信回调code
        let cover = this.getQueryString('cover') // 是否封面入口
        let local_code = this.getLocalStorage('code') // 本地缓存code
        let isRule = this.getQueryString('rule')==1 // 规则
        let isCoupon = this.getQueryString('coupon')==1 // 优惠券
        // let code = this.getQueryString('code') // 微信回调code
        // let cover = this.getQueryString('cover') // 是否封面入口
        // let local_code = this.getLocalStorage('code') // 本地缓存code
        // let isRule = this.getQueryString('rule')==1 // 规则
        // let isCoupon = this.getQueryString('coupon')==1 // 优惠券
        // 以下情况需要重定向到长链
        // 1. 链接带有code,但code已经用过
@@ -92,20 +100,20 @@
        // 4. 非优惠券单页
        // console.dir(Config.createCodeUrl())
        if(Config.isWxLoginType){
            if (code && local_code == code || (!isCoupon && !isRule && !cover && !code && !Config.ismock && !Config.istest)) {
                // 该微信code已使用,重新跳转长链
                Login.toLongUrl()
                return
            } else {
                this.removeLocalStorage('code')
            }
        }
        // if(Config.isWxLoginType){
        //     if (code && local_code == code || (!isCoupon && !isRule && !cover && !code && !Config.ismock && !Config.istest)) {
        //         // 该微信code已使用,重新跳转长链
        //         Login.toLongUrl()
        //         return
        //     } else {
        //         this.removeLocalStorage('code')
        //     }
        // }
        // 刷新固定首页
        if (location.hash && location.hash!='#/') {
            this.$router.replace({name: 'root'})
        }
        // if (location.hash && location.hash!='#/') {
        //     this.$router.replace({name: 'root'})
        // }
        // 暴露到全局,jun_httpEvent.js 调用
        window.appLoading = this.loading.bind(this)
@@ -113,7 +121,8 @@
        window.appToast = this.toast.bind(this)
        // this.$refs.audio.play()
        if(Config.isWxLoginType) this.wxinit()
        // if(Config.isWxLoginType) this.wxinit()
    },
    methods: {
        // 微信初始化