授权页支持通过 domain 参数切换请求域名

This commit is contained in:
yankang 2026-10-09 11:10:09 +08:00
parent 1bdc9ecf2f
commit d5bff9fa3f
2 changed files with 17 additions and 9 deletions

View File

@ -50,6 +50,7 @@
<script>
import { getEnvironment } from '@/utils/env.js';
import domainMap from '@/utils/domain.js';
import http from '@/request/request.js';
import pagesConfig from '@/pages.json';
import wx from 'weixin-js-sdk';
@ -80,6 +81,7 @@ export default {
this.code = params.code || '';
this.queryState = params.state || '';
this.exuid = params.exuid || '';
this.domain = params.domain || '';
if(this.queryState) this.$store.dispatch('setCurrentUid', (params.state || '').replace(/^uid/, '') || '');
@ -93,15 +95,9 @@ export default {
},
methods: {
getBaseUrl() {
// return 'https://point.agrimedia.cn';
return window.location.origin;
// // #ifdef H5
// return window.location.origin;
// // #endif
// // #ifndef H5
// // 非 H5 平台(小程序/App)需配置为已备案的 H5 域名
return 'https://tpoint.agrimedia.cn';
// // #endif
// 进入项目时若携带 domain 字段且能在 utils/domain.js 中对应上,
// 则使用对应的属性值作为请求前置域名,否则默认使用 HOST
return domainMap[this.domain] || domainMap.HOST;
},
handleAuth() {

12
utils/domain.js Normal file
View File

@ -0,0 +1,12 @@
export default {
// 默认请当前访问地址域名
HOST: `${window.location.protocol}//${window.location.host}`,
// 线上环境域名
POINT: 'https://point.agrimedia.cn',
// 测试环境域名
T_POINT: 'https://tpoint.agrimedia.cn',
// 线上环境域名
APIPOINT: 'https://aipoint.zdyyai.com',
// 测试环境域名
T_APIPOINT: 'https://taipoint.agrimedia.cn',
}