Commit 69649f08 by jianan

Merge branch 'test_zjn' into test

parents c6432ef6 9cd08123
......@@ -11,6 +11,8 @@ const dev = {
scrm_url:'https://mdev.zuihuibi.cn',
file_query_url:'https://mdev.zuihuibi.cn',
csf_url:'http://139.224.145.34:9002',
// 港险转介人工作台 H5(独立系统,整屏跳转,不嵌 iframe)
workbench_url:'https://center.zuihuibi.cn/',
}
const stage = {
base_url:'https://mstage.zuihuibi.cn',
......@@ -19,8 +21,9 @@ const stage = {
share_url:'https://mstage.zuihuibi.cn/appYdhomeoffice',
sfp_url:'https://mstage.zuihuibi.cn/sfpApi',
scrm_url:'https://mstage.zuihuibi.cn',
file_query_url:'https://mstage.zuihuibi.cn'
file_query_url:'https://mstage.zuihuibi.cn',
// 港险转介人工作台 H5(独立系统,整屏跳转,不嵌 iframe)
workbench_url:'https://center.zuihuibi.cn/',
}
const prod = {
base_url:'https://app.ydhomeoffice.cn',
......@@ -32,6 +35,8 @@ const prod = {
scrm_url:'https://m.zuihuibi.cn',
file_query_url:'https://m.zuihuibi.cn',
csf_url:'https://web.csf.hk',
// 港险转介人工作台 H5(独立系统,整屏跳转,不嵌 iframe)
workbench_url:'https://center.supguard.cn/',
}
// companyType: '1', cffp
// companyType: '2', appYdhomeoffice
......@@ -66,6 +71,7 @@ let imgUrl = config[env].img_url;
let scrmUrl = config[env].scrm_url;
let fileQueryErl = config[env].file_query_url;
let csfUrl = config[env].csf_url;
let workbenchUrl = config[env].workbench_url;
export{
baseURL,
......@@ -78,5 +84,6 @@ export{
imgUrl,
scrmUrl,
fileQueryErl,
csfUrl
csfUrl,
workbenchUrl
}
\ No newline at end of file
......@@ -62,7 +62,7 @@
</view>
</view>
<view class="btnBox" @click="gotoApply">
{{loginType=='codelogin'?'确认加盟':'注册并加盟'}}
{{loginType!='visitor'?'确认加盟':'注册并加盟'}}
</view>
</view>
</view>
......@@ -164,17 +164,17 @@
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.editMobile = true
this.showVerificationCode = false
}
// 非邀请状态
if (!this.shareId && this.loginType == 'codelogin' && !this.form.nickName) {
if (!this.shareId && this.loginType != 'visitor' && !this.form.nickName) {
this.queryInfo()
}
// 登录状态 非邀请
if (this.loginType == 'codelogin' && !this.shareId) {
if (this.loginType != 'visitor' && !this.shareId) {
// #ifdef H5
initJssdkShare(() => {
setWechatShare();
......@@ -233,7 +233,7 @@
this.loginType = 'visitor'
return
}
if (res.data.data.isPartner && this.loginType == 'codelogin') {
if (res.data.data.isPartner && this.loginType != 'visitor') {
this.$refs.successJoinPopup.open()
}
})
......@@ -306,7 +306,7 @@
}
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.$refs.restrictedOrCanelTip.open('您的账号处在不可用状态,请扫码添加客服咨询情况')
return
......@@ -347,7 +347,7 @@
...this.form,
visitorUuid:uni.getStorageSync('visitorUuid')?uni.getStorageSync('visitorUuid'):dataHandling.uuid()
}
if (this.loginType == 'codelogin') {
if (this.loginType != 'visitor') {
this.getApply()
uni.hideLoading()
return
......
......@@ -103,7 +103,7 @@
onLoad(options){
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -418,7 +418,7 @@
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -58,7 +58,7 @@ export default {
}
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
......
......@@ -221,7 +221,7 @@ const queryInfo = () => {
});
};
onShow(()=>{
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
queryInfo()
}
})
......
......@@ -145,7 +145,7 @@ const fetchProducts = async (type=0) => {
}
}
onShow(()=>{
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
queryInfo()
}
})
......
......@@ -335,7 +335,7 @@ const queryInfo = () => {
});
};
onShow(()=>{
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
queryInfo()
}
})
......
......@@ -151,7 +151,7 @@ export default {
},
},
onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -306,7 +306,7 @@
this.isBack = options.isBack
},
onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -70,7 +70,7 @@
},
components:{restrictedTip,},
onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -171,7 +171,7 @@
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
}
this.getSalaryData()
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -103,7 +103,7 @@
},
onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
let dataForm = JSON.parse(uni.getStorageSync('cffp_userInfo'))
......
......@@ -645,6 +645,14 @@
"meta": { "moduleCode": "launch", "moduleName": "启动页" }
},
"lazyLoad": true
},
{
"path": "pages/auth/ticket",
"style": {
"topWindow": false,
"navigationBarTitleText": "登录中"
},
"lazyLoad": true
}
],
"subPackages": [
......
......@@ -179,7 +179,7 @@
this.userAfterSalesDtl()
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -104,7 +104,7 @@
this.userAfterSales()
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -257,7 +257,7 @@
this.dropOptionsQuery()
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
this.userRefundCourseDtl();
......
......@@ -114,7 +114,7 @@
this.queryDate = option.queryDate;
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -864,7 +864,7 @@
isSaveShare: '1', //是否存贮分享便于统计分享数据
fileId: this.fileId,
}
if (uni.getStorageSync('loginType') == 'codelogin') {
if (uni.getStorageSync('loginType') != 'visitor') {
shareInfo.userId = this.userId
newLink =
`${shareURL}/pages/lanch/index?fileId=${this.fileId}&coursesharing=1&serialsNo=${nanoid()}&shareCode=${shareCode}&shareUserId=${this.userId}&jumpUrl=${jumptime}&landingPage=courseDetail&miniShare=1`
......@@ -1508,7 +1508,7 @@
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
}
this.userId = uni.getStorageSync('cffp_userId')
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -244,7 +244,7 @@
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
}
this.userId = uni.getStorageSync('cffp_userId')
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......@@ -305,7 +305,7 @@
this.shareItem = JSON.parse(JSON.stringify(item))
// return
// 未登录去登录
if (uni.getStorageSync('loginType') !== 'codelogin') {
if (uni.getStorageSync('loginType') == 'visitor') {
dataHandling.pocessTracking(
'点击',
`用户在产品中心未登录时点击产品分享按钮`,
......
......@@ -200,7 +200,7 @@
this.isLoading = false
this.posterImg = ''
this.generatedImage = ''
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -20,16 +20,22 @@
import * as environment from '@/environments/environment'
import dataHandling from "@/util/dataHandling";
import wx from 'weixin-js-sdk'
import * as sso from '@/util/sso'
import restrictedTip from '@/components/commonPopup/restrictedTip.vue';
let jumpInfo = ref({})
let dataToken = ref()
let restrictedTipRef = ref()
onLoad((options) => {
jumpInfo.value = JSON.parse(JSON.stringify(options))
if(options.backFlag){
uni.setStorageSync('backFlag',options.backFlag)
}
// Casdoor 票据通道:登录态已在内存,按 landingPage 直达,不换 code、不建 HS 会话
if (sso.isSsoMode() && sso.getSsoToken()) {
gotoLandingPage(options.landingPage || 'index')
return
}
// 参数带token了重新登录
if (options.dataToken) {
console.log('jumpInfo.value', jumpInfo.value);
......@@ -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) => {
uni.showLoading({
title: '加载中...'
......@@ -118,52 +174,7 @@
uni.setStorageSync('cffp_userId', res.data.userId);
uni.setStorageSync('uni-token', res.data['token']);
uni.setStorageSync('visitorUuid', res.data['visitorUuid']);
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` })
}
// 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`
})
}
gotoLandingPage(landingPage)
} else {
//内嵌带的code失效了,用户需要重新登录
if(res.data.commonResult&&res.data.commonResult.errorCode=='1101'){
......
......@@ -265,7 +265,7 @@
this.userShareQuery();
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -668,7 +668,7 @@
},
onShow() {
if (uni.getStorageSync('loginType') == 'codelogin') {
if (uni.getStorageSync('loginType') != 'visitor') {
this.queryInfo()
}
// #ifdef H5
......
......@@ -267,7 +267,7 @@
this.commissionType = option.commissionType;
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -78,7 +78,7 @@
};
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -68,7 +68,7 @@
}
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
if(this.companyType == '1'){
......
......@@ -355,7 +355,7 @@
queryUserInfoAndPermission();
});
onShow(()=>{
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
queryInfo()
}
})
......
......@@ -74,7 +74,7 @@
}
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -285,7 +285,7 @@
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -212,7 +212,7 @@
this.getqueryTeamAchievement()
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -175,11 +175,12 @@
import common from "../../common/common";
import tabBar from '../../components/tabBar/tabBar.vue';
import api from "@/api/api";
import { companyInfo, shareURL } from "@/environments/environment";
import { companyInfo, shareURL, workbenchUrl } from "@/environments/environment";
import FloatingButton from '@/components/FloatingButton/FloatingButton.vue';
import JoinPopup from '@/components/commonPopup/JoinPopup.vue';
import PartnerTipPopup from "@/components/commonPopup/PartnerTipPopup.vue";
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
import { getSsoToken, issueWorkbenchTicket } from "@/util/sso";
import restrictedTip from '@/components/commonPopup/restrictedTip.vue';
import wx from 'weixin-js-sdk'
export default {
......@@ -337,6 +338,15 @@
id: '04',
categoryName: '海外资产配置',
children: [{
// 港险转介人工作台:独立 H5,点击后整屏跳转(见 goDetail 的 workbench 分支)
title: '港险工作台',
icon: 'icon-shield',
link: '',
isOpen: true,
isShow: true,
workbench: true
},
{
title: '积分明细',
icon: 'icon-yongjin',
link: '/myPackageA/salary/salaryList',
......@@ -725,6 +735,14 @@
return
}
// 港险转介人工作台是独立 H5(Casdoor OIDC 自管登录态):
// 整屏顶层跳转,不做 iframe(避免第三方 cookie / 微信内核限制)。
// 走到这里已过上面的 CFFP 登录拦截,满足"先登录 CFFP 再进工作台"。
if (item.workbench) {
this.openWorkbench()
return
}
if (item.isShow && item.isOpen) {
if (item.title === '我的邀请码') {
this.$refs.popup1.open('bottom');
......@@ -735,6 +753,46 @@
common.errorDialog(2, '该模块正在开发中,敬请期待!', '提示');
}
},
// 整屏打开港险转介人工作台(独立 H5,不嵌 iframe)
openWorkbench() {
const url = workbenchUrl;
if (!url) {
common.errorDialog(2, '港险工作台暂未开放,敬请期待!', '提示');
return;
}
dataHandling.pocessTracking(
'港险工作台',
`用户从我的页进入港险工作台`,
'点击',
2,
'我的',
'pages/personalCenter/personalCenter'
)
// D11 票桥接力:已持 Casdoor token(经 cffp 票桥免登进来)时,先向工作台后端
// (与 workbench_url 同源的 /csf/api)换一次性票据,落 /auth/ticket 建会话——
// 全程不再经过 Casdoor 登录页;无 token 或换票失败则回落直连(工作台自身 OIDC 登录照旧)。
const navigate = (target) => {
// #ifdef APP-PLUS
// APP 内复用通用 web-view 整屏页
uni.navigateTo({
url: '/components/webview?url=' + encodeURIComponent(target)
});
// #endif
// #ifndef APP-PLUS
// H5(含微信小程序 web-view 内、普通浏览器):replace 顶层跳转、不压历史栈,
// 避免微信内核脏历史快照恢复后「我的」页菜单入口丢失
window.location.replace(target);
// #endif
}
if (getSsoToken()) {
const csfApiBase = url.replace(/\/+$/, '') + '/csf/api'
issueWorkbenchTicket(csfApiBase)
.then((ticket) => navigate(url + 'auth/ticket?ticket=' + encodeURIComponent(ticket) + '&redirect=' + encodeURIComponent('/')))
.catch(() => navigate(url))
} else {
navigate(url)
}
},
ckidentity(item) {
if (item.identity == true && this.customerBasicInfo.partnerType == null) {
dataHandling.pocessTracking(
......
......@@ -55,7 +55,7 @@
}
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
this.userInfo = JSON.parse(uni.getStorageSync('cffp_userInfo'))
......
......@@ -37,7 +37,7 @@
return {}
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -26,6 +26,10 @@
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
import api from "@/api/api";
import restrictedTip from '@/components/commonPopup/restrictedTip.vue';
// #ifdef H5
import wx from 'weixin-js-sdk'
import * as sso from '@/util/sso'
// #endif
export default {
components:{ MenuList,restrictedTip, },
data() {
......@@ -59,7 +63,7 @@
}
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......@@ -115,6 +119,23 @@
});
},
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({
title: '退出登录',
content: '确定要退出登录吗?',
......
......@@ -178,7 +178,7 @@
// this.optionForm = this.tempInfo.optionForm = JSON.parse(options.customerBasicInfo)
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -186,7 +186,7 @@
this.queryByUserIdFortuneStatistic();
this.getCommissionType()
this.getDetail()
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -79,7 +79,7 @@
restrictedTip
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -297,7 +297,7 @@
let app22 = getCurrentPages().length
this.userCourseCount()
this.userCourseList()
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -55,7 +55,7 @@
this.querySystemMessage();
},
onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
this.querySystemMessage();
......
......@@ -47,7 +47,7 @@
this.getSystemMsgDetail();
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -72,7 +72,7 @@
}
},
onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -99,7 +99,7 @@
this.goFortuneWithdrawal()
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -229,7 +229,7 @@
}
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -116,7 +116,7 @@
this.calcuteData = uni.getStorageSync('calcuteData') ? JSON.parse(uni.getStorageSync('calcuteData')) : null;
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -377,7 +377,7 @@
this.provCityQry();
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -98,7 +98,7 @@
restrictedTip,
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -65,7 +65,7 @@
restrictedTip,
},
onShow(){
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
// #ifdef H5
......
......@@ -664,7 +664,7 @@
},
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if(uni.getStorageSync('loginType')!='visitor'){
this.queryInfo()
}
if(uni.getStorageSync('resIrrAndSimpleResInfos')){
......
......@@ -93,15 +93,16 @@
// };
// }
// });
// }
// 旧版的拦截器
// }
// 旧版的拦截器
import {apiURL,cffpURL,sfpUrl} from "../environments/environment";
import api from "@/api/api";
import * as sso from "@/util/sso";
// 白名单,不需要携带token就允许被访问的接口
const whiteApiList = [`${apiURL}/authorize/obtainToken`,
`${apiURL}/authorize/checkToken`,
const whiteApiList = [`${apiURL}/authorize/obtainToken`,
`${apiURL}/authorize/checkToken`,
`${cffpURL}/user/loginVerification`,
`${apiURL}/appVersion/checkIsUpdate`,
`${cffpURL}/accessLog/accessLogSave`,
......@@ -110,12 +111,34 @@ const whiteApiList = [`${apiURL}/authorize/obtainToken`,
`${apiURL}/verificationCode`,
`${sfpUrl}/sfp/sfpMain/pocessTracking`,
`${cffpURL}/partner/queryById`,
`${apiURL}/sso/ticket/consume`, // Casdoor 票据消费:匿名,唯一凭据是 ticket
];
export const interceptor = () => {
uni.addInterceptor('request', {
// 请求拦截器
invoke(args) {
invoke(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
if (!uni.getStorageSync('uni-token') && !whiteApiList.includes(args.url)) {
......@@ -153,9 +176,19 @@ export const interceptor = () => {
},
// 响应拦截器,可以对数据进行预处理
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('uni-token');
uni.removeStorageSync('uni-token');
uni.setStorageSync('loginType','visitor')
uni.switchTab({
url:'/pages/index/index'
......
/**
* Casdoor 统一身份·CFFP/SFP H5 侧(design D3):
* - /pages/auth/ticket 落地页用一次性票据换 Casdoor JWT,仅存内存(不落 localStorage)
* - sso 模式标志与业务 userId 存持久 storage(不含令牌、非敏感):web-view 被系统回收后
* 重载业务页时,内存令牌已丢而登录态「应在」,据此交原生重走票据,绝不静默降级 obtainToken
* - 401/T001:销毁 web-view,由原生 reLaunch 重走 wx.login→票据闭环
* 普通浏览器直连票据 URL 也可消费;但无 wx.miniProgram 可回时降级跳 H5 登录页。
*/
import wx from 'weixin-js-sdk'
import { apiURL } from '@/environments/environment'
import dataHandling from '@/util/dataHandling'
const MODE_KEY = 'cffp_sso_mode'
let casdoorToken: string | null = null
let relogining = false
/**
* 建立 SSO 会话:令牌只进内存;非敏感登录态(模式标志、isLogin、业务 userId)
* 落持久 storage——web-view 被系统回收重载后内存令牌丢失,据此识别「登录态应在」,
* 拦掉无令牌请求并交原生重走票据,绝不静默降级 obtainToken 游客链路。
* loginType 写 'sso':作为第三种登录方式(codelogin/visitor/sso),让全局登录态
* UI 与「已登录才拉 queryInfo」门禁天然识别;code 登录专属链路仍显式比对 codelogin。
*/
export const setSsoToken = (token: string, userId: number | string) => {
casdoorToken = token
uni.setStorageSync(MODE_KEY, '1')
uni.setStorageSync('isLogin', '1')
uni.setStorageSync('loginType', 'sso')
uni.setStorageSync('cffp_userId', userId)
}
export const getSsoToken = (): string | null => casdoorToken
/**
* 票桥接力(referrer-portal-api design D11):用内存中的 Casdoor token 向工作台后端
* (csf-api,与 workbench_url 同源)换一次性票据,使「CFFP → 工作台」免 Casdoor 登录页。
* 跨域携带 Authorization,服务端按 referrer.ticket.allowed-origins 白名单放行本 H5 来源。
* 失败仅 reject 不跳转——调用方降级为直连工作台(照旧走工作台自身 OIDC 登录)。
* 注意响应是 csf 的 Result 形态 {code:200,msg,data:{ticket}}(区别于 cffp 票桥的 success 字段)。
*/
export const issueWorkbenchTicket = (csfApiBase: string): Promise<string> =>
new Promise((resolve, reject) => {
if (!casdoorToken) {
reject(new Error('无 Casdoor 令牌,无法签发工作台票据'))
return
}
uni.request({
url: `${csfApiBase}/c/sso/ticket/issue`,
method: 'POST',
data: {},
header: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${casdoorToken}`
},
success: (res: any) => {
const data = res.data && res.data.code === 200 ? res.data.data : null
const ticket = data && data.ticket
ticket ? resolve(ticket) : reject(new Error('工作台票据签发失败: ' + (res.data && res.data.msg)))
},
fail: () => reject(new Error('工作台票据签发网络失败'))
})
})
export const isSsoMode = (): boolean => uni.getStorageSync(MODE_KEY) === '1'
export const clearSso = () => {
casdoorToken = null
uni.removeStorageSync(MODE_KEY)
uni.removeStorageSync('isLogin')
uni.removeStorageSync('cffp_userId')
// 回到 H5 老链路的游客语义
uni.setStorageSync('loginType', 'visitor')
}
export const isMiniprogram = (): boolean => {
// #ifdef H5
return dataHandling.h5RuntimeEnv() === 'wechat-miniprogram'
// #endif
// #ifndef H5
return false
// #endif
}
/** 一次性票据换 Casdoor 令牌与业务 userId(匿名接口,唯一凭据是票据本身) */
export const consumeTicket = (ticket: string): Promise<{token: string, userId: number | string}> =>
new Promise((resolve, reject) => {
uni.request({
url: `${apiURL}/sso/ticket/consume?ticket=${encodeURIComponent(ticket)}`,
method: 'GET',
success: (res: any) => {
const data = res.data && res.data.success ? res.data.data : null
data && data.token && data.userId != null
? resolve({ token: data.token, userId: data.userId })
: reject(new Error('票据无效、已过期或已使用'))
},
fail: () => reject(new Error('票据消费网络失败'))
})
})
/** 当前应用内路径(剥 history base),供原生重走票据后精确回跳 */
export const currentAppPath = (): string => {
const path = window.location.pathname + window.location.search
const m = path.match(/\/((?:pages|myPackageA|myPackageB|sfp)\/.*)/)
return m ? '/' + m[1] : '/pages/index/index'
}
/**
* 通知原生销毁 web-view 重走票据(design D3 重登闭环)。
* 非小程序环境无法回原生:清理 sso 态并降级 H5 登录页。
*/
export const reloginViaMiniprogram = (appPath?: string) => {
if (relogining) return
const redirect = appPath || currentAppPath()
// #ifdef H5
if (isMiniprogram()) {
relogining = true
wx.miniProgram.reLaunch({
url: `/pages/launch/index?ssoRelogin=1&cffpRedirect=${encodeURIComponent(redirect)}`
})
return
}
// #endif
clearSso()
uni.reLaunch({ url: '/myPackageA/login/login' })
}
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