|
|
@@ -1,55 +1,55 @@
|
|
|
-import { pageTo } from '@/utils/util.js'
|
|
|
-import { wxLoginFn } from '@/utils/auth'
|
|
|
-import { mapGetters } from 'vuex'
|
|
|
-import { TOKEN_STORAGE_KEY } from '@/constant/storageKeys'
|
|
|
-import { applyLaunchQuery, persistLaunchStorage } from '@/utils/launchScene'
|
|
|
-
|
|
|
-export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- option: null,
|
|
|
- constant: this.$constant,
|
|
|
- $util: this.$util,
|
|
|
- pageTo: pageTo,
|
|
|
- //0没有登录 1有登录
|
|
|
- globalLoginStyle :0
|
|
|
- }
|
|
|
- },
|
|
|
- computed: {
|
|
|
- ...mapGetters({ loginInfo: "getLoginInfo" })
|
|
|
- },
|
|
|
- // 页面生命周期才触发
|
|
|
- onLoad: function (option) {
|
|
|
- let that = this
|
|
|
- option = applyLaunchQuery(option || {})
|
|
|
- this.option = option
|
|
|
-
|
|
|
- if (option.token) {
|
|
|
- uni.setStorageSync(TOKEN_STORAGE_KEY, option.token)
|
|
|
- }
|
|
|
-
|
|
|
- persistLaunchStorage(option)
|
|
|
-
|
|
|
- //线上检查小程序的登录态是否有效 checkSession
|
|
|
- //checkSession开发环境无效,在真机调试有效
|
|
|
- if (process.env.NODE_ENV == "production") {
|
|
|
- uni.checkSession({
|
|
|
- success() {
|
|
|
- console.log('checkSession success')
|
|
|
- },
|
|
|
- fail() {
|
|
|
- uni.removeStorageSync(TOKEN_STORAGE_KEY);
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- if (that.$util.isEmpty(that.getLoginInfo)) {
|
|
|
- wxLoginFn().then(wxRes=>{
|
|
|
- that.init()
|
|
|
- })
|
|
|
- }else{
|
|
|
- that.init()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+import { pageTo } from '@/utils/util.js'
|
|
|
+import { wxLoginFn } from '@/utils/auth'
|
|
|
+import { mapGetters } from 'vuex'
|
|
|
+import { TOKEN_STORAGE_KEY } from '@/constant/storageKeys'
|
|
|
+import { applyLaunchQuery, persistLaunchStorage } from '@/utils/launchScene'
|
|
|
+
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ option: null,
|
|
|
+ constant: this.$constant,
|
|
|
+ $util: this.$util,
|
|
|
+ pageTo: pageTo,
|
|
|
+ //0没有登录 1有登录
|
|
|
+ globalLoginStyle :0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters({ loginInfo: "getLoginInfo" })
|
|
|
+ },
|
|
|
+ // 页面生命周期才触发
|
|
|
+ onLoad: function (option) {
|
|
|
+ let that = this
|
|
|
+ option = applyLaunchQuery(option || {})
|
|
|
+ this.option = option
|
|
|
+
|
|
|
+ if (option.token) {
|
|
|
+ uni.setStorageSync(TOKEN_STORAGE_KEY, option.token)
|
|
|
+ }
|
|
|
+
|
|
|
+ persistLaunchStorage(option)
|
|
|
+
|
|
|
+ //线上检查小程序的登录态是否有效 checkSession
|
|
|
+ //checkSession开发环境无效,在真机调试有效
|
|
|
+ if (process.env.NODE_ENV == "production") {
|
|
|
+ uni.checkSession({
|
|
|
+ success() {
|
|
|
+ console.log('checkSession success')
|
|
|
+ },
|
|
|
+ fail() {
|
|
|
+ uni.removeStorageSync(TOKEN_STORAGE_KEY);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (that.$util.isEmpty(that.loginInfo)) {
|
|
|
+ wxLoginFn().then(wxRes=>{
|
|
|
+ that.init()
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ that.init()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
|