Commit 9cd08123 by jianan

feat(统一身份): CFFP H5 sso 登录态适配——票据通道落地与第三种登录方式贯通

- util/interceptor.ts:/sso/ticket/consume 加白名单;sso 模式下 custom.token 注入
  Casdoor 令牌;401/T001 走 sso 重登闭环(销毁 web-view 回原生重走票据)
- pages/lanch:isSsoMode+内存令牌在 → 按 landingPage 直达,不换 code、不建 HS 会话;
  锚点跳转函数抽出与 reLogin(HS) 链路共用
- 45 个业务页:登录判定 codelogin → !=visitor,使 loginType='sso' 被全站识别为已登录
  (web-view 回收重载后可凭 sso 标志交原生重走票据,绝不静默降级游客)
- 配套已提交:util/sso.ts + openWorkbench 接力(3cece355)、/pages/auth/ticket 落地页
parent 3cece355
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
</view> </view>
</view> </view>
<view class="btnBox" @click="gotoApply"> <view class="btnBox" @click="gotoApply">
{{loginType=='codelogin'?'确认加盟':'注册并加盟'}} {{loginType!='visitor'?'确认加盟':'注册并加盟'}}
</view> </view>
</view> </view>
</view> </view>
...@@ -164,17 +164,17 @@ ...@@ -164,17 +164,17 @@
this.checkToken() this.checkToken()
} }
// 非邀请状态 // 非邀请状态
if (!this.shareId && this.loginType == 'codelogin' && this.userInfo.mobile) { if (!this.shareId && this.loginType != 'visitor' && this.userInfo.mobile) {
this.form.mobile = this.userInfo.mobile this.form.mobile = this.userInfo.mobile
this.editMobile = true this.editMobile = true
this.showVerificationCode = false this.showVerificationCode = false
} }
// 非邀请状态 // 非邀请状态
if (!this.shareId && this.loginType == 'codelogin' && !this.form.nickName) { if (!this.shareId && this.loginType != 'visitor' && !this.form.nickName) {
this.queryInfo() this.queryInfo()
} }
// 登录状态 非邀请 // 登录状态 非邀请
if (this.loginType == 'codelogin' && !this.shareId) { if (this.loginType != 'visitor' && !this.shareId) {
// #ifdef H5 // #ifdef H5
initJssdkShare(() => { initJssdkShare(() => {
setWechatShare(); setWechatShare();
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
this.loginType = 'visitor' this.loginType = 'visitor'
return return
} }
if (res.data.data.isPartner && this.loginType == 'codelogin') { if (res.data.data.isPartner && this.loginType != 'visitor') {
this.$refs.successJoinPopup.open() this.$refs.successJoinPopup.open()
} }
}) })
...@@ -306,7 +306,7 @@ ...@@ -306,7 +306,7 @@
} }
console.log('this.sharePosterObj', this.sharePosterObj) console.log('this.sharePosterObj', this.sharePosterObj)
// 登录并且是禁用状态 // 登录并且是禁用状态
if (this.loginType == 'codelogin' && this.userInfo.userIsActive == 2) { if (this.loginType != 'visitor' && this.userInfo.userIsActive == 2) {
this.showCode = true this.showCode = true
this.$refs.restrictedOrCanelTip.open('您的账号处在不可用状态,请扫码添加客服咨询情况') this.$refs.restrictedOrCanelTip.open('您的账号处在不可用状态,请扫码添加客服咨询情况')
return return
...@@ -347,7 +347,7 @@ ...@@ -347,7 +347,7 @@
...this.form, ...this.form,
visitorUuid:uni.getStorageSync('visitorUuid')?uni.getStorageSync('visitorUuid'):dataHandling.uuid() visitorUuid:uni.getStorageSync('visitorUuid')?uni.getStorageSync('visitorUuid'):dataHandling.uuid()
} }
if (this.loginType == 'codelogin') { if (this.loginType != 'visitor') {
this.getApply() this.getApply()
uni.hideLoading() uni.hideLoading()
return return
......
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
onLoad(options){ onLoad(options){
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -418,7 +418,7 @@ ...@@ -418,7 +418,7 @@
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -58,7 +58,7 @@ export default { ...@@ -58,7 +58,7 @@ export default {
} }
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo')) this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
......
...@@ -221,7 +221,7 @@ const queryInfo = () => { ...@@ -221,7 +221,7 @@ const queryInfo = () => {
}); });
}; };
onShow(()=>{ onShow(()=>{
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
queryInfo() queryInfo()
} }
}) })
......
...@@ -145,7 +145,7 @@ const fetchProducts = async (type=0) => { ...@@ -145,7 +145,7 @@ const fetchProducts = async (type=0) => {
} }
} }
onShow(()=>{ onShow(()=>{
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
queryInfo() queryInfo()
} }
}) })
......
...@@ -335,7 +335,7 @@ const queryInfo = () => { ...@@ -335,7 +335,7 @@ const queryInfo = () => {
}); });
}; };
onShow(()=>{ onShow(()=>{
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
queryInfo() queryInfo()
} }
}) })
......
...@@ -151,7 +151,7 @@ export default { ...@@ -151,7 +151,7 @@ export default {
}, },
}, },
onShow(){ onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -306,7 +306,7 @@ ...@@ -306,7 +306,7 @@
this.isBack = options.isBack this.isBack = options.isBack
}, },
onShow(){ onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
}, },
components:{restrictedTip,}, components:{restrictedTip,},
onShow(){ onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo')) this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
} }
this.getSalaryData() this.getSalaryData()
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
}, },
onShow(){ onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
let dataForm = JSON.parse(uni.getStorageSync('cffp_userInfo')) let dataForm = JSON.parse(uni.getStorageSync('cffp_userInfo'))
......
...@@ -592,6 +592,14 @@ ...@@ -592,6 +592,14 @@
"navigationBarTitleText": "启动页" "navigationBarTitleText": "启动页"
}, },
"lazyLoad": true "lazyLoad": true
},
{
"path": "pages/auth/ticket",
"style": {
"topWindow": false,
"navigationBarTitleText": "登录中"
},
"lazyLoad": true
} }
], ],
"subPackages": [ "subPackages": [
......
...@@ -179,7 +179,7 @@ ...@@ -179,7 +179,7 @@
this.userAfterSalesDtl() this.userAfterSalesDtl()
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
this.userAfterSales() this.userAfterSales()
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
this.dropOptionsQuery() this.dropOptionsQuery()
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
this.userRefundCourseDtl(); this.userRefundCourseDtl();
......
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
this.queryDate = option.queryDate; this.queryDate = option.queryDate;
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -865,7 +865,7 @@ ...@@ -865,7 +865,7 @@
isSaveShare: '1', //是否存贮分享便于统计分享数据 isSaveShare: '1', //是否存贮分享便于统计分享数据
fileId: this.fileId, fileId: this.fileId,
} }
if (uni.getStorageSync('loginType') == 'codelogin') { if (uni.getStorageSync('loginType') != 'visitor') {
shareInfo.userId = this.userId shareInfo.userId = this.userId
newLink = newLink =
`${shareURL}/pages/lanch/index?fileId=${this.fileId}&coursesharing=1&serialsNo=${nanoid()}&shareCode=${shareCode}&shareUserId=${this.userId}&jumpUrl=${jumptime}&landingPage=courseDetail&miniShare=1` `${shareURL}/pages/lanch/index?fileId=${this.fileId}&coursesharing=1&serialsNo=${nanoid()}&shareCode=${shareCode}&shareUserId=${this.userId}&jumpUrl=${jumptime}&landingPage=courseDetail&miniShare=1`
...@@ -1510,7 +1510,7 @@ ...@@ -1510,7 +1510,7 @@
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo')) this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
} }
this.userId = uni.getStorageSync('cffp_userId') this.userId = uni.getStorageSync('cffp_userId')
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo')) this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
} }
this.userId = uni.getStorageSync('cffp_userId') this.userId = uni.getStorageSync('cffp_userId')
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
...@@ -305,7 +305,7 @@ ...@@ -305,7 +305,7 @@
this.shareItem = JSON.parse(JSON.stringify(item)) this.shareItem = JSON.parse(JSON.stringify(item))
// return // return
// 未登录去登录 // 未登录去登录
if (uni.getStorageSync('loginType') !== 'codelogin') { if (uni.getStorageSync('loginType') == 'visitor') {
dataHandling.pocessTracking( dataHandling.pocessTracking(
'点击', '点击',
`用户在产品中心未登录时点击产品分享按钮`, `用户在产品中心未登录时点击产品分享按钮`,
......
...@@ -200,7 +200,7 @@ ...@@ -200,7 +200,7 @@
this.isLoading = false this.isLoading = false
this.posterImg = '' this.posterImg = ''
this.generatedImage = '' this.generatedImage = ''
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -20,16 +20,22 @@ ...@@ -20,16 +20,22 @@
import * as environment from '@/environments/environment' import * as environment from '@/environments/environment'
import dataHandling from "@/util/dataHandling"; import dataHandling from "@/util/dataHandling";
import wx from 'weixin-js-sdk' import wx from 'weixin-js-sdk'
import * as sso from '@/util/sso'
import restrictedTip from '@/components/commonPopup/restrictedTip.vue'; import restrictedTip from '@/components/commonPopup/restrictedTip.vue';
let jumpInfo = ref({}) let jumpInfo = ref({})
let dataToken = ref() let dataToken = ref()
let restrictedTipRef = ref() let restrictedTipRef = ref()
onLoad((options) => { onLoad((options) => {
jumpInfo.value = JSON.parse(JSON.stringify(options)) jumpInfo.value = JSON.parse(JSON.stringify(options))
if(options.backFlag){ if(options.backFlag){
uni.setStorageSync('backFlag',options.backFlag) uni.setStorageSync('backFlag',options.backFlag)
} }
// Casdoor 票据通道:登录态已在内存,按 landingPage 直达,不换 code、不建 HS 会话
if (sso.isSsoMode() && sso.getSsoToken()) {
gotoLandingPage(options.landingPage || 'index')
return
}
// 参数带token了重新登录 // 参数带token了重新登录
if (options.dataToken) { if (options.dataToken) {
console.log('jumpInfo.value', jumpInfo.value); console.log('jumpInfo.value', jumpInfo.value);
...@@ -86,6 +92,56 @@ ...@@ -86,6 +92,56 @@
}) })
// 按 landingPage 锚点跳转:reLogin(HS code 登录)与 sso(Casdoor 票据)共用
const gotoLandingPage = (landingPage) => {
if (landingPage == 'sfpHousePurchase') {
uni.reLaunch({ url: `/sfp/housePurchase/housePurchase` })
} else if (landingPage == 'sfpIndex') {
uni.reLaunch({ url: `/sfp/index/index` })
} else if (landingPage == 'courseDetail') {
if(jumpInfo.value.noShare){
uni.reLaunch({ url: `/pages/courseDetail/courseDetail?fileId=${jumpInfo.value.fileId}&noShare=1`})
} else {
if(jumpInfo.value.shareUserId){
uni.reLaunch({ url: `/pages/courseDetail/courseDetail?fileId=${jumpInfo.value.fileId}&coursesharing=1&serialsNo=${jumpInfo.value.serialsNo}&shareCode=${jumpInfo.value.shareCode}&shareUserId=${jumpInfo.value.shareUserId}&jumpUrl=${jumpInfo.value.jumpUrl}&miniShare=1` })
}else {
uni.reLaunch({ url: `/pages/courseDetail/courseDetail?fileId=${jumpInfo.value.fileId}&miniShare=1` })
}
}
return
} else if (landingPage == 'businessCard') {
uni.reLaunch({ url: `/myPackageA/businessCard/businessCard?userId=${jumpInfo.value.userId}&isShareCard=1&cardId=${jumpInfo.value.cardId}&miniShare=1` })
} else if (landingPage == 'applyFranchise') {
uni.reLaunch({ url: `/myPackageA/applyFranchise/applyFranchise?shareId=${jumpInfo.value.shareId}&invitationCode=${jumpInfo.value.invitationCode}&inviteUserId=${jumpInfo.value.inviteUserId}&miniShare=1` })
}else if(landingPage == 'index'){
if(jumpInfo.value.miniShare){
uni.reLaunch({
url:'/pages/index/index?miniShare=1'
})
}else {
console.log('走到这里了');
uni.reLaunch({
url:'/pages/index/index'
})
}
}else if(landingPage == 'courselist'){
uni.reLaunch({
url:'/pages/courselist/courselist'
})
}else if(landingPage == 'personalCenter'){
uni.reLaunch({
url:'/pages/personalCenter/personalCenter'
})
}else if(landingPage == 'orderStatus'){
const userId = jumpInfo.value.userId || uni.getStorageSync('cffp_userId')
uni.reLaunch({
url:`/pages/orderStatus/orderStatus?orderId=${jumpInfo.value.orderId}&fileId=${jumpInfo.value.fileId}&orderStatus=2&userId=${userId}&backMySelf=1`
})
}
}
const reLogin = (landingPage) => { const reLogin = (landingPage) => {
uni.showLoading({ uni.showLoading({
title: '加载中...' title: '加载中...'
...@@ -118,52 +174,7 @@ ...@@ -118,52 +174,7 @@
uni.setStorageSync('cffp_userId', res.data.userId); uni.setStorageSync('cffp_userId', res.data.userId);
uni.setStorageSync('uni-token', res.data['token']); uni.setStorageSync('uni-token', res.data['token']);
uni.setStorageSync('visitorUuid', res.data['visitorUuid']); uni.setStorageSync('visitorUuid', res.data['visitorUuid']);
if (landingPage == 'sfpHousePurchase') { gotoLandingPage(landingPage)
uni.reLaunch({ url: `/sfp/housePurchase/housePurchase` })
} else if (landingPage == 'sfpIndex') {
uni.reLaunch({ url: `/sfp/index/index` })
} else if (landingPage == 'courseDetail') {
if(jumpInfo.value.noShare){
uni.reLaunch({ url: `/pages/courseDetail/courseDetail?fileId=${jumpInfo.value.fileId}&noShare=1`})
} else {
if(jumpInfo.value.shareUserId){
uni.reLaunch({ url: `/pages/courseDetail/courseDetail?fileId=${jumpInfo.value.fileId}&coursesharing=1&serialsNo=${jumpInfo.value.serialsNo}&shareCode=${jumpInfo.value.shareCode}&shareUserId=${jumpInfo.value.shareUserId}&jumpUrl=${jumpInfo.value.jumpUrl}&miniShare=1` })
}else {
uni.reLaunch({ url: `/pages/courseDetail/courseDetail?fileId=${jumpInfo.value.fileId}&miniShare=1` })
}
// uni.reLaunch({ url: `/pages/courseDetail/courseDetail?fileId=${jumpInfo.value.fileId}&coursesharing=1&serialsNo=${jumpInfo.value.serialsNo}&shareCode=${jumpInfo.value.shareCode}&shareUserId=${jumpInfo.value.shareUserId}&jumpUrl=${jumpInfo.value.jumpUrl}&miniShare=1` })
}
return
} else if (landingPage == 'businessCard') {
uni.reLaunch({ url: `/myPackageA/businessCard/businessCard?userId=${jumpInfo.value.userId}&isShareCard=1&cardId=${jumpInfo.value.cardId}&miniShare=1` })
} else if (landingPage == 'applyFranchise') {
uni.reLaunch({ url: `/myPackageA/applyFranchise/applyFranchise?shareId=${jumpInfo.value.shareId}&invitationCode=${jumpInfo.value.invitationCode}&inviteUserId=${jumpInfo.value.inviteUserId}&miniShare=1` })
}else if(landingPage == 'index'){
if(jumpInfo.value.miniShare){
uni.reLaunch({
url:'/pages/index/index?miniShare=1'
})
}else {
console.log('走到这里了');
uni.reLaunch({
url:'/pages/index/index'
})
}
}else if(landingPage == 'courselist'){
uni.reLaunch({
url:'/pages/courselist/courselist'
})
}else if(landingPage == 'personalCenter'){
uni.reLaunch({
url:'/pages/personalCenter/personalCenter'
})
}else if(landingPage == 'orderStatus'){
uni.reLaunch({
url:`/pages/orderStatus/orderStatus?orderId=${jumpInfo.value.orderId}&fileId=${jumpInfo.value.fileId}&orderStatus=2&userId=${res.data.userId}&backMySelf=1`
})
}
} else { } else {
//内嵌带的code失效了,用户需要重新登录 //内嵌带的code失效了,用户需要重新登录
if(res.data.commonResult&&res.data.commonResult.errorCode=='1101'){ if(res.data.commonResult&&res.data.commonResult.errorCode=='1101'){
......
...@@ -265,7 +265,7 @@ ...@@ -265,7 +265,7 @@
this.userShareQuery(); this.userShareQuery();
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -668,7 +668,7 @@ ...@@ -668,7 +668,7 @@
}, },
onShow() { onShow() {
if (uni.getStorageSync('loginType') == 'codelogin') { if (uni.getStorageSync('loginType') != 'visitor') {
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -267,7 +267,7 @@ ...@@ -267,7 +267,7 @@
this.commissionType = option.commissionType; this.commissionType = option.commissionType;
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
}; };
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
} }
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
if(this.companyType == '1'){ if(this.companyType == '1'){
......
...@@ -355,7 +355,7 @@ ...@@ -355,7 +355,7 @@
queryUserInfoAndPermission(); queryUserInfoAndPermission();
}); });
onShow(()=>{ onShow(()=>{
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
queryInfo() queryInfo()
} }
}) })
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
} }
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -285,7 +285,7 @@ ...@@ -285,7 +285,7 @@
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
this.getqueryTeamAchievement() this.getqueryTeamAchievement()
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
} }
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo')) this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
return {} return {}
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
import { initJssdkShare, setWechatShare } from '@/util/fiveshare'; import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
import api from "@/api/api"; import api from "@/api/api";
import restrictedTip from '@/components/commonPopup/restrictedTip.vue'; import restrictedTip from '@/components/commonPopup/restrictedTip.vue';
// #ifdef H5
import wx from 'weixin-js-sdk'
import * as sso from '@/util/sso'
// #endif
export default { export default {
components:{ MenuList,restrictedTip, }, components:{ MenuList,restrictedTip, },
data() { data() {
...@@ -59,7 +63,7 @@ ...@@ -59,7 +63,7 @@
} }
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
...@@ -115,6 +119,23 @@ ...@@ -115,6 +119,23 @@
}); });
}, },
outLing(){ outLing(){
// #ifdef H5
// SSO(小程序票据)会话:销毁 web-view 回小程序原生;
// IdP(unionid)会话在原生侧,H5 登录页在小程序内不可用
if (sso.isSsoMode()) {
uni.showModal({
title: '退出登录',
content: '确定退出工作台吗?',
showCancel: true,
success: (res) => {
if (res.confirm) {
wx.miniProgram.reLaunch({ url: '/pages/index/mySelf' })
}
}
})
return
}
// #endif
uni.showModal({ uni.showModal({
title: '退出登录', title: '退出登录',
content: '确定要退出登录吗?', content: '确定要退出登录吗?',
......
...@@ -178,7 +178,7 @@ ...@@ -178,7 +178,7 @@
// this.optionForm = this.tempInfo.optionForm = JSON.parse(options.customerBasicInfo) // this.optionForm = this.tempInfo.optionForm = JSON.parse(options.customerBasicInfo)
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
this.queryByUserIdFortuneStatistic(); this.queryByUserIdFortuneStatistic();
this.getCommissionType() this.getCommissionType()
this.getDetail() this.getDetail()
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
restrictedTip restrictedTip
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
let app22 = getCurrentPages().length let app22 = getCurrentPages().length
this.userCourseCount() this.userCourseCount()
this.userCourseList() this.userCourseList()
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
this.querySystemMessage(); this.querySystemMessage();
}, },
onShow(){ onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
this.querySystemMessage(); this.querySystemMessage();
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
this.getSystemMsgDetail(); this.getSystemMsgDetail();
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
} }
}, },
onShow(){ onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
this.goFortuneWithdrawal() this.goFortuneWithdrawal()
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -229,7 +229,7 @@ ...@@ -229,7 +229,7 @@
} }
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
this.calcuteData = uni.getStorageSync('calcuteData') ? JSON.parse(uni.getStorageSync('calcuteData')) : null; this.calcuteData = uni.getStorageSync('calcuteData') ? JSON.parse(uni.getStorageSync('calcuteData')) : null;
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -377,7 +377,7 @@ ...@@ -377,7 +377,7 @@
this.provCityQry(); this.provCityQry();
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
restrictedTip, restrictedTip,
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
restrictedTip, restrictedTip,
}, },
onShow(){ onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
// #ifdef H5 // #ifdef H5
......
...@@ -664,7 +664,7 @@ ...@@ -664,7 +664,7 @@
}, },
}, },
onShow() { onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){ if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo() this.queryInfo()
} }
if(uni.getStorageSync('resIrrAndSimpleResInfos')){ if(uni.getStorageSync('resIrrAndSimpleResInfos')){
......
...@@ -93,15 +93,16 @@ ...@@ -93,15 +93,16 @@
// }; // };
// } // }
// }); // });
// } // }
// 旧版的拦截器 // 旧版的拦截器
import {apiURL,cffpURL,sfpUrl} from "../environments/environment"; import {apiURL,cffpURL,sfpUrl} from "../environments/environment";
import api from "@/api/api"; import api from "@/api/api";
import * as sso from "@/util/sso";
// 白名单,不需要携带token就允许被访问的接口 // 白名单,不需要携带token就允许被访问的接口
const whiteApiList = [`${apiURL}/authorize/obtainToken`, const whiteApiList = [`${apiURL}/authorize/obtainToken`,
`${apiURL}/authorize/checkToken`, `${apiURL}/authorize/checkToken`,
`${cffpURL}/user/loginVerification`, `${cffpURL}/user/loginVerification`,
`${apiURL}/appVersion/checkIsUpdate`, `${apiURL}/appVersion/checkIsUpdate`,
`${cffpURL}/accessLog/accessLogSave`, `${cffpURL}/accessLog/accessLogSave`,
...@@ -110,12 +111,34 @@ const whiteApiList = [`${apiURL}/authorize/obtainToken`, ...@@ -110,12 +111,34 @@ const whiteApiList = [`${apiURL}/authorize/obtainToken`,
`${apiURL}/verificationCode`, `${apiURL}/verificationCode`,
`${sfpUrl}/sfp/sfpMain/pocessTracking`, `${sfpUrl}/sfp/sfpMain/pocessTracking`,
`${cffpURL}/partner/queryById`, `${cffpURL}/partner/queryById`,
`${apiURL}/sso/ticket/consume`, // Casdoor 票据消费:匿名,唯一凭据是 ticket
]; ];
export const interceptor = () => { export const interceptor = () => {
uni.addInterceptor('request', { uni.addInterceptor('request', {
// 请求拦截器 // 请求拦截器
invoke(args) { invoke(args) {
// alert(JSON.stringify(args)) // alert(JSON.stringify(args))
// Casdoor SSO 匿名端点(票据消费带 query,精确白名单匹配不上,按前缀放行)
if (typeof args.url === 'string' && args.url.indexOf('/sso/') !== -1) {
args.header = {
'content-type': args.method === 'POST' ? 'application/json' : 'application/x-www-form-urlencoded',
}
return
}
// Casdoor 票据通道(小程序 web-view):令牌只在内存,绝不走 obtainToken 游客降级
if (sso.isSsoMode()) {
const ssoToken = sso.getSsoToken()
if (!ssoToken) {
// 会话应在但内存令牌丢失(web-view 被系统回收后重载业务页):交原生重走票据,拦掉本次无令牌请求
sso.reloginViaMiniprogram()
return
}
args.header = {
'content-type': args.method === 'POST' ? 'application/json' : 'application/x-www-form-urlencoded',
'X-Authorization': ssoToken,
}
return
}
// 当本地没有token,并且接口地址没在白名单内,需要重新获取token // 当本地没有token,并且接口地址没在白名单内,需要重新获取token
if (!uni.getStorageSync('uni-token') && !whiteApiList.includes(args.url)) { if (!uni.getStorageSync('uni-token') && !whiteApiList.includes(args.url)) {
...@@ -153,9 +176,19 @@ export const interceptor = () => { ...@@ -153,9 +176,19 @@ export const interceptor = () => {
}, },
// 响应拦截器,可以对数据进行预处理 // 响应拦截器,可以对数据进行预处理
success(args) { success(args) {
if(args && args.data && args.data.errorCode && "T001"==args.data.errorCode){ const bodyT001 = args && args.data && args.data.errorCode && "T001" == args.data.errorCode
// Casdoor 分支失败:sso 模式接受纯 HTTP 401;非 sso 模式严格维持老条件(仅 body T001),行为不变
const unauthorized = sso.isSsoMode()
? (bodyT001 || args.statusCode === 401)
: bodyT001
if(unauthorized){
if (sso.isSsoMode()) {
// 不回 H5 首页/登录页:销毁 web-view,原生强制重走 wx.login→票据
sso.reloginViaMiniprogram()
return
}
uni.removeStorageSync('isLogin'); uni.removeStorageSync('isLogin');
uni.removeStorageSync('uni-token'); uni.removeStorageSync('uni-token');
uni.setStorageSync('loginType','visitor') uni.setStorageSync('loginType','visitor')
uni.switchTab({ uni.switchTab({
url:'/pages/index/index' url:'/pages/index/index'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment