|
|
@@ -19,7 +19,7 @@ export default {
|
|
|
// ...mapGetters({ userInfo: 'getUser' })
|
|
|
// },
|
|
|
// 页面生命周期才触发
|
|
|
- onLoad: function(option) {
|
|
|
+ onLoad: function (option) {
|
|
|
this.option = option || null
|
|
|
if (option.token) {
|
|
|
uni.setStorageSync('token', option.token)
|
|
|
@@ -33,67 +33,59 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
uni.setStorageSync('currentQuery', JSON.stringify(option))
|
|
|
+
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
+ //检查小程序的登录态是否有效 checkSession
|
|
|
+ uni.checkSession({
|
|
|
+ success(){
|
|
|
+ console.log('checkSession success')
|
|
|
+ },
|
|
|
+ fail(){
|
|
|
+ uni.removeStorageSync('token');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // #endif
|
|
|
+
|
|
|
// 登录
|
|
|
- if (constant.source == 'business' || constant.source == 'mall') {
|
|
|
- if (isLogin()) {
|
|
|
- // #ifdef H5
|
|
|
- if (this.init) {
|
|
|
- if (constant.source == 'business') {
|
|
|
- getUser()
|
|
|
- }
|
|
|
- this.init()
|
|
|
- // console.log('init', this.init)
|
|
|
- }
|
|
|
- // #endif
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- wxLoginFn().then(res => {
|
|
|
- if (this.init) {
|
|
|
- if (constant.source == 'business') {
|
|
|
- getUser()
|
|
|
- }
|
|
|
- this.init()
|
|
|
- }
|
|
|
- })
|
|
|
- // #endif
|
|
|
- } else {
|
|
|
- // #ifdef H5
|
|
|
- getCheckLogin().then(res => {
|
|
|
- if (constant.source == 'business') {
|
|
|
- if (res) {
|
|
|
- getUser()
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- // #endif
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- wxLoginFn().then(res => {
|
|
|
- if (this.init) {
|
|
|
- if (constant.source == 'business') {
|
|
|
- getUser()
|
|
|
- }
|
|
|
- this.init()
|
|
|
- }
|
|
|
- })
|
|
|
- // #endif
|
|
|
+ if (isLogin()) {
|
|
|
+ // #ifdef H5
|
|
|
+ if (this.init) {
|
|
|
+ this.init()
|
|
|
}
|
|
|
- }
|
|
|
- if (constant.source == 'official') {
|
|
|
+ // #endif
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
if (this.init) {
|
|
|
this.init()
|
|
|
}
|
|
|
+ // #endif
|
|
|
+ } else {
|
|
|
+ // #ifdef H5
|
|
|
+ getCheckLogin().then(res => {
|
|
|
+ })
|
|
|
+ // #endif
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
+ console.log('执行这里。。。111')
|
|
|
+ wxLoginFn().then(res => {
|
|
|
+ if (this.init) {
|
|
|
+ this.init()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // #endif
|
|
|
}
|
|
|
+
|
|
|
},
|
|
|
mounted() {
|
|
|
if (this.mInit) {
|
|
|
// #ifdef H5
|
|
|
this.mInit()
|
|
|
// #endif
|
|
|
+
|
|
|
// #ifdef MP-WEIXIN
|
|
|
// wxLoginFn().then(res => {
|
|
|
// this.mInit()
|
|
|
// })
|
|
|
// #endif
|
|
|
- // console.log('init', this.mInit)
|
|
|
}
|
|
|
}
|
|
|
}
|