Commit 8d80bd36 by yuzhenWang

Merge branch 'feature-20260203-解决外部跳转页面登录问题' into 'dev'

修复小程序跳转到cffp支付订单bug

See merge request !88
parents ceb9e782 42c6d16b
......@@ -15,6 +15,9 @@
},
onLaunch: function() {
console.log('App Launch');
if(uni.getStorageSync('dataToken')){
uni.removeStorageSync('dataToken')
}
if(!uni.getStorageSync('loginType')){
uni.setStorageSync('loginType','visitor');
}
......@@ -104,6 +107,7 @@
'/pages/orderDetail/orderDetail',
'/pages/orderStatus/orderStatus',
'/pages/index/index',
'pages/lanch/index',
'/myPackageA/poster/poster',
] // 根据需要调整
if(!whiteList.includes(currentRoute)) {
......@@ -142,6 +146,7 @@
if(res['success']){}else{
api.obtainToken().then(res=>{
if(res.success){
uni.setStorageSync('uni-token',res.data['token']);
}
})
......@@ -228,7 +233,7 @@
//家办商城跳转登录状态下
if(params.dataToken){
// this.dataToken = params.dataToken
uni.setStorageSync('dataToken',params.dataToken);
uni.setStorageSync('dataToken',decodeURIComponent(params.dataToken));
}
//家办商城跳转未登录状态下
if(params.noLogin){
......
......@@ -141,7 +141,7 @@
<text>{{showName}}</text>
</view>
</view>
<view v-if="mpCffp" class="shareBuyBox">
<view v-if="mpCffp" class="shareBuyBox">
<view class="rightShare" @click="reinvite">
<loadingIcon
:loading="isLoading"
......@@ -428,6 +428,7 @@
this.userId = uni.getStorageSync('cffp_userId')
const shareCode = nanoid() + this.userId
const jumptime = Date.parse(new Date()) / 1000
if(this.mpCffp){
if(uni.getStorageSync('posterItem')){
this.shareItem = JSON.parse(JSON.stringify(uni.getStorageSync('posterItem')))
......@@ -708,35 +709,26 @@
'产品详情',
'pages/courseDetail/courseDetail'
)
// 如果是商城跳转到cffp得购买直接弹出海报框
if(this.mpCffp){
if(uni.getStorageSync('posterItem')){
this.shareItem = JSON.parse(JSON.stringify(uni.getStorageSync('posterItem')))
}
let dataToken = uni.getStorageSync('uni-token')
// 因为是从家办商城小程序跳转到cffp的,所以这里购买要带家办商城的token,
let dataToken = uni.getStorageSync('dataToken')
console.log('家办商城dataToken',dataToken);
this.posterShareTxt = '保存图片扫码下单'
this.posterDesTxt = '扫码下单'
let newLink = shareURL + `/pages/orderConfirm/orderConfirm?fileId=${this.fileId}&orderId=${this.orderId}&userId=${this.userId}&dataToken=${dataToken}`
let newLink = shareURL + `/pages/orderConfirm/orderConfirm?fileId=${this.fileId}&orderId=${this.orderId}&userId=${this.userId}&dataToken=${encodeURIComponent(dataToken)}`
// let newLink = shareURL + `/pages/lanch/index?fileId=${this.fileId}&orderId=${this.orderId}&userId=${this.userId}&dataToken=${encodeURIComponent(dataToken)}&landingPage=orderConfirm`
console.log('newLink',newLink);
this.qrCodeUrl = newLink
this.showImg = true
this.isOrderLoading = true,
this.posterImgType = 'orderPoster'
return
}
// 是由小程序的webview跳转过来的
// if (this.mpCffp) {
// let dataToken = uni.getStorageSync('uni-token')
// this.orderCodeUrl = shareURL + `/pages/orderConfirm/orderConfirm?fileId=${this.fileId}&orderId=${this.orderId}&userId=${this.userId}&dataToken=${dataToken}`
// // 这里需要与小程序的webview通信,不会写
// setTimeout(()=>{
// console.log('wx',wx);
// this.sendMessageToMiniProgram();
// },500)
// return
// }
uni.navigateTo({
url: `/pages/orderConfirm/orderConfirm?fileId=${this.fileId}&orderId=${this.orderId}&userId=${this.userId}`
})
......@@ -1352,6 +1344,7 @@
},
onLoad(option) {
this.sharePosterObj = uni.getStorageSync('sharePosterObj') || {};
// console.log('sharePosterObj======',this.sharePosterObj);
// 如果通过海报分享进入系统,海报分享人为合伙人且普通客户完成购买了,那么海报分享人可以获得销售佣金
......@@ -1395,6 +1388,7 @@
// this.switchTab(1);
},
onShow() {
this.isLoading = false
if(uni.getStorageSync('mpCffp')){
this.mpCffp = uni.getStorageSync('mpCffp')
......@@ -1418,6 +1412,7 @@
setWechatShare();
}, window.location.href);
// #endif
},
onReady() {
this.videoContext = uni.createVideoContext('myVideo');
......
......@@ -273,7 +273,9 @@
},
onShow() {
if(uni.getStorageSync('dataToken')){
this.dataToken = uni.getStorageSync('dataToken')
}
console.log('webview',typeof wx !== 'undefined' && wx.miniProgram);
this.loginType = uni.getStorageSync('loginType')
......@@ -297,9 +299,7 @@
})
},
onLoad(options) {
if(uni.getStorageSync('dataToken')){
this.dataToken = uni.getStorageSync('dataToken')
}
if(options.sharePoster){
dataHandling.pocessTracking(
'进入',
......@@ -449,7 +449,6 @@
}
},
init() {
console.log('this.dataToken',this.dataToken);
// 从家办商城跳转过来
if(this.dataToken){
this.reLogin()
......@@ -776,12 +775,12 @@
this.getOneProduct()
this.queryAreaCenterInfo()
this.dataToken = ''
uni.removeStorageSync('dataToken')
// uni.removeStorageSync('dataToken')
}else{
uni.showToast({
title: res['message'],
duration: 2000,
icon: 'none'
icon: 'none',
})
}
})
......
......@@ -7,14 +7,15 @@
import api from '@/api/api';
import { onLaunch, onLoad } from '@dcloudio/uni-app'
import * as environment from '@/environments/environment'
let dataToken = ref()
let jumpInfo = ref({})
onLoad((options) => {
// 参数带token了重新登录
if (options.dataToken) {
jumpInfo.value = JSON.parse(JSON.stringify(options))
// uni.clearStorageSync();
dataToken.value = options.dataToken
reLogin(options.landingPage)
}
})
......@@ -35,8 +36,6 @@
uni.setStorageSync('loginType', 'codelogin');
uni.setStorageSync('cffp_userId', res.data.userId);
uni.setStorageSync('uni-token', res.data['token']);
dataToken.value = ''
uni.removeStorageSync('dataToken')
if (landingPage == 'sfpHousePurchase') {
uni.reLaunch({ url: `/sfp/housePurchase/housePurchase` })
......@@ -49,6 +48,7 @@
duration: 2000,
icon: 'none'
})
uni.reLaunch({ url: `/pages/index/index` })
}
})
uni.hideLoading()
......
......@@ -206,6 +206,7 @@
amount: 0,
calculatedPrice: 0,
dataToken:'',
oldToken:'',//原始用户token
}
},
computed: {
......@@ -319,6 +320,12 @@
} else {
window.location.href = res['data']['paymentForm']['action'];
}
}else{
uni.showToast({
title: res['message'],
duration: 2000,
icon: 'none'
})
}
})
} else {
......@@ -339,6 +346,7 @@
provider: 'alipay',
orderInfo: aliOrderString,
success: function(resp) {
uni.navigateTo({
url: `/pages/orderStatus/orderStatus?orderId=${_this.orderId}&fileId=${_this.fileId}&orderStatus=2&userId=${_this.userId}&isRedirect=1`
})
......@@ -506,23 +514,31 @@
}, 500)
}
},
reLogin(){
reLogin(option,flag){
uni.showLoading({
title: '加载中...'
});
const params = {
loginType:'5',
authToken: this.dataToken
authToken: uni.getStorageSync('dataToken')
}
api.loginVerification(params).then((res)=>{
if(res['success']){
uni.setStorageSync('isLogin','1');
uni.setStorageSync('loginType','codelogin');
uni.setStorageSync('cffp_userId', res.data.userId);
uni.setStorageSync('uni-token', res.data['token']);
// 之前没使用过系统没有userid,登录并写入缓存
if(flag=='1'){
uni.setStorageSync('isLogin','1');
uni.setStorageSync('loginType','codelogin');
uni.setStorageSync('cffp_userId', res.data.userId);
uni.setStorageSync('uni-token', res.data['token']);
}else if(flag=='2'){
// 有userid,直接可以购买但付款人只是帮订单账号付钱,购买成功还是进入到付款人的账号
this.oldToken = uni.getStorageSync('uni-token')
uni.setStorageSync('oldToken', this.oldToken);
uni.setStorageSync('uni-token', res.data['token']);
}
this.userId = res.data.userId
this.dataToken = ''
uni.removeStorageSync('dataToken')
}else{
uni.showToast({
title: res['message'],
......@@ -539,17 +555,25 @@
if(uni.getStorageSync('dataToken')){
this.dataToken = uni.getStorageSync('dataToken')
}
if(uni.getStorageSync('dataToken')&&(!uni.getStorageSync('cffp_userId')||(uni.getStorageSync('cffp_userId')!=option.userId))){
if(uni.getStorageSync('dataToken')){
// 没有使用过系统或者之前使用过但未登录
if(!uni.getStorageSync('cffp_userId')|| (uni.getStorageSync('cffp_userId')&&uni.getStorageSync('loginType')=='visitor')){
this.reLogin(option,'1')
}else if(uni.getStorageSync('cffp_userId')!=option.userId){
// 付钱的人和分享的人不一样
this.reLogin(option,'2')
}
this.reLogin()
}
this.fileId = option.fileId;
this.fileId = Number(option.fileId);
this.orderId = option.orderId;
if (option.userId) {
this.userId = option.userId;
}
this.isRedirect = option.isRedirect;
if (this.isRedirect == 1 && option.userId) {
uni.request({
url: `${apiURL}/authorize/obtainToken`,
method: 'POST',
......@@ -564,9 +588,11 @@
}
}
});
}else{
this.courseDetailLoad(option);
}
},
onShow() {
// #ifdef H5
......
......@@ -4,7 +4,7 @@
<view class="successBox" v-if="orderStatus=='2'">
<i class="iconfont icon-dengdai"></i>
<text class="statusText">订单支付成功</text>
<text @click="viewDetail()" class="viewOrder">查看订单</text>
<text v-if="showOrder" @click="viewDetail()" class="viewOrder">查看订单</text>
</view>
<view class="failBox" v-if="orderStatus=='1'">
<text style="color:#F04604"><i class="iconfont icon-guanbi"></i>订单支付失败</text>
......@@ -68,7 +68,8 @@
userId:'',
isRedirect:'',
currentPage: '',
infoTotal:0
infoTotal:0,
showOrder:true
};
},
onShow() {
......@@ -83,6 +84,16 @@
// }else{
// this.infoTotal = 0
// }
//帮别人购买,成功后就不应该显示查看订单按钮,订单在别人的账号上
if(uni.getStorageSync('oldToken')){
this.showOrder = false
}
},
onUnload(){
if(uni.getStorageSync('oldToken')){
uni.setStorageSync('uni-token', uni.getStorageSync('oldToken'));
uni.removeStorageSync('oldToken')
}
},
methods:{
querySystemMessage() {
......@@ -144,7 +155,8 @@
this.orderId = options.orderId;
this.orderStatus = options.orderStatus;
this.fileId = options.fileId;
if(options.userId && options.userId != "undefined"){
// 没有oldToken代表支付订单人和提供订单人不是同一个人
if(options.userId && options.userId != "undefined"&&!uni.getStorageSync('oldToken')){
this.userId = options.userId;
uni.setStorageSync('cffp_userId', this.userId)
uni.request({
......
......@@ -27,12 +27,16 @@
</text>
<text
v-else-if="!customerBasicInfo.parentRealName&&customerBasicInfo.parentNickName">我的上级:{{customerBasicInfo.parentNickName}}</text>
</view>
<view class="desBox">{{customerBasicInfo.mobile}}</view>
</view>
</view>
</view>
<view class="right" @click="goDetail(settingItem)">
<!-- 小程序跳入到cffp不展示设置 -->
<view class="right" @click="goDetail(settingItem)" v-if="!mpCffp">
<view class="iconfont icon-shezhi " style="font-size: 40rpx;color: #fff;"></view>
</view>
</view>
......@@ -180,6 +184,7 @@
export default {
data() {
return {
mpCffp:'',
showMyName: '',
msgTotal: 0,
messageInfo: [],
......@@ -397,6 +402,9 @@
},
onShow() {
this.loginType = uni.getStorageSync('loginType')
if(uni.getStorageSync('mpCffp')){
this.mpCffp = uni.getStorageSync('mpCffp')
}
if (this.companyType == '1') {
this.companyLogo = '../../static/myteam/Group1633.png';
} else if (this.companyType == '2') {
......@@ -453,6 +461,7 @@
setWechatShare();
}, window.location.href);
// #endif
console.log('mpcffp',this.mpCffp);
},
methods: {
......@@ -858,7 +867,7 @@
}
this.inviteEqrode = this.customerBasicInfo.invitationCode;
uni.setStorageSync('user_mobile', res.data.mobile)
console.log('this.mainMenuLists', this.mainMenuLists);
console.log('this.customerBasicInfo', this.customerBasicInfo);
} else {
uni.setStorageSync('loginType', 'visitor')
......
......@@ -318,7 +318,7 @@ export default{
//家庭成员id
// familyMemberId: familyMemberId,
//
modelType: modelType ? modelType : pages[pages.length - 1]?.$page?.options?.modelType,
modelType: modelType ? modelType : pages[pages.length - 1]?.options?.modelType,
//模块页面
// modelPage: modelPage?modelPage:pages[pages.length - 1]?.$page?.options?.modelPage,
modelPage: '',
......
......@@ -19,6 +19,7 @@ const whiteList = [
'/pages/courselist/courselist',
'/pages/personalCenter/helpCenter',
'/pages/index/index',
'pages/lanch/index',
'/myPackageA/poster/poster',
]
export default function initApp(){
......
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