feat(app): 添加公众号 AppId配置并优化登录逻辑

- 在 appConfig 中添加 appIdPublic 字段用于存储公众号 AppId
- 修改 codeLogin 和 passwordLogin 页面,支持获取和使用公众号 AppId
- 更新 order/detail 页面,从 store 中获取公众号 AppId
This commit is contained in:
fhysy 2025-03-12 17:55:36 +08:00
parent 6f156df9a8
commit 54740328e8
4 changed files with 37 additions and 11 deletions

View File

@ -120,7 +120,7 @@
tenantEnabled:true,
query:{},
isTenant: true,
appid:'',
appIdMini:'',
smsLoading:false,
loading:false,
icpLicense:'',
@ -134,7 +134,7 @@
onLoad(e) {
// #ifdef MP-WEIXIN
const accountInfo = uni.getAccountInfoSync();
this.appid = accountInfo.miniProgram.appId;
this.appIdMini = accountInfo.miniProgram.appId;
// #endif
if(e){
this.query = e;
@ -206,6 +206,7 @@
let logo = '';
let title = '';
let icpLicense = '';
let appIdPublic = '';
// #ifdef H5
if(this.query.tenantId){
this.form.tenantId = this.query.tenantId;
@ -214,6 +215,7 @@
logo = item.logo;
title = item.companyName;
icpLicense = item.icpLicense || '';
appIdPublic = item.appIdPublic || '';
}
});
this.isTenant = false;
@ -222,6 +224,7 @@
logo = data.voList[0].logo;
title = data.voList[0].companyName;
icpLicense = data.voList[0].icpLicense || '';
appIdPublic = data.voList[0].appIdPublic || '';
this.isTenant = false;
} else if (data.voList != null && data.voList.length !== 0) {
this.form.tenantId = data.voList[0].tenantId;
@ -229,17 +232,19 @@
logo = data.voList[0].logo;
title = data.voList[0].companyName;
icpLicense = data.voList[0].icpLicense || '';
appIdPublic = data.voList[0].appIdPublic || '';
}
// #endif
// #ifdef MP-WEIXIN
if(this.appid){
if(this.appIdMini){
let isAppid = true;
data.voList.forEach((item) => {
if (item.appId === this.appid) {
if (item.appId === this.appIdMini) {
this.form.tenantId = item.tenantId;
logo = item.logo;
title = item.companyName;
icpLicense = item.icpLicense || '';
appIdPublic = item.appIdPublic || '';
isAppid = false;
}
});
@ -247,6 +252,7 @@
this.form.tenantId = data.voList[0].tenantId;
this.activeTenantObj = data.voList[0];
icpLicense = data.voList[0].icpLicense || '';
appIdPublic = data.voList[0].appIdPublic || '';
logo = data.voList[0].logo;
title = data.voList[0].companyName;
}else{
@ -258,14 +264,17 @@
logo = data.voList[0].logo;
title = data.voList[0].companyName;
icpLicense = data.voList[0].icpLicense || '';
appIdPublic = data.voList[0].appIdPublic || '';
}
// #endif
if(title){
this.appConfig.logo = logo;
this.appConfig.name = title;
this.appConfig.appIdPublic = appIdPublic;
}else{
this.appConfig.logo = '';
this.appConfig.name = this.$store.state.app.appConfig;
this.appConfig.appIdPublic = appIdPublic;
}
if(icpLicense){
this.icpLicense = icpLicense;
@ -283,6 +292,7 @@
this.form.tenantId = item.tenantId;
this.appConfig.logo = item.logo;
this.appConfig.name = item.companyName;
this.appConfig.appIdPublic = item.appIdPublic;
this.icpLicense = item.icpLicense || '';
}
});

View File

@ -125,7 +125,7 @@
tenantEnabled:true,
query:{},
isTenant: true,
appid:'',
appIdMini:'',
icpLicense:'',
}
},
@ -137,7 +137,7 @@
onLoad(e) {
// #ifdef MP-WEIXIN
const accountInfo = uni.getAccountInfoSync();
this.appid = accountInfo.miniProgram.appId;
this.appIdMini = accountInfo.miniProgram.appId;
// #endif
if(e){
this.query = e;
@ -217,6 +217,7 @@
let logo = '';
let title = '';
let icpLicense = '';
let appIdPublic = '';
// #ifdef H5
if(this.query.tenantId){
this.form.tenantId = this.query.tenantId;
@ -225,6 +226,7 @@
logo = item.logo;
title = item.companyName;
icpLicense = item.icpLicense || '';
appIdPublic = item.appIdPublic || '';
}
});
this.isTenant = false;
@ -233,6 +235,7 @@
logo = data.voList[0].logo;
title = data.voList[0].companyName;
icpLicense = data.voList[0].icpLicense || '';
appIdPublic = data.voList[0].appIdPublic || '';
this.isTenant = false;
} else if (data.voList != null && data.voList.length !== 0) {
this.form.tenantId = data.voList[0].tenantId;
@ -240,18 +243,20 @@
logo = data.voList[0].logo;
title = data.voList[0].companyName;
icpLicense = data.voList[0].icpLicense || '';
appIdPublic = data.voList[0].appIdPublic || '';
}
// #endif
// #ifdef MP-WEIXIN
if(this.appid){
if(this.appIdMini){
let isAppid = true;
data.voList.forEach((item) => {
if (item.appId === this.appid) {
if (item.appId === this.appIdMini) {
console.log("appId",item)
this.form.tenantId = item.tenantId;
logo = item.logo;
title = item.companyName;
icpLicense = item.icpLicense || '';
appIdPublic = item.appIdPublic || '';
isAppid = false;
}
});
@ -261,24 +266,29 @@
logo = data.voList[0].logo;
title = data.voList[0].companyName;
icpLicense = data.voList[0].icpLicense || '';
appIdPublic = data.voList[0].appIdPublic || '';
}else{
this.isTenant = false;
}
}else if (data.voList != null && data.voList.length !== 0) {
this.form.tenantId = data.voList[0].tenantId;
this.activeTenantObj = data.voList[0] ;
appIdPublic = data.voList[0].appIdPublic || '';
logo = data.voList[0].logo;
title = data.voList[0].companyName;
icpLicense = data.voList[0].icpLicense || '';
appIdPublic = data.voList[0].appIdPublic || '';
}
// #endif
console.log("title",title,logo)
if(title){
this.appConfig.logo = logo;
this.appConfig.name = title;
this.appConfig.appIdPublic = appIdPublic;
}else{
this.appConfig.logo = '';
this.appConfig.name = this.$store.state.app.appConfig;
this.appConfig.appIdPublic = appIdPublic;
}
if(icpLicense){
this.icpLicense = icpLicense;
@ -296,6 +306,7 @@
this.form.tenantId = item.tenantId;
this.appConfig.logo = item.logo;
this.appConfig.name = item.companyName;
this.appConfig.appIdPublic = item.appIdPublic;
this.icpLicense = item.icpLicense || '';
}
});

View File

@ -128,7 +128,7 @@ export default {
mall_pay_type:[],
buttonLoading:false,
officialAccount:{
appid:'wx80a304ffbfb30995',
appid:'',
appsecret:'ca307cfb6c94e8ac015e26cfd717a91c',
},
code:'',
@ -136,7 +136,7 @@ export default {
}
},
onLoad(option) {
this.officialAccount.appid = this.$store.state.app.appConfig.appIdPublic;
this.getDictDataList('mall_order_status');
this.getDictDataList('mall_source_type');
this.getDictDataList('mall_pay_type');

View File

@ -1,6 +1,11 @@
const auth = {
state: {
appConfig:{},
appConfig:{
name:'',
logo:'',
appIdPublic:'',
openId:'',
},
},
mutations: {
updataConfig(state, data) {