Commit 8d80bd36 by yuzhenWang

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

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

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