|
@@ -1,7 +1,7 @@
|
|
|
<script>
|
|
<script>
|
|
|
import config from '@/config.js'
|
|
import config from '@/config.js'
|
|
|
import Vue from 'vue'
|
|
import Vue from 'vue'
|
|
|
-import { checkUserFamily, verifyToken, bindReferralIfNotSelf, silentRelogin } from './utils/api.js'
|
|
|
|
|
|
|
+import { checkUserFamily, verifyToken, bindReferralIfNotSelf, silentRelogin, ssoLogin } from './utils/api.js'
|
|
|
Vue.prototype.$config = config
|
|
Vue.prototype.$config = config
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -19,7 +19,7 @@ export default {
|
|
|
// inviteCode=推荐码(文章/活动/商品分享)| refCode=推广码 | token/familyInviteCode=家庭邀请令牌 | id=内容详情
|
|
// inviteCode=推荐码(文章/活动/商品分享)| refCode=推广码 | token/familyInviteCode=家庭邀请令牌 | id=内容详情
|
|
|
var hasDeepLink = options && options.query && (
|
|
var hasDeepLink = options && options.query && (
|
|
|
options.query.inviteCode || options.query.refCode || options.query.token ||
|
|
options.query.inviteCode || options.query.refCode || options.query.token ||
|
|
|
- options.query.familyInviteCode || options.query.id
|
|
|
|
|
|
|
+ options.query.familyInviteCode || options.query.id || options.query.ssoTicket
|
|
|
)
|
|
)
|
|
|
// 冷启动:跳转到 splash 页展示过渡动画,2秒后自动进入首页
|
|
// 冷启动:跳转到 splash 页展示过渡动画,2秒后自动进入首页
|
|
|
if (options.scene !== 1047 && options.scene !== 1048 && options.scene !== 1049 && !hasDeepLink) {
|
|
if (options.scene !== 1047 && options.scene !== 1048 && options.scene !== 1049 && !hasDeepLink) {
|
|
@@ -27,6 +27,8 @@ export default {
|
|
|
uni.redirectTo({ url: '/pages/splash/index' })
|
|
uni.redirectTo({ url: '/pages/splash/index' })
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+ // 跨小程序单点登录:携带 ssoTicket 进入 → 换取本地登录态
|
|
|
|
|
+ this.handleSsoLogin(options)
|
|
|
// 处理小程序码场景值(从 wxacode 扫码进入,跳过 splash)
|
|
// 处理小程序码场景值(从 wxacode 扫码进入,跳过 splash)
|
|
|
this.handleScene(options)
|
|
this.handleScene(options)
|
|
|
},
|
|
},
|
|
@@ -34,6 +36,8 @@ export default {
|
|
|
console.log('App Show', options)
|
|
console.log('App Show', options)
|
|
|
// 热启动(含从分享卡重新进入):同样捕获分享参数
|
|
// 热启动(含从分享卡重新进入):同样捕获分享参数
|
|
|
this.captureReferralParams(options)
|
|
this.captureReferralParams(options)
|
|
|
|
|
+ // 跨小程序单点登录:热启动携带 ssoTicket 进入同样处理
|
|
|
|
|
+ this.handleSsoLogin(options)
|
|
|
// 每次 app 展示时也检查场景值(小程序码可能从冷启动后的 onShow 传入)
|
|
// 每次 app 展示时也检查场景值(小程序码可能从冷启动后的 onShow 传入)
|
|
|
this.handleScene(options)
|
|
this.handleScene(options)
|
|
|
|
|
|
|
@@ -167,6 +171,30 @@ bindReferralIfNotSelf(code).then(function(res) {
|
|
|
// 同步 familyId 到 store(hasFamily getter 依赖;静默续期路径)
|
|
// 同步 familyId 到 store(hasFamily getter 依赖;静默续期路径)
|
|
|
this.$store.commit('setFamilyId', data.familyId)
|
|
this.$store.commit('setFamilyId', data.familyId)
|
|
|
},
|
|
},
|
|
|
|
|
+ // 跨小程序单点登录:从 train 跳转进入时携带 ssoTicket → 换取本地登录态。
|
|
|
|
|
+ // 一次性票据(后端原子消费),用 _ssoHandledTicket 去重,避免 onLaunch/onShow 双处理。
|
|
|
|
|
+ handleSsoLogin(options) {
|
|
|
|
|
+ if (!options || !options.query) return
|
|
|
|
|
+ var ticket = options.query.ssoTicket
|
|
|
|
|
+ if (!ticket) return
|
|
|
|
|
+ if (this._ssoHandledTicket === ticket) return
|
|
|
|
|
+ this._ssoHandledTicket = ticket
|
|
|
|
|
+ var self = this
|
|
|
|
|
+ uni.showLoading({ title: '登录中...' })
|
|
|
|
|
+ ssoLogin(ticket).then(function(res) {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ if (res && res.code === 200 && res.data) {
|
|
|
|
|
+ self.saveLoginInfo(res.data)
|
|
|
|
|
+ // 清空路由票据(防转发泄漏)并落地首页;index/index 会按角色重新分流
|
|
|
|
|
+ uni.reLaunch({ url: '/pages/index/index' })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({ title: (res && res.message) || '单点登录失败', icon: 'none' })
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(function(e) {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ uni.showToast({ title: (e && e.message) || '单点登录失败', icon: 'none' })
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
// 处理小程序码场景值
|
|
// 处理小程序码场景值
|
|
|
handleScene(options) {
|
|
handleScene(options) {
|
|
|
if (!options || !options.query) return
|
|
if (!options || !options.query) return
|