Commit 2b95f091 authored by 俞嘉婷's avatar 俞嘉婷

免登逻辑

parent 2df13986
{"proSetting":{"projectxIDs":{"testId":[{"label":"测试","value":"pa1ce2110"}],"prodId":[{"label":"线上测试","value":"p8d9bf93b"},{"label":"线上正式","value":"peb5290b6"}]},"skinVariables":[],"mockSetting":{"projectId":"","pageId":""}},"envSetting":{},"psdSetting":{"psdFSSetting":true,"psdCenterSetting":true}} {"proSetting":{"projectxIDs":{"testId":[{"label":"测试","value":"p2c32b821"}],"prodId":[{"label":"线上测试","value":"p8d9bf93b"},{"label":"线上正式","value":"peb5290b6"}]},"skinVariables":[],"mockSetting":{"projectId":"","pageId":""}},"envSetting":{},"psdSetting":{"psdFSSetting":true,"psdCenterSetting":true}}
{"proName":"太保-端午节-20250429","proDesc":"","proPath":"/Users/yujiating/Documents/programme/太保-端午节-20250429","createTime":1745912031535} {"proName":"太保-守护人生-20250711","proDesc":"","proPath":"/Users/yujiating/Documents/programme/太保-守护人生-20250714/20250711_tbguardinglife","createTime":1745912031535}
...@@ -6,9 +6,9 @@ import { md5 } from '@spark/utils'; ...@@ -6,9 +6,9 @@ import { md5 } from '@spark/utils';
import { CHANNEL_PARAMS } from '@src/utils/constants'; import { CHANNEL_PARAMS } from '@src/utils/constants';
import API from '@src/api'; import API from '@src/api';
import './middlePageNew.less'; import './middlePageNew.less';
import { _throttle, getUrlParam, isWechatMini } from '@src/utils/utils'; import { _throttle, getUrlParam, isWechatMini, windowJumpUrl } from '@src/utils/utils';
import WxOpenModule from '@src/components/wxOpenModule/wxOpenModule'; import WxOpenModule from '@src/components/wxOpenModule/wxOpenModule';
import { onInitShare } from '@src/utils/share'; import { miniGoUrl, onInitShare } from '@src/utils/share';
import { ensureDomain, domain } from '@spark/dbdomain'; import { ensureDomain, domain } from '@spark/dbdomain';
@observer @observer
class MiddlePage extends React.Component { class MiddlePage extends React.Component {
...@@ -16,6 +16,8 @@ class MiddlePage extends React.Component { ...@@ -16,6 +16,8 @@ class MiddlePage extends React.Component {
super(props); super(props);
this.state = { this.state = {
isWeixinMini: false, isWeixinMini: false,
dataInfo:{},
callBackUrl:'',
}; };
} }
...@@ -46,20 +48,17 @@ class MiddlePage extends React.Component { ...@@ -46,20 +48,17 @@ class MiddlePage extends React.Component {
const empnoShow = getUrlParam("empnoShow"); const empnoShow = getUrlParam("empnoShow");
let actUrl = getUrlParam("actUrl") && getUrlParam("actUrl") != 'null' ? decodeURIComponent(getUrlParam("actUrl")) : CFG.index; let actUrl = getUrlParam("actUrl") && getUrlParam("actUrl") != 'null' ? decodeURIComponent(getUrlParam("actUrl")) : CFG.index;
// console.log(actUrl); //接口重定向地址
const jumpUrl = decodeURIComponent(decodeURIComponent(decodeURIComponent(getUrlParam("redirectUrl")))) || CFG.index; let directUrl = `${actUrl}&channel=${channel}&empno=${empno}&empname=${empname}&wdTK=${wdTK}&isFromShare=${isFromShare}&empnoShow=${empnoShow}`
let directUrl = encodeURIComponent(
encodeURIComponent(
actUrl +
`&channel=${channel}&empno=${empno}&empname=${empname}&wdTK=${wdTK}&isFromShare=${isFromShare}&empnoShow=${empnoShow}`
)
);
// alert(actUrl); // 用不到了
// alert(directUrl); // const middleUrl = CFG.projectId == 'pa77ad6bf' ? CFG.middleTestPage : CFG.middleProdPage;
console.info("这是直接跳转的链接", directUrl); // const callBackUrl = `${middleUrl}&redirectUrl=${actUrl}&channel=${channel}&empno=${empno}&empname=${empname}&wdTK=${wdTK}&isFromShare=${isFromShare}&empnoShow=${empnoShow}`
// this.setState({callBackUrl})
// console.info("这是直接跳转的链接", directUrl);
if (channel == CHANNEL_PARAMS.THD_MINI) { if (channel == CHANNEL_PARAMS.THD_MINI) {
//太好店渠道
const thirdParam = JSON.parse(decodeURIComponent(getUrlParam("thdParam"))); const thirdParam = JSON.parse(decodeURIComponent(getUrlParam("thdParam")));
let newEmpno = thirdParam.empno; let newEmpno = thirdParam.empno;
let newEmpname = thirdParam.empname; let newEmpname = thirdParam.empname;
...@@ -68,14 +67,11 @@ class MiddlePage extends React.Component { ...@@ -68,14 +67,11 @@ class MiddlePage extends React.Component {
let custPhone = thirdParam.custPhone let custPhone = thirdParam.custPhone
let token = getUrlParam("token") let token = getUrlParam("token")
let newWdTK = decodeURIComponent(getUrlParam("wdTK")) let newWdTK = decodeURIComponent(getUrlParam("wdTK"))
// JSON.parse(decodeURIComponent(getUrlParam("wdTK"))); // console.error("kankancanshu", thirdParam, custPhone)
// alert("thirdParam " + thirdParam + "123 " + custPhone) // console.info('---sign',getUrlParam("thdParam") + timestamp + "24fnTNEK8KqURnlZhIJ58mdylVe1rs0BZha")
console.error("kankancanshu", thirdParam, custPhone)
// location.href = `${CFG.middleTHRequest}requestParam=${requestParam}&redirect=${directUrl}&channel=${channel}&sign=${sign}&timestamp=${timestamp}&empno=${newEmpno}&empname=${newEmpname}&openid=${openId}&wdTK=${newWdTK}&empnoShow=${newEmpnoShow}&custPhone=${custPhone}`;
console.info('---sign',getUrlParam("thdParam") + timestamp + "24fnTNEK8KqURnlZhIJ58mdylVe1rs0BZha")
const {success, data} = await API.thdLoginNew({ const {success, data} = await API.thdLoginNew({
requestParam:encodeURIComponent(getUrlParam("thdParam")), requestParam:encodeURIComponent(getUrlParam("thdParam")),
redirect:decodeURIComponent(directUrl), redirect: encodeURIComponent(directUrl),
channel:channel, channel:channel,
sign:md5(getUrlParam("thdParam") + timestamp + "24fnTNEK8KqURnlZhIJ58mdylVe1rs0BZha"), sign:md5(getUrlParam("thdParam") + timestamp + "24fnTNEK8KqURnlZhIJ58mdylVe1rs0BZha"),
timestamp:timestamp, timestamp:timestamp,
...@@ -86,37 +82,105 @@ class MiddlePage extends React.Component { ...@@ -86,37 +82,105 @@ class MiddlePage extends React.Component {
empnoShow:newEmpnoShow, empnoShow:newEmpnoShow,
custPhone:custPhone, custPhone:custPhone,
token:token, token:token,
authToken:'P_PT_PHONE_THD25DragonBoat', authToken:'P_PT_PHONE_THD25GuardingLife',
environment:CFG.environment, environment:CFG.environment,
// environment:CFG.projectId == 'pd5fd3088' ? 'test' : ''
}) })
if(success){ if(success){
if(data?.boolLogin){ // 已登录 this.setState({dataInfo:data},()=>{
location.href = data?.autoLoginUrl; //免登录链接 this.handleToGo2()
}else{ })
location.href = data?.authUrl; //授权地址
}
} }
}else{ }else{
const { success, data } = await API.tbLoginNew({ const { success, data } = await API.tbLoginNew({
token: getUrlParam("token"), token: getUrlParam("token"),
src: "d8", src: "d8",
redirectUrl: directUrl, redirectUrl: encodeURIComponent(encodeURIComponent(directUrl)),
}); });
if (success) { if (success) {
if (data?.loginFlag) { console.info('----data', data);
location.href = data?.autoLoginUrl; this.setState({dataInfo:data},()=>{
} // this.handleToGo2()
})
} else { } else {
} }
} }
// 这个活动投太好店
// let targetUrl = `${CFG.middleRequest}requestParam=${requestParam}&redirect=${directUrl}&channel=${channel}&sign=${sign}&timestamp=${timestamp}&empno=${empno}&empname=${empname}&wdTK=${wdTK}`;
// if (param && param != "changHangParam") targetUrl += `&chparam=${param}`;
// location.href = targetUrl;
}
//授权三合一(登录、授权、兴趣收集合并) 6.22迭代
handleAuthOrize = (token) => {
if(getUrlParam('channel') == CHANNEL_PARAMS.THD_MINI){
const link = `${CFG.originUrl}/cpicactivity/#/mini-auth-loading?isCollect=1&token=${token}&gwAuthToken=P_PT_PHONE_THD25GuardingLife&channel=${CFG.channel}`
// alert(link)
windowJumpUrl(link)
}else{
const link2 = `/packageAgent/pages/loading/loading?gwAuthToken=P_PT_PHONE_25GuardingLife&channel=${CFG.channel}`
console.info("官微小程序2", link2);
// alert(link)
wx?.miniProgram?.navigateTo({ url: link2 });
}
};
handleToGo2 = () =>{
const {dataInfo} = this.state;
if(getUrlParam('channel') == CHANNEL_PARAMS.THD_MINI){
const { boolLogin, authBaseFlag, interestCollectionFlag, authUrl, autoLoginUrl, token} = dataInfo;
if(!boolLogin || !authBaseFlag || !interestCollectionFlag){
this.handleAuthOrize(token)
}else{
// location.href = autoLoginUrl; //免登录链接
location.replace(autoLoginUrl)
}
}else{
const { loginFlag, authBaseFlag, interestCollectionFlag, autoLoginUrl, } = dataInfo;
if (!loginFlag || !authBaseFlag || !interestCollectionFlag) {
this.handleAuthOrize()
}else{
// location.href = autoLoginUrl;
location.replace(autoLoginUrl)
}
}
} }
//授权头像昵称
handleGetUserInfo = (backUrl, token) => {
if(getUrlParam('channel') == CHANNEL_PARAMS.THD_MINI){
// const link2 = `/kydraw/pages/gwndhd/index?url=${encodeURIComponent(backUrl)}`
const link2 = '/kydraw/pages/gwndhd/index?url='+encodeURIComponent(backUrl)
// alert('授权头像昵称')
// alert(
// `${CFG.originUrl}/sxwxauthentication/wx-thirdAuth/silentForMini?rUrl=${encodeURIComponent(link2)}&src=sxwx2db&token=${token}`
// )
windowJumpUrl(
`${CFG.originUrl}/sxwxauthentication/wx-thirdAuth/silentForMini?rUrl=${encodeURIComponent(link2)}&src=sxwx2db&token=${token}`
)
}else{
console.info("授权头像昵称");
const link2 = `/pages/webviewByToken/index?url=${backUrl}`
miniGoUrl(`/packageMember/pages/avatarNameAuthorization/avatarNameAuthorization/index?isskip=0&backurl=${encodeURIComponent(link2)}`);
}
};
// 跳转兴趣收集页面
handleInterestCollection = (backUrl, token) => {
if(getUrlParam('channel') == CHANNEL_PARAMS.THD_MINI){
const link2 = `/kydraw/pages/gwndhd/index?url=${encodeURIComponent(backUrl)}`
windowJumpUrl(
`${CFG.originUrl}/cpicactivity/#/mini-auth-loading?pageCode=interestComponent&backurl=${encodeURIComponent(link2)}&token=${token}`
)
}else{
console.info("跳转兴趣收集页面官微");
const link2 = `/pages/webviewByToken/index?url=${encodeURIComponent(backUrl)}`
// alert(`/pages/webviewByToken/index?url=${encodeURIComponent(`${CFG.originUrl}/cpicactivity/#/mini-auth-loading?pageCode=interestComponent&backurl=${encodeURIComponent(link2)}`)}`);
miniGoUrl(`/pages/webviewByToken/index?url=${encodeURIComponent(`${CFG.originUrl}/cpicactivity/#/mini-auth-loading?pageCode=interestComponent&backurl=${encodeURIComponent(link2)}`)}`);
}
};
// 判断是否为微信小程序环境
juageWeixin = async () => { juageWeixin = async () => {
const env = await isWechatMini(); const env = await isWechatMini();
console.error(env, "这个有问题??"); console.error(env, "这个有问题??");
...@@ -126,37 +190,70 @@ class MiddlePage extends React.Component { ...@@ -126,37 +190,70 @@ class MiddlePage extends React.Component {
isWeixinMini, isWeixinMini,
}); });
}; };
// 获取登录小程序路径
getWeixinMiniPath = () => { getWeixinMiniPath = () => {
let path = ""; let path = "";
const { isWeixinMini } = this.state; const { isWeixinMini } = this.state;
console.info( console.info(
"这是path", "这是path",
`/packageMember/pages/bindPhone/thirdBindPhone/thirdBindPhone?gwAuthToken=P_PT_PHONE_25DragonBoat` `/packageMember/pages/bindPhone/thirdBindPhone/thirdBindPhone?gwAuthToken=P_PT_PHONE_25GuardingLife`
); );
if (isWeixinMini) { if (isWeixinMini) {
//官微小程序 //官微小程序
CFG.miniAppid = "wx68b00bbff4c69cc9"; //生产appid wx68b00bbff4c69cc9 测试appid: wx0fe22fef352fafc1 CFG.miniAppid = "wx68b00bbff4c69cc9"; //生产appid wx68b00bbff4c69cc9 测试appid: wx0fe22fef352fafc1
CFG.miniUserName = "gh_70448c19370c"; CFG.miniUserName = "gh_70448c19370c";
path = `/packageMember/pages/bindPhone/thirdBindPhone/thirdBindPhone?gwAuthToken=P_PT_PHONE_25DragonBoat&channel=${CFG.channel}`; path = `/packageMember/pages/bindPhone/thirdBindPhone/thirdBindPhone?gwAuthToken=P_PT_PHONE_25GuardingLife&channel=${CFG.channel}`;
} else { } else {
//H5默认跳转官微小程序 //H5默认跳转官微小程序
CFG.miniAppid = "wx68b00bbff4c69cc9"; CFG.miniAppid = "wx68b00bbff4c69cc9";
CFG.miniUserName = "gh_70448c19370c"; CFG.miniUserName = "gh_70448c19370c";
path = `/packageMember/pages/bindPhone/thirdBindPhone/thirdBindPhone?gwAuthToken=P_PT_PHONE_25DragonBoat&channel=${CFG.channel}`; path = `/packageMember/pages/bindPhone/thirdBindPhone/thirdBindPhone?gwAuthToken=P_PT_PHONE_25GuardingLife&channel=${CFG.channel}`;
} }
window.myAlert && window.myAlert(path); window.myAlert && window.myAlert(path);
return path; return path;
}; };
// 跳转逻辑处理 用不到了
handleToDraw = _throttle(() => { handleToGo = _throttle(() => {
const { isWeixinMini } = this.state; const {callBackUrl, dataInfo} = this.state;
console.info("跳转-->", isWeixinMini, this.getWeixinMiniPath()); if(getUrlParam('channel') == CHANNEL_PARAMS.THD_MINI){
if (!isWeixinMini) return; //H5走组件的能力,小程序内直接跳转 const { boolLogin, authBaseFlag, interestCollectionFlag, authUrl, autoLoginUrl, token} = dataInfo;
wx?.miniProgram?.navigateTo({ url: this.getWeixinMiniPath() }); if(boolLogin){ // 已登录
// wx.miniProgram.navigateTo({ url: url }); if(!authBaseFlag){
this.handleGetUserInfo(callBackUrl, token)
return;
}
// if(!interestCollectionFlag){
// this.handleInterestCollection(callBackUrl, token)
// return
// }
location.href = autoLoginUrl; //免登录链接
}else{
location.href = authUrl; //授权地址
}
}else{
const { loginFlag, authBaseFlag, interestCollectionFlag, autoLoginUrl, } = dataInfo;
if (loginFlag) {
if(!authBaseFlag){
this.handleGetUserInfo(callBackUrl)
return;
}
// if(!interestCollectionFlag){
// this.handleInterestCollection(callBackUrl)
// return
// }
location.href = autoLoginUrl;
}else{
const { isWeixinMini } = this.state;
console.info("跳转-->", isWeixinMini, this.getWeixinMiniPath());
if (!isWeixinMini) return; //H5走组件的能力,小程序内直接跳转
wx?.miniProgram?.navigateTo({ url: this.getWeixinMiniPath() });
// wx.miniProgram.navigateTo({ url: url });
}
}
}); });
render() { render() {
const { isWeixinMini } = this.state; const { isWeixinMini } = this.state;
...@@ -165,15 +262,15 @@ class MiddlePage extends React.Component { ...@@ -165,15 +262,15 @@ class MiddlePage extends React.Component {
<div className="middlePageNew"> <div className="middlePageNew">
<div className={`${channel == CHANNEL_PARAMS.THD_MINI ? 'bg' : 'bg1'}`}> <div className={`${channel == CHANNEL_PARAMS.THD_MINI ? 'bg' : 'bg1'}`}>
{/* <div className="btn"></div> */} {/* <div className="btn"></div> */}
<div className="btn" onClick={this.handleToDraw}> <div className="btn" onClick={this.handleToGo2}>
{!isWeixinMini && ( {/* {!isWeixinMini && (
<WxOpenModule <WxOpenModule
id={"downLoadbtn"} id={"downLoadbtn"}
appid={CFG.miniAppid} appid={CFG.miniAppid}
username={CFG.miniUserName} username={CFG.miniUserName}
envVersion={CFG.miniEnv} envVersion={CFG.miniEnv}
path={this.getWeixinMiniPath()}></WxOpenModule> path={this.getWeixinMiniPath()}></WxOpenModule>
)} )} */}
</div> </div>
</div> </div>
</div> </div>
......
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