diff --git a/.env.development b/.env.development
index 3a62d8e..f929f8f 100644
--- a/.env.development
+++ b/.env.development
@@ -1,10 +1,6 @@
# 本地环境
ENV = 'development'
-# 统一后端服务地址配置(全部模块共用 8000 端口)
-# 切换环境时,仅需修改下面这一个地址的 IP
-# 当前环境: 192.168.3.38
-# 备用环境: 192.168.3.200
-# 备用环境: 116.204.74.41
-# 备用环境: 172.20.10.7
-VITE_API_URL = 'http://192.168.74.41:8000/'
+# 统一后端服务地址前缀(网关服务名:admin-go)
+# 开发环境走本地代理,避免 CORS
+VITE_API_URL = 'http://192.168.74.41:8000'
diff --git a/.env.production b/.env.production
index fa100b0..ccfb6ae 100644
--- a/.env.production
+++ b/.env.production
@@ -4,5 +4,5 @@ ENV = 'production'
# public path 配置线上环境路径(打包)、本地通过 http-server 访问时,请置空即可
VITE_PUBLIC_PATH = '/sys/'
-# 统一服务地址(端口8000)
-VITE_API_URL = '/'
+# 统一服务地址前缀(网关服务名:admin-go)
+VITE_API_URL = ''
diff --git a/public/web/subscribe.html b/public/web/subscribe.html
index d3cc214..176420a 100644
--- a/public/web/subscribe.html
+++ b/public/web/subscribe.html
@@ -1,563 +1,584 @@
-
+
-
-
-
- 服务开通 - 智能营销服务平台
-
-
-
-
-
-
+ .success-message p {
+ margin: 0;
+ color: #15803d;
+ }
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
-
+ // 更新提交按钮状态
+ function updateSubmitButton() {
+ const btn = document.getElementById('btn-submit');
+ // 如果有用户类型选项,则需要同时选择类型和套餐
+ if (tenantModuleTypes.length > 0) {
+ btn.disabled = !selectedSku || !selectedType;
+ } else {
+ btn.disabled = !selectedSku;
+ }
+ }
+
+ // 开通服务
+ async function handleSubscribe() {
+ if (!selectedSku) {
+ alert('请选择套餐');
+ return;
+ }
+
+ // 如果有用户类型选项但未选择
+ if (tenantModuleTypes.length > 0 && !selectedType) {
+ alert('请选择用户类型');
+ return;
+ }
+
+ const btn = document.getElementById('btn-submit');
+ btn.disabled = true;
+ btn.textContent = '开通中...';
+
+ try {
+ const token = getToken();
+
+ // 构建请求参数
+ const requestBody = {
+ assetSkuId: selectedSku.id,
+ };
+
+ // 如果选择了用户类型,添加到请求参数
+ if (selectedType) {
+ requestBody.tenantModuleType = selectedType.key;
+ }
+
+ const response = await fetch(`${API_BASE_MAIN}/admin-go/api/v1/system/moduleTenant/add`, {
+ method: 'POST',
+ headers: {
+ Authorization: token ? `Bearer ${token}` : '',
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(requestBody),
+ });
+
+ const result = await response.json();
+
+ if (result.code !== 0) {
+ throw new Error(result.message || '开通失败');
+ }
+
+ // 显示成功
+ document.getElementById('type-section').style.display = 'none';
+ document.getElementById('sku-section').style.display = 'none';
+ document.getElementById('actions').style.display = 'none';
+ document.getElementById('asset-info').style.display = 'none';
+ document.getElementById('success').style.display = 'block';
+
+ // 设置开通时间标记,防止跳转后立即又触发402
+ sessionStorage.setItem('lastSubscribeTime', Date.now().toString());
+
+ // 延迟跳转回原页面
+ const targetUrl = decodeURIComponent(returnUrl);
+ // console.log('[subscribe] 开通成功,即将跳转到:', targetUrl);
+ // console.log('[subscribe] 原始 returnUrl:', returnUrl);
+
+ setTimeout(() => {
+ let finalUrl;
+ // 如果 returnUrl 包含当前开通页面路径,则跳转到首页
+ if (targetUrl.includes('/web/subscribe') || targetUrl.includes('subscribe.html')) {
+ console.log('[subscribe] returnUrl 指向开通页面,改为跳转首页');
+ finalUrl = '/index.html#/home';
+ } else {
+ finalUrl = targetUrl;
+ }
+
+ // 使用 replace 跳转,然后强制刷新
+ window.location.replace(finalUrl);
+ // 延迟一点再刷新,确保 URL 已经改变
+ setTimeout(() => {
+ window.location.reload(true);
+ }, 100);
+ }, 2000);
+ } catch (error) {
+ console.error('开通失败:', error);
+ alert(error.message || '开通失败,请稍后重试');
+ btn.disabled = false;
+ btn.textContent = '立即开通';
+ }
+ }
+
+ // 取消 - 跳转到后台首页,避免循环触发402
+ function handleCancel() {
+ window.location.href = '/index.html#/home';
+ }
+
+ // 获取Token(从Cookie获取)
+ function getToken() {
+ try {
+ const cookies = document.cookie.split(';');
+ for (let cookie of cookies) {
+ const parts = cookie.trim().split('=');
+ const name = parts[0];
+ // token 值可能包含 = 号,所以用 slice 获取剩余部分
+ const value = parts.slice(1).join('=');
+ if (name === 'token' && value) {
+ // Cookie 中的值可能被 URL 编码,需要解码
+ try {
+ return decodeURIComponent(value);
+ } catch (e) {
+ return value;
+ }
+ }
+ }
+ } catch (e) {
+ console.error('获取token失败:', e);
+ }
+ return '';
+ }
+
+ // 显示/隐藏加载
+ function showLoading(show) {
+ document.getElementById('loading').style.display = show ? 'block' : 'none';
+ }
+
+ // 显示错误
+ function showError(message) {
+ const errorEl = document.getElementById('error');
+ errorEl.textContent = message;
+ errorEl.style.display = 'block';
+ document.getElementById('loading').style.display = 'none';
+ }
+
+