From 68aa7d3ce2dab7c301f164516499200c40319af9 Mon Sep 17 00:00:00 2001 From: jacy <18049821889@163.com> Date: Wed, 15 Jul 2026 19:50:09 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=8D=E5=8B=BE=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/h5-partner/src/App.tsx | 3 + apps/h5-partner/src/components/AuthGate.tsx | 2 +- apps/h5-partner/src/main.tsx | 1 + apps/h5-partner/src/pages/LegalPage.tsx | 36 ++++ apps/h5-partner/src/pages/LoginPage.tsx | 11 +- apps/h5-partner/src/styles/legal.css | 75 ++++++++ apps/h5-shop/src/App.tsx | 3 + apps/h5-shop/src/components/AuthGate.tsx | 2 +- apps/h5-shop/src/main.tsx | 1 + apps/h5-shop/src/pages/LegalPage.tsx | 36 ++++ apps/h5-shop/src/pages/LoginPage.tsx | 10 +- apps/h5-shop/src/styles/legal.css | 75 ++++++++ apps/h5-user/src/App.tsx | 3 + apps/h5-user/src/main.tsx | 1 + apps/h5-user/src/pages/LegalPage.tsx | 36 ++++ apps/h5-user/src/pages/LoginPage.tsx | 12 +- apps/h5-user/src/styles/legal.css | 75 ++++++++ apps/mini-hq/src/app.config.ts | 2 + apps/mini-hq/src/pages/login/index.tsx | 22 ++- .../src/pages/privacy-policy/index.config.ts | 3 + .../src/pages/privacy-policy/index.tsx | 32 ++++ .../src/pages/user-agreement/index.config.ts | 3 + .../src/pages/user-agreement/index.tsx | 32 ++++ .../src/pages/user-agreement/legal.css | 68 ++++++++ apps/mini-user/src/app.config.ts | 2 + apps/mini-user/src/app.css | 1 + apps/mini-user/src/pages/login/index.tsx | 24 ++- .../src/pages/privacy-policy/index.config.ts | 4 + .../src/pages/privacy-policy/index.tsx | 29 ++++ .../src/pages/user-agreement/index.config.ts | 4 + .../src/pages/user-agreement/index.tsx | 29 ++++ apps/mini-user/src/styles/legal.css | 40 +++++ packages/shared-types/src/index.ts | 1 + packages/shared-types/src/legal.ts | 161 ++++++++++++++++++ 34 files changed, 821 insertions(+), 18 deletions(-) create mode 100644 apps/h5-partner/src/pages/LegalPage.tsx create mode 100644 apps/h5-partner/src/styles/legal.css create mode 100644 apps/h5-shop/src/pages/LegalPage.tsx create mode 100644 apps/h5-shop/src/styles/legal.css create mode 100644 apps/h5-user/src/pages/LegalPage.tsx create mode 100644 apps/h5-user/src/styles/legal.css create mode 100644 apps/mini-hq/src/pages/privacy-policy/index.config.ts create mode 100644 apps/mini-hq/src/pages/privacy-policy/index.tsx create mode 100644 apps/mini-hq/src/pages/user-agreement/index.config.ts create mode 100644 apps/mini-hq/src/pages/user-agreement/index.tsx create mode 100644 apps/mini-hq/src/pages/user-agreement/legal.css create mode 100644 apps/mini-user/src/pages/privacy-policy/index.config.ts create mode 100644 apps/mini-user/src/pages/privacy-policy/index.tsx create mode 100644 apps/mini-user/src/pages/user-agreement/index.config.ts create mode 100644 apps/mini-user/src/pages/user-agreement/index.tsx create mode 100644 apps/mini-user/src/styles/legal.css create mode 100644 packages/shared-types/src/legal.ts diff --git a/apps/h5-partner/src/App.tsx b/apps/h5-partner/src/App.tsx index 70d0459..1b1ded1 100644 --- a/apps/h5-partner/src/App.tsx +++ b/apps/h5-partner/src/App.tsx @@ -1,6 +1,7 @@ import { Routes, Route } from 'react-router-dom'; import AuthGate from './components/AuthGate'; import LoginPage from './pages/LoginPage'; +import LegalPage from './pages/LegalPage'; import PartnerAppRoutes from './PartnerAppRoutes'; export default function App() { @@ -8,6 +9,8 @@ export default function App() { } /> + } /> + } /> } /> diff --git a/apps/h5-partner/src/components/AuthGate.tsx b/apps/h5-partner/src/components/AuthGate.tsx index b01c2be..56229d5 100644 --- a/apps/h5-partner/src/components/AuthGate.tsx +++ b/apps/h5-partner/src/components/AuthGate.tsx @@ -3,7 +3,7 @@ import { getPartnerProfile, hasPartnerWxSession } from '../lib/api'; import { usePartnerSession } from '../contexts/PartnerSessionContext'; import { partnerHomePath } from '../lib/partnerAccess'; -const PUBLIC_PATHS = new Set(['/login']); +const PUBLIC_PATHS = new Set(['/login', '/legal/user-agreement', '/legal/privacy-policy']); export default function AuthGate({ children }: { children: React.ReactNode }) { const { ready, authenticated, account } = usePartnerSession(); diff --git a/apps/h5-partner/src/main.tsx b/apps/h5-partner/src/main.tsx index e8bf706..714c575 100644 --- a/apps/h5-partner/src/main.tsx +++ b/apps/h5-partner/src/main.tsx @@ -6,6 +6,7 @@ import App from './App'; import { PartnerSessionProvider } from './contexts/PartnerSessionContext'; import { PartnerToastProvider } from './contexts/PartnerToastContext'; import './styles.css'; +import './styles/legal.css'; ReactDOM.createRoot(document.getElementById('root')!).render( diff --git a/apps/h5-partner/src/pages/LegalPage.tsx b/apps/h5-partner/src/pages/LegalPage.tsx new file mode 100644 index 0000000..337fdc4 --- /dev/null +++ b/apps/h5-partner/src/pages/LegalPage.tsx @@ -0,0 +1,36 @@ +import { Link } from 'react-router-dom'; +import { getLegalDocument, type LegalDocument } from '@dukang/shared-types'; + +type LegalPageProps = { + docId: LegalDocument['id']; + /** 返回登录页的路径,如 /login */ + backTo?: string; +}; + +/** H5 各端共用的协议/隐私正文页 */ +export default function LegalPage({ docId, backTo = '/login' }: LegalPageProps) { + const doc = getLegalDocument(docId); + + return ( +
+
+ + ‹ + +

{doc.title}

+
+
+

更新日期:{doc.updatedAt}

+

{doc.intro}

+ {doc.sections.map((section) => ( +
+

{section.heading}

+ {section.paragraphs.map((p, i) => ( +

{p}

+ ))} +
+ ))} +
+
+ ); +} diff --git a/apps/h5-partner/src/pages/LoginPage.tsx b/apps/h5-partner/src/pages/LoginPage.tsx index 902404c..d3722b0 100644 --- a/apps/h5-partner/src/pages/LoginPage.tsx +++ b/apps/h5-partner/src/pages/LoginPage.tsx @@ -68,7 +68,7 @@ export default function LoginPage() { const [phone, setPhone] = useState(remembered.phone || getLastPhone()); const [code, setCode] = useState(''); const [rememberAccount, setRememberAccount] = useState(remembered.remember); - const [agreed, setAgreed] = useState(true); + const [agreed, setAgreed] = useState(false); const [loading, setLoading] = useState(false); const [wxLoading, setWxLoading] = useState(false); const [msg, setMsg] = useState(''); @@ -343,7 +343,14 @@ export default function LoginPage() { diff --git a/apps/h5-partner/src/styles/legal.css b/apps/h5-partner/src/styles/legal.css new file mode 100644 index 0000000..800aac1 --- /dev/null +++ b/apps/h5-partner/src/styles/legal.css @@ -0,0 +1,75 @@ +.legal-h5-page { + min-height: 100vh; + background: #faf9f7; + color: #1f1a17; +} + +.legal-h5-header { + position: sticky; + top: 0; + z-index: 10; + display: flex; + align-items: center; + justify-content: center; + height: 52px; + padding: 0 16px; + background: #faf9f7; + border-bottom: 1px solid rgba(0, 0, 0, 0.06); +} + +.legal-h5-back { + position: absolute; + left: 12px; + top: 50%; + transform: translateY(-50%); + width: 36px; + height: 36px; + display: flex; + align-items: center; + justify-content: center; + font-size: 28px; + line-height: 1; + color: #1f1a17; + text-decoration: none; +} + +.legal-h5-title { + margin: 0; + font-size: 17px; + font-weight: 600; +} + +.legal-h5-body { + padding: 16px 20px 40px; + max-width: 720px; + margin: 0 auto; +} + +.legal-h5-updated { + margin: 0 0 12px; + font-size: 12px; + color: #8d706e; +} + +.legal-h5-intro { + margin: 0 0 20px; + font-size: 14px; + line-height: 1.7; +} + +.legal-h5-section { + margin-bottom: 18px; +} + +.legal-h5-section h2 { + margin: 0 0 8px; + font-size: 15px; + font-weight: 600; +} + +.legal-h5-section p { + margin: 0 0 8px; + font-size: 13px; + line-height: 1.7; + color: #5c504c; +} diff --git a/apps/h5-shop/src/App.tsx b/apps/h5-shop/src/App.tsx index 1d9790f..78cf4f9 100644 --- a/apps/h5-shop/src/App.tsx +++ b/apps/h5-shop/src/App.tsx @@ -2,6 +2,7 @@ import { Routes, Route, Navigate } from 'react-router-dom'; import AuthGate from './components/AuthGate'; import TabLayout from './layouts/TabLayout'; import LoginPage from './pages/LoginPage'; +import LegalPage from './pages/LegalPage'; import SelectStorePage from './pages/SelectStorePage'; import HomePage from './pages/HomePage'; import RedeemConfirmPage from './pages/RedeemConfirmPage'; @@ -17,6 +18,8 @@ export default function App() { } /> + } /> + } /> } /> } /> } /> diff --git a/apps/h5-shop/src/components/AuthGate.tsx b/apps/h5-shop/src/components/AuthGate.tsx index e297e17..46fee16 100644 --- a/apps/h5-shop/src/components/AuthGate.tsx +++ b/apps/h5-shop/src/components/AuthGate.tsx @@ -2,7 +2,7 @@ import { Navigate, useLocation } from 'react-router-dom'; import { getStoreProfile, hasShopWxSession } from '../lib/api'; import { useStoreSession } from '../contexts/StoreSessionContext'; -const PUBLIC_PATHS = new Set(['/login']); +const PUBLIC_PATHS = new Set(['/login', '/legal/user-agreement', '/legal/privacy-policy']); const SELECT_STORE_PATH = '/select-store'; export default function AuthGate({ children }: { children: React.ReactNode }) { diff --git a/apps/h5-shop/src/main.tsx b/apps/h5-shop/src/main.tsx index 29a6ad7..2e7a6da 100644 --- a/apps/h5-shop/src/main.tsx +++ b/apps/h5-shop/src/main.tsx @@ -5,6 +5,7 @@ import { getRouterBasename } from '@dukang/weixin-sdk'; import { StoreSessionProvider } from './contexts/StoreSessionContext'; import App from './App'; import './styles.css'; +import './styles/legal.css'; ReactDOM.createRoot(document.getElementById('root')!).render( diff --git a/apps/h5-shop/src/pages/LegalPage.tsx b/apps/h5-shop/src/pages/LegalPage.tsx new file mode 100644 index 0000000..337fdc4 --- /dev/null +++ b/apps/h5-shop/src/pages/LegalPage.tsx @@ -0,0 +1,36 @@ +import { Link } from 'react-router-dom'; +import { getLegalDocument, type LegalDocument } from '@dukang/shared-types'; + +type LegalPageProps = { + docId: LegalDocument['id']; + /** 返回登录页的路径,如 /login */ + backTo?: string; +}; + +/** H5 各端共用的协议/隐私正文页 */ +export default function LegalPage({ docId, backTo = '/login' }: LegalPageProps) { + const doc = getLegalDocument(docId); + + return ( +
+
+ + ‹ + +

{doc.title}

+
+
+

更新日期:{doc.updatedAt}

+

{doc.intro}

+ {doc.sections.map((section) => ( +
+

{section.heading}

+ {section.paragraphs.map((p, i) => ( +

{p}

+ ))} +
+ ))} +
+
+ ); +} diff --git a/apps/h5-shop/src/pages/LoginPage.tsx b/apps/h5-shop/src/pages/LoginPage.tsx index 722daa6..a35d60d 100644 --- a/apps/h5-shop/src/pages/LoginPage.tsx +++ b/apps/h5-shop/src/pages/LoginPage.tsx @@ -36,7 +36,7 @@ export default function LoginPage() { const savedProfile = getStoreProfile(); const [phone, setPhone] = useState(getLastPhone()); const [code, setCode] = useState(''); - const [agreed, setAgreed] = useState(true); + const [agreed, setAgreed] = useState(false); const [loading, setLoading] = useState(false); const [wxLoading, setWxLoading] = useState(false); const [msg, setMsg] = useState(''); @@ -309,9 +309,13 @@ export default function LoginPage() { /> 我已阅读并同意 - 《用户协议》 + e.stopPropagation()}> + 《用户协议》 + 与 - 《隐私政策》 + e.stopPropagation()}> + 《隐私政策》 + diff --git a/apps/h5-shop/src/styles/legal.css b/apps/h5-shop/src/styles/legal.css new file mode 100644 index 0000000..800aac1 --- /dev/null +++ b/apps/h5-shop/src/styles/legal.css @@ -0,0 +1,75 @@ +.legal-h5-page { + min-height: 100vh; + background: #faf9f7; + color: #1f1a17; +} + +.legal-h5-header { + position: sticky; + top: 0; + z-index: 10; + display: flex; + align-items: center; + justify-content: center; + height: 52px; + padding: 0 16px; + background: #faf9f7; + border-bottom: 1px solid rgba(0, 0, 0, 0.06); +} + +.legal-h5-back { + position: absolute; + left: 12px; + top: 50%; + transform: translateY(-50%); + width: 36px; + height: 36px; + display: flex; + align-items: center; + justify-content: center; + font-size: 28px; + line-height: 1; + color: #1f1a17; + text-decoration: none; +} + +.legal-h5-title { + margin: 0; + font-size: 17px; + font-weight: 600; +} + +.legal-h5-body { + padding: 16px 20px 40px; + max-width: 720px; + margin: 0 auto; +} + +.legal-h5-updated { + margin: 0 0 12px; + font-size: 12px; + color: #8d706e; +} + +.legal-h5-intro { + margin: 0 0 20px; + font-size: 14px; + line-height: 1.7; +} + +.legal-h5-section { + margin-bottom: 18px; +} + +.legal-h5-section h2 { + margin: 0 0 8px; + font-size: 15px; + font-weight: 600; +} + +.legal-h5-section p { + margin: 0 0 8px; + font-size: 13px; + line-height: 1.7; + color: #5c504c; +} diff --git a/apps/h5-user/src/App.tsx b/apps/h5-user/src/App.tsx index f2c4448..a7df6f7 100644 --- a/apps/h5-user/src/App.tsx +++ b/apps/h5-user/src/App.tsx @@ -2,6 +2,7 @@ import { Routes, Route, Navigate } from 'react-router-dom'; import { useEffect } from 'react'; import TabLayout from './layouts/TabLayout'; import LoginPage from './pages/LoginPage'; +import LegalPage from './pages/LegalPage'; import HomePage from './pages/HomePage'; import ProductDetailPage from './pages/ProductDetailPage'; import OrderConfirmPage from './pages/OrderConfirmPage'; @@ -37,6 +38,8 @@ export default function App() { } /> + } /> + } /> }> } /> } /> diff --git a/apps/h5-user/src/main.tsx b/apps/h5-user/src/main.tsx index fcde7ac..94007ec 100644 --- a/apps/h5-user/src/main.tsx +++ b/apps/h5-user/src/main.tsx @@ -4,6 +4,7 @@ import { BrowserRouter } from 'react-router-dom'; import { getRouterBasename } from '@dukang/weixin-sdk'; import App from './App'; import './styles.css'; +import './styles/legal.css'; ReactDOM.createRoot(document.getElementById('root')!).render( diff --git a/apps/h5-user/src/pages/LegalPage.tsx b/apps/h5-user/src/pages/LegalPage.tsx new file mode 100644 index 0000000..337fdc4 --- /dev/null +++ b/apps/h5-user/src/pages/LegalPage.tsx @@ -0,0 +1,36 @@ +import { Link } from 'react-router-dom'; +import { getLegalDocument, type LegalDocument } from '@dukang/shared-types'; + +type LegalPageProps = { + docId: LegalDocument['id']; + /** 返回登录页的路径,如 /login */ + backTo?: string; +}; + +/** H5 各端共用的协议/隐私正文页 */ +export default function LegalPage({ docId, backTo = '/login' }: LegalPageProps) { + const doc = getLegalDocument(docId); + + return ( +
+
+ + ‹ + +

{doc.title}

+
+
+

更新日期:{doc.updatedAt}

+

{doc.intro}

+ {doc.sections.map((section) => ( +
+

{section.heading}

+ {section.paragraphs.map((p, i) => ( +

{p}

+ ))} +
+ ))} +
+
+ ); +} diff --git a/apps/h5-user/src/pages/LoginPage.tsx b/apps/h5-user/src/pages/LoginPage.tsx index 980cbca..494310c 100644 --- a/apps/h5-user/src/pages/LoginPage.tsx +++ b/apps/h5-user/src/pages/LoginPage.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import { useNavigate, useSearchParams } from 'react-router-dom'; +import { useNavigate, useSearchParams, Link } from 'react-router-dom'; import AppImage from '@dukang/shared-ui/AppImage'; import type { WechatLoginResult } from '@dukang/shared-types'; import { SmsScene } from '@dukang/shared-types'; @@ -26,7 +26,7 @@ export default function LoginPage() { const [phone, setPhone] = useState(''); const [code, setCode] = useState(''); const [loading, setLoading] = useState(false); - const [agreed, setAgreed] = useState(true); + const [agreed, setAgreed] = useState(false); const [msg, setMsg] = useState(''); const [wxSessionKey, setWxSessionKey] = useState(null); const [bindMode, setBindMode] = useState(false); @@ -229,9 +229,13 @@ export default function LoginPage() { /> 我已阅读并同意 - 《用户协议》 + e.stopPropagation()}> + 《用户协议》 + 和 - 《隐私政策》 + e.stopPropagation()}> + 《隐私政策》 + diff --git a/apps/h5-user/src/styles/legal.css b/apps/h5-user/src/styles/legal.css new file mode 100644 index 0000000..800aac1 --- /dev/null +++ b/apps/h5-user/src/styles/legal.css @@ -0,0 +1,75 @@ +.legal-h5-page { + min-height: 100vh; + background: #faf9f7; + color: #1f1a17; +} + +.legal-h5-header { + position: sticky; + top: 0; + z-index: 10; + display: flex; + align-items: center; + justify-content: center; + height: 52px; + padding: 0 16px; + background: #faf9f7; + border-bottom: 1px solid rgba(0, 0, 0, 0.06); +} + +.legal-h5-back { + position: absolute; + left: 12px; + top: 50%; + transform: translateY(-50%); + width: 36px; + height: 36px; + display: flex; + align-items: center; + justify-content: center; + font-size: 28px; + line-height: 1; + color: #1f1a17; + text-decoration: none; +} + +.legal-h5-title { + margin: 0; + font-size: 17px; + font-weight: 600; +} + +.legal-h5-body { + padding: 16px 20px 40px; + max-width: 720px; + margin: 0 auto; +} + +.legal-h5-updated { + margin: 0 0 12px; + font-size: 12px; + color: #8d706e; +} + +.legal-h5-intro { + margin: 0 0 20px; + font-size: 14px; + line-height: 1.7; +} + +.legal-h5-section { + margin-bottom: 18px; +} + +.legal-h5-section h2 { + margin: 0 0 8px; + font-size: 15px; + font-weight: 600; +} + +.legal-h5-section p { + margin: 0 0 8px; + font-size: 13px; + line-height: 1.7; + color: #5c504c; +} diff --git a/apps/mini-hq/src/app.config.ts b/apps/mini-hq/src/app.config.ts index 7441445..c0808d7 100644 --- a/apps/mini-hq/src/app.config.ts +++ b/apps/mini-hq/src/app.config.ts @@ -5,6 +5,8 @@ export default defineAppConfig({ 'pages/settlement/index', 'pages/tickets/index', 'pages/login/index', + 'pages/user-agreement/index', + 'pages/privacy-policy/index', 'pages/stores/detail', 'pages/orders/index', 'pages/orders/detail', diff --git a/apps/mini-hq/src/pages/login/index.tsx b/apps/mini-hq/src/pages/login/index.tsx index bf4687d..387f301 100644 --- a/apps/mini-hq/src/pages/login/index.tsx +++ b/apps/mini-hq/src/pages/login/index.tsx @@ -43,7 +43,7 @@ export default function LoginPage() { const [phone, setPhone] = useState(remembered.phone || DEMO_PHONE); const [code, setCode] = useState('123456'); const [rememberAccount, setRememberAccount] = useState(remembered.remember); - const [agreed, setAgreed] = useState(true); + const [agreed, setAgreed] = useState(false); const [cooldown, setCooldown] = useState(0); const [loading, setLoading] = useState(false); const [wxLoading, setWxLoading] = useState(false); @@ -234,9 +234,25 @@ export default function LoginPage() { 我已阅读并同意 - 《用户协议》 + { + e.stopPropagation(); + Taro.navigateTo({ url: '/pages/user-agreement/index' }); + }} + > + 《用户协议》 + 与 - 《隐私政策》 + { + e.stopPropagation(); + Taro.navigateTo({ url: '/pages/privacy-policy/index' }); + }} + > + 《隐私政策》 + diff --git a/apps/mini-hq/src/pages/privacy-policy/index.config.ts b/apps/mini-hq/src/pages/privacy-policy/index.config.ts new file mode 100644 index 0000000..e3caa98 --- /dev/null +++ b/apps/mini-hq/src/pages/privacy-policy/index.config.ts @@ -0,0 +1,3 @@ +export default definePageConfig({ + navigationBarTitleText: '隐私政策', +}); diff --git a/apps/mini-hq/src/pages/privacy-policy/index.tsx b/apps/mini-hq/src/pages/privacy-policy/index.tsx new file mode 100644 index 0000000..a1f39ae --- /dev/null +++ b/apps/mini-hq/src/pages/privacy-policy/index.tsx @@ -0,0 +1,32 @@ +import { View, Text, ScrollView } from '@tarojs/components'; +import Taro from '@tarojs/taro'; +import { getLegalDocument } from '@dukang/shared-types'; +import '../user-agreement/legal.css'; + +export default function PrivacyPolicyPage() { + const doc = getLegalDocument('privacy-policy'); + return ( + + + Taro.navigateBack()}> + ‹ + + {doc.title} + + + 更新日期:{doc.updatedAt} + {doc.intro} + {doc.sections.map((section) => ( + + {section.heading} + {section.paragraphs.map((p, i) => ( + + {p} + + ))} + + ))} + + + ); +} diff --git a/apps/mini-hq/src/pages/user-agreement/index.config.ts b/apps/mini-hq/src/pages/user-agreement/index.config.ts new file mode 100644 index 0000000..6eeca34 --- /dev/null +++ b/apps/mini-hq/src/pages/user-agreement/index.config.ts @@ -0,0 +1,3 @@ +export default definePageConfig({ + navigationBarTitleText: '用户协议', +}); diff --git a/apps/mini-hq/src/pages/user-agreement/index.tsx b/apps/mini-hq/src/pages/user-agreement/index.tsx new file mode 100644 index 0000000..594ef64 --- /dev/null +++ b/apps/mini-hq/src/pages/user-agreement/index.tsx @@ -0,0 +1,32 @@ +import { View, Text, ScrollView } from '@tarojs/components'; +import Taro from '@tarojs/taro'; +import { getLegalDocument } from '@dukang/shared-types'; +import './legal.css'; + +export default function UserAgreementPage() { + const doc = getLegalDocument('user-agreement'); + return ( + + + Taro.navigateBack()}> + ‹ + + {doc.title} + + + 更新日期:{doc.updatedAt} + {doc.intro} + {doc.sections.map((section) => ( + + {section.heading} + {section.paragraphs.map((p, i) => ( + + {p} + + ))} + + ))} + + + ); +} diff --git a/apps/mini-hq/src/pages/user-agreement/legal.css b/apps/mini-hq/src/pages/user-agreement/legal.css new file mode 100644 index 0000000..c7b91b4 --- /dev/null +++ b/apps/mini-hq/src/pages/user-agreement/legal.css @@ -0,0 +1,68 @@ +.hq-legal-page { + min-height: 100vh; + background: #faf9f7; +} + +.hq-legal-header { + position: sticky; + top: 0; + z-index: 10; + height: 52px; + display: flex; + align-items: center; + justify-content: center; + background: #faf9f7; + border-bottom: 1px solid rgba(0, 0, 0, 0.06); +} + +.hq-legal-back { + position: absolute; + left: 12px; + font-size: 28px; + line-height: 1; + padding: 4px 8px; +} + +.hq-legal-title { + font-size: 17px; + font-weight: 600; +} + +.hq-legal-body { + height: calc(100vh - 52px); + padding: 16px 20px 40px; + box-sizing: border-box; +} + +.hq-legal-updated { + display: block; + font-size: 12px; + color: #8d706e; + margin-bottom: 12px; +} + +.hq-legal-intro { + display: block; + font-size: 14px; + line-height: 1.7; + margin-bottom: 20px; +} + +.hq-legal-section { + margin-bottom: 18px; +} + +.hq-legal-heading { + display: block; + font-size: 15px; + font-weight: 600; + margin-bottom: 8px; +} + +.hq-legal-paragraph { + display: block; + font-size: 13px; + line-height: 1.7; + color: #5c504c; + margin-bottom: 8px; +} diff --git a/apps/mini-user/src/app.config.ts b/apps/mini-user/src/app.config.ts index 6c732f2..1bb2d0a 100644 --- a/apps/mini-user/src/app.config.ts +++ b/apps/mini-user/src/app.config.ts @@ -18,6 +18,8 @@ export default defineAppConfig({ 'pages/redeem-code/index', 'pages/redeem-success/index', 'pages/login/index', + 'pages/user-agreement/index', + 'pages/privacy-policy/index', ], window: { backgroundTextStyle: 'light', diff --git a/apps/mini-user/src/app.css b/apps/mini-user/src/app.css index ce40b8e..43fbbe9 100644 --- a/apps/mini-user/src/app.css +++ b/apps/mini-user/src/app.css @@ -8,6 +8,7 @@ @import './styles/product-detail.css'; @import './styles/store-detail.css'; @import './styles/login.css'; +@import './styles/legal.css'; @import './styles/order.css'; @import './styles/address.css'; @import './styles/redeem.css'; diff --git a/apps/mini-user/src/pages/login/index.tsx b/apps/mini-user/src/pages/login/index.tsx index 429a696..0e3390e 100644 --- a/apps/mini-user/src/pages/login/index.tsx +++ b/apps/mini-user/src/pages/login/index.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import { View, Text, Input, Button, Image } from '@tarojs/components'; -import { useRouter } from '@tarojs/taro'; +import Taro, { useRouter } from '@tarojs/taro'; import { SmsScene, isWxAuthorizeEnabled, @@ -47,7 +47,7 @@ export default function LoginPage() { const [wxLoading, setWxLoading] = useState(false); const [sending, setSending] = useState(false); const [cooldown, setCooldown] = useState(0); - const [agreed, setAgreed] = useState(true); + const [agreed, setAgreed] = useState(false); const [msg, setMsg] = useState(''); const [sentHint, setSentHint] = useState(''); const [bindMode, setBindMode] = useState(initialBindMode); @@ -387,9 +387,25 @@ export default function LoginPage() { 我已阅读并同意 - 《用户协议》 + { + e.stopPropagation(); + Taro.navigateTo({ url: '/pages/user-agreement/index' }); + }} + > + 《用户协议》 + 和 - 《隐私政策》 + { + e.stopPropagation(); + Taro.navigateTo({ url: '/pages/privacy-policy/index' }); + }} + > + 《隐私政策》 + diff --git a/apps/mini-user/src/pages/privacy-policy/index.config.ts b/apps/mini-user/src/pages/privacy-policy/index.config.ts new file mode 100644 index 0000000..5b55d95 --- /dev/null +++ b/apps/mini-user/src/pages/privacy-policy/index.config.ts @@ -0,0 +1,4 @@ +export default definePageConfig({ + navigationBarTitleText: '隐私政策', + navigationStyle: 'custom', +}); diff --git a/apps/mini-user/src/pages/privacy-policy/index.tsx b/apps/mini-user/src/pages/privacy-policy/index.tsx new file mode 100644 index 0000000..865712d --- /dev/null +++ b/apps/mini-user/src/pages/privacy-policy/index.tsx @@ -0,0 +1,29 @@ +import { View, Text, ScrollView } from '@tarojs/components'; +import { getLegalDocument } from '@dukang/shared-types'; +import PageShell from '../../components/PageShell'; +import SubPageHeader from '../../components/SubPageHeader'; + +export default function PrivacyPolicyPage() { + const doc = getLegalDocument('privacy-policy'); + return ( + + + + + 更新日期:{doc.updatedAt} + {doc.intro} + {doc.sections.map((section) => ( + + {section.heading} + {section.paragraphs.map((p, i) => ( + + {p} + + ))} + + ))} + + + + ); +} diff --git a/apps/mini-user/src/pages/user-agreement/index.config.ts b/apps/mini-user/src/pages/user-agreement/index.config.ts new file mode 100644 index 0000000..37e4e8b --- /dev/null +++ b/apps/mini-user/src/pages/user-agreement/index.config.ts @@ -0,0 +1,4 @@ +export default definePageConfig({ + navigationBarTitleText: '用户协议', + navigationStyle: 'custom', +}); diff --git a/apps/mini-user/src/pages/user-agreement/index.tsx b/apps/mini-user/src/pages/user-agreement/index.tsx new file mode 100644 index 0000000..098e45c --- /dev/null +++ b/apps/mini-user/src/pages/user-agreement/index.tsx @@ -0,0 +1,29 @@ +import { View, Text, ScrollView } from '@tarojs/components'; +import { getLegalDocument } from '@dukang/shared-types'; +import PageShell from '../../components/PageShell'; +import SubPageHeader from '../../components/SubPageHeader'; + +export default function UserAgreementPage() { + const doc = getLegalDocument('user-agreement'); + return ( + + + + + 更新日期:{doc.updatedAt} + {doc.intro} + {doc.sections.map((section) => ( + + {section.heading} + {section.paragraphs.map((p, i) => ( + + {p} + + ))} + + ))} + + + + ); +} diff --git a/apps/mini-user/src/styles/legal.css b/apps/mini-user/src/styles/legal.css new file mode 100644 index 0000000..44eaa27 --- /dev/null +++ b/apps/mini-user/src/styles/legal.css @@ -0,0 +1,40 @@ +.legal-page .legal-scroll { + height: 100%; + box-sizing: border-box; + padding-bottom: 32px; +} + +.legal-updated { + display: block; + font-size: 12px; + color: var(--color-on-surface-variant, #8d706e); + margin-bottom: 12px; +} + +.legal-intro { + display: block; + font-size: 14px; + line-height: 1.7; + color: var(--color-on-surface, #1f1a17); + margin-bottom: 20px; +} + +.legal-section { + margin-bottom: 18px; +} + +.legal-heading { + display: block; + font-size: 15px; + font-weight: 600; + color: var(--color-on-surface, #1f1a17); + margin-bottom: 8px; +} + +.legal-paragraph { + display: block; + font-size: 13px; + line-height: 1.7; + color: var(--color-on-surface-variant, #5c504c); + margin-bottom: 8px; +} diff --git a/packages/shared-types/src/index.ts b/packages/shared-types/src/index.ts index 57a5dcf..ae2578f 100644 --- a/packages/shared-types/src/index.ts +++ b/packages/shared-types/src/index.ts @@ -19,3 +19,4 @@ export * from './shop'; export * from './city-partner'; export * from './city-warehouse'; export * from './system-config'; +export * from './legal'; diff --git a/packages/shared-types/src/legal.ts b/packages/shared-types/src/legal.ts new file mode 100644 index 0000000..50c4fac --- /dev/null +++ b/packages/shared-types/src/legal.ts @@ -0,0 +1,161 @@ +import { CUSTOMER_SERVICE_PHONE } from './config'; + +export type LegalSection = { + heading: string; + paragraphs: string[]; +}; + +export type LegalDocument = { + id: 'user-agreement' | 'privacy-policy'; + title: string; + updatedAt: string; + intro: string; + sections: LegalSection[]; +}; + +/** + * 杜康好客 · 用户协议 / 隐私政策(多端共用)。 + * 结构对齐《个人信息保护法》及 App 合规常见披露要点。 + * 参考:小米开发者「隐私政策不合规修改指引」、FreeBuf APP 隐私合规规范(禁止默认勾选等)。 + * 正式上线前请法务审定主体名称与联系方式。 + */ +export const USER_AGREEMENT: LegalDocument = { + id: 'user-agreement', + title: '用户协议', + updatedAt: '2026-07-15', + intro: + '欢迎使用「杜康好客」平台(含微信小程序、微信内置浏览器 H5 及门店端/合伙人端相关服务,以下统称「本平台」)。请您在注册、登录或以其他方式使用本服务前仔细阅读并充分理解本协议。您勾选同意并继续使用,即视为已阅读并接受本协议全部内容。', + sections: [ + { + heading: '一、服务说明', + paragraphs: [ + '杜康好客是杜康酒业 O2O 消费服务平台:用户可在线浏览与购买酒类商品,获得对应「好客权益」并在合作门店核销;门店与城市合伙人可使用管理端完成核销、门店与订单相关履约操作。', + '我们有权根据业务需要调整服务内容、功能或规则,并在合理范围内通过平台公告、页面提示等方式通知您。', + ], + }, + { + heading: '二、账号注册与安全', + paragraphs: [ + '您可通过手机号验证码、微信授权等方式注册或登录。您应保证提供的信息真实、准确、完整,并及时更新。', + '您应妥善保管账号、验证码及设备。因您自身原因导致的账号被盗用、信息泄露等风险,由您自行承担;如发现异常请立即联系客服。', + '您不得利用本平台从事违法违规、侵害他人权益或扰乱平台秩序的行为,否则我们有权限制或终止服务。', + ], + }, + { + heading: '三、订单、支付与权益', + paragraphs: [ + '下单、支付、配送及「好客权益」发放/核销规则以平台页面展示及相关业务规则为准。支付成功后产生的权益额度按产品说明计入您的账户。', + '核销须在合作门店按规则完成;超出可用余额、已失效或违反使用规则的核销请求将被拒绝。', + '如发生退款、补发等售后事宜,将按平台售后规则及客服处理结果执行。', + ], + }, + { + heading: '四、用户行为规范', + paragraphs: [ + '您承诺依法使用本平台,不得利用技术手段恶意刷单、伪造核销、攻击系统或传播违法信息。', + '您理解并同意:酒类商品及相关服务可能仅面向符合法律法规要求的主体;若您不具备相应资格,请勿使用购买或核销功能。', + ], + }, + { + heading: '五、知识产权', + paragraphs: [ + '本平台中的文字、图片、标识、界面设计、软件等知识产权归平台运营方或合法权利人所有。未经许可,您不得擅自复制、传播或用于商业目的。', + ], + }, + { + heading: '六、免责与责任限制', + paragraphs: [ + '因不可抗力、网络故障、第三方支付或配送服务异常等非我们可控因素导致的服务中断或延误,我们将在合理范围内协助处理,但不承担因此产生的间接损失。', + '在法律允许的范围内,我们对因使用或无法使用本服务所产生的损害责任以您就相关服务实际支付的费用为限(免费服务除外另有约定)。', + ], + }, + { + heading: '七、协议变更与终止', + paragraphs: [ + '我们可能适时修订本协议,修订后的协议将在平台公布并自公布之日起生效(法律法规另有要求的除外)。若您继续使用服务,视为接受修订后的协议。', + '您可停止使用并申请注销账号;我们亦可在您严重违反本协议时中止或终止向您提供服务。', + ], + }, + { + heading: '八、联系我们', + paragraphs: [ + `如对本协议有任何疑问,请通过客服热线 ${CUSTOMER_SERVICE_PHONE}(工作时间 9:00–21:00)与我们联系。`, + ], + }, + ], +}; + +export const PRIVACY_POLICY: LegalDocument = { + id: 'privacy-policy', + title: '隐私政策', + updatedAt: '2026-07-15', + intro: + '杜康好客平台运营方(以下简称「我们」)深知个人信息对您的重要性,将按《中华人民共和国个人信息保护法》等相关法律法规保护您的个人信息。请您在使用服务前仔细阅读本政策。您勾选同意,即表示您已充分理解并同意我们按本政策处理相关个人信息。', + sections: [ + { + heading: '一、我们如何收集与使用个人信息', + paragraphs: [ + '为向您提供注册登录、下单支付、配送履约、门店核销、客服支持等核心功能,我们可能收集并使用下列信息:', + '1)账号信息:手机号码、验证码、微信 OpenID/UnionID、昵称与头像(若您授权微信);用于注册登录、账号绑定与安全保障。', + '2)交易信息:订单内容、收货地址、支付状态、配送状态、权益与核销记录;用于履约、售后与对账。', + '3)位置信息:在您授权后获取大致位置或精确位置,用于展示所在城市商品与附近门店;您可拒绝授权,我们将使用默认开城城市兜底。', + '4)设备与日志信息:设备型号、操作系统、网络类型、崩溃日志、操作日志等;用于安全风控、故障排查与服务优化。', + '5)您主动提供的其他信息:如客服沟通内容、反馈建议等。', + '我们不会以默认勾选等方式强制您同意本政策;未征得同意前,我们不会超范围收集与实现业务功能无关的个人信息。', + ], + }, + { + heading: '二、我们如何共享、转让、公开披露', + paragraphs: [ + '我们不会向第三方出售您的个人信息。仅在以下情形共享:', + '1)获得您的明确同意;', + '2)为实现支付、短信、配送、地图/定位、微信登录与支付等功能,与必要的服务提供商共享履行服务所必需的信息,并要求其依法保护;', + '3)根据法律法规、行政或司法机关要求;', + '4)在合并、分立、资产转让等情形下,如涉及个人信息转移,我们将要求新的持有方继续受本政策约束,或重新征得您的同意。', + ], + }, + { + heading: '三、我们如何存储与保护', + paragraphs: [ + '您的个人信息存储于中华人民共和国境内。我们仅在实现本政策所述目的所必需的期限内保存;超出期限后将删除或匿名化处理(法律法规另有规定的除外)。', + '我们采取合理的技术与管理措施保护信息安全,防止未经授权的访问、披露、篡改或丢失。如发生安全事件,我们将按法规要求及时告知并采取补救措施。', + ], + }, + { + heading: '四、第三方 SDK / 服务说明', + paragraphs: [ + '为实现登录、支付、分享、定位等功能,本平台可能接入微信开放平台、支付、短信、地图定位等第三方服务。该类服务会按其自身隐私政策处理相关信息。我们仅在实现功能所必需的范围内启用,并尽量采用最小化授权。', + ], + }, + { + heading: '五、您的权利', + paragraphs: [ + '您有权查阅、复制、更正、补充、删除您的个人信息,有权撤回同意、注销账号,以及在符合条件时限制或拒绝我们处理您的个人信息。', + '您可通过「我的」相关功能或联系客服行使上述权利。为保障安全,我们可能需要先验证您的身份。我们将在合理期限内答复。', + '您撤回同意后,我们将停止基于相应同意的处理活动,但不影响此前基于同意已进行的处理。', + ], + }, + { + heading: '六、未成年人保护', + paragraphs: [ + '本平台主要面向成年人。若您为未成年人,请在监护人陪同下阅读本政策,并在监护人同意后使用服务。我们不会主动收集未成年人的个人信息;如发现误收集,将尽快删除。', + ], + }, + { + heading: '七、本政策的更新', + paragraphs: [ + '我们可能适时更新本政策,并通过平台公告、弹窗或页面提示等方式告知。重大变更时,我们会提供更显著的通知,并在必要时重新征得您的同意。', + ], + }, + { + heading: '八、联系我们', + paragraphs: [ + `个人信息保护相关事宜,请拨打客服热线 ${CUSTOMER_SERVICE_PHONE}(工作时间 9:00–21:00)。我们将尽快处理您的请求。`, + ], + }, + ], +}; + +export function getLegalDocument(id: LegalDocument['id']): LegalDocument { + return id === 'privacy-policy' ? PRIVACY_POLICY : USER_AGREEMENT; +} From f15d2057f2c09e3b56b3822c87eb2695eae0d57a Mon Sep 17 00:00:00 2001 From: jacy <18049821889@163.com> Date: Wed, 15 Jul 2026 19:51:57 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=A1=B5=E7=9A=84?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=8C=89=E9=92=AE=E7=9C=8B=E4=B8=8D=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/mini-user/src/pages/login/index.tsx | 28 ++++++++++++------------ apps/mini-user/src/styles/login.css | 22 ++++++++++++++----- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/apps/mini-user/src/pages/login/index.tsx b/apps/mini-user/src/pages/login/index.tsx index 0e3390e..c5617f7 100644 --- a/apps/mini-user/src/pages/login/index.tsx +++ b/apps/mini-user/src/pages/login/index.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import { View, Text, Input, Button, Image } from '@tarojs/components'; +import { View, Text, Input, Image } from '@tarojs/components'; import Taro, { useRouter } from '@tarojs/taro'; import { SmsScene, @@ -351,20 +351,20 @@ export default function LoginPage() { ) : null} - + + {loading + ? '处理中...' + : completeMode === 'phone' + ? '完成验证' + : bindMode + ? '绑定并登录' + : '登录'} + + )} diff --git a/apps/mini-user/src/styles/login.css b/apps/mini-user/src/styles/login.css index 250d259..a79eeed 100644 --- a/apps/mini-user/src/styles/login.css +++ b/apps/mini-user/src/styles/login.css @@ -155,10 +155,10 @@ width: 100%; height: 48px; margin-top: 8px; - border: 1px solid rgba(166, 29, 36, 0.2); + border: 1.5px solid var(--color-heritage-red, #a61d24); border-radius: var(--radius-lg); - background: transparent; - color: var(--color-heritage-red); + background: #fff; + color: var(--color-heritage-red, #a61d24); font-family: var(--font-headline); font-size: 18px; font-weight: 600; @@ -167,14 +167,24 @@ justify-content: center; line-height: 1; padding: 0; + box-sizing: border-box; } -.login-sms-btn::after { - border: none; +.login-sms-btn__text { + color: var(--color-heritage-red, #a61d24); + font-size: 18px; + font-weight: 600; + line-height: 26px; } -.login-sms-btn[disabled] { +.login-sms-btn:active { + background: rgba(166, 29, 36, 0.06); + transform: scale(0.98); +} + +.login-sms-btn--disabled { opacity: 0.6; + pointer-events: none; } .login-divider { From 0f5f0f4c2bb17afd0f302297a4dc79dde4ed60cb Mon Sep 17 00:00:00 2001 From: jacy <18049821889@163.com> Date: Wed, 15 Jul 2026 19:57:06 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AB=AF=E4=B8=8D?= =?UTF-8?q?=E8=A6=81=E5=BC=BA=E5=88=B6=E7=94=A8=E6=88=B7=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../skills/dukang-coding/reference-backend.md | 2 +- .../skills/dukang-v3/reference-req-index.md | 2 +- .../src/components/PhoneVerifySheet.tsx | 7 ++- apps/h5-user/src/pages/LoginPage.tsx | 12 ++-- apps/h5-user/src/pages/OrderConfirmPage.tsx | 52 ++++++++++++++-- apps/h5-user/src/styles.css | 12 ++++ .../src/components/WechatShareBootstrap.tsx | 15 ++--- apps/mini-user/src/lib/pay-ready.ts | 9 +-- apps/mini-user/src/pages/login/index.tsx | 30 ++++++--- .../src/pages/order-confirm/index.tsx | 29 ++++++++- .../src/modules/iam/auth.service.ts | 61 +++++++++---------- .../src/modules/trade/trade.controller.ts | 3 - 杜康好客-v3-PRD.md | 2 +- 杜康好客-v3-现状对照.md | 2 +- 14 files changed, 167 insertions(+), 71 deletions(-) diff --git a/.cursor/skills/dukang-coding/reference-backend.md b/.cursor/skills/dukang-coding/reference-backend.md index 58e3836..2bf3cc1 100644 --- a/.cursor/skills/dukang-coding/reference-backend.md +++ b/.cursor/skills/dukang-coding/reference-backend.md @@ -23,7 +23,7 @@ | Guard | 用途 | |-------|------| | JwtAuthGuard | 需登录 | -| PhoneVerifiedGuard | C 端需绑定手机(下单/支付) | +| PhoneVerifiedGuard | (已废弃强制)C 端手机号改为下单页可选绑定 | | OptionalJwtAuthGuard | 可选登录(bootstrap) | Admin 路由在 `modules/ops/` 下,前缀 `/admin/*`。 diff --git a/.cursor/skills/dukang-v3/reference-req-index.md b/.cursor/skills/dukang-v3/reference-req-index.md index fe44cc0..6e9287c 100644 --- a/.cursor/skills/dukang-v3/reference-req-index.md +++ b/.cursor/skills/dukang-v3/reference-req-index.md @@ -7,7 +7,7 @@ | ID | 模块 | 结论摘要 | |----|------|----------| | REQ-U-001 | 导航 | 首页/门店/好客权益/个人中心 | -| REQ-U-002 | 登录 | 无感登录;下单强制手机号;微信/短信;7 天免登 | +| REQ-U-002 | 登录 | 无感登录;下单提示绑定手机号(可选);微信/短信;7 天免登 | | REQ-U-003 | 支付 | 仅微信支付 | | REQ-U-004 | 定位 | 右上角市区;默认 IP;可授权精确定位 | | REQ-U-005 | 首页商品 | 4 款酒祖杜康;大图、标题加粗、价格标红、权益金额 | diff --git a/apps/h5-user/src/components/PhoneVerifySheet.tsx b/apps/h5-user/src/components/PhoneVerifySheet.tsx index 6db9910..ed6ad19 100644 --- a/apps/h5-user/src/components/PhoneVerifySheet.tsx +++ b/apps/h5-user/src/components/PhoneVerifySheet.tsx @@ -105,8 +105,8 @@ export default function PhoneVerifySheet({ const sheetDesc = description ?? (mode === 'wechat_bind_phone' - ? '微信授权成功,请绑定手机号以完成支付' - : '下单前需验证手机号,以便接收订单通知'); + ? '建议绑定手机号,便于订单通知与售后;关闭可跳过继续支付' + : '建议绑定手机号,便于订单通知与售后;关闭可跳过继续下单'); return (
@@ -159,6 +159,9 @@ export default function PhoneVerifySheet({ +
); diff --git a/apps/h5-user/src/pages/LoginPage.tsx b/apps/h5-user/src/pages/LoginPage.tsx index 494310c..b31de3b 100644 --- a/apps/h5-user/src/pages/LoginPage.tsx +++ b/apps/h5-user/src/pages/LoginPage.tsx @@ -51,12 +51,6 @@ export default function LoginPage() { }, [wxAuthorize]); function handleWechatLoginResult(result: WechatLoginResult) { - if (result.needBindPhone && result.wxSessionKey) { - setBindMode(true); - setWxSessionKey(result.wxSessionKey); - setMsg('微信授权成功,请绑定手机号完成登录'); - return; - } if (result.accessToken) { applySession({ accessToken: result.accessToken, @@ -68,6 +62,12 @@ export default function LoginPage() { void finishLogin(navigate, returnTo); return; } + if (result.needBindPhone && result.wxSessionKey) { + setBindMode(true); + setWxSessionKey(result.wxSessionKey); + setMsg('微信授权成功,可绑定手机号(也可跳过,稍后在下单时再绑定)'); + return; + } } function ensureAgreed() { diff --git a/apps/h5-user/src/pages/OrderConfirmPage.tsx b/apps/h5-user/src/pages/OrderConfirmPage.tsx index aa9a650..6d5f58b 100644 --- a/apps/h5-user/src/pages/OrderConfirmPage.tsx +++ b/apps/h5-user/src/pages/OrderConfirmPage.tsx @@ -1,4 +1,4 @@ -import { useEffect, useMemo, useState } from 'react'; +import { useEffect, useMemo, useRef, useState } from 'react'; import { useNavigate, useSearchParams } from 'react-router-dom'; import SubPageHeader from '../components/SubPageHeader'; import AppImage from '@dukang/shared-ui/AppImage'; @@ -73,6 +73,7 @@ export default function OrderConfirmPage() { const [previewLoading, setPreviewLoading] = useState(false); const [loading, setLoading] = useState(false); const [msg, setMsg] = useState(''); + const phonePromptSkipped = useRef(false); useEffect(() => { request('USER_H5', '/user/addresses').then((list) => { @@ -195,7 +196,7 @@ export default function OrderConfirmPage() { setMsg('请选择收货地址'); return; } - if (!phoneVerified) { + if (!phoneVerified && !phonePromptSkipped.current) { setPendingSubmit(true); setShowPhoneVerify(true); return; @@ -204,6 +205,7 @@ export default function OrderConfirmPage() { const authResult = await ensureWechatAuthForPay(); if (!authResult.ok) { if ('needBindPhone' in authResult) { + // 兼容旧接口:微信授权后提示可选绑定 setWxSessionKey(authResult.wxSessionKey); setShowWechatBindPhone(true); setPendingSubmit(true); @@ -418,9 +420,35 @@ export default function OrderConfirmPage() { { setShowPhoneVerify(false); - setPendingSubmit(false); + if (pendingSubmit) { + phonePromptSkipped.current = true; + setPendingSubmit(false); + void (async () => { + setLoading(true); + setMsg(''); + try { + const authResult = await ensureWechatAuthForPay(); + if (!authResult.ok) { + if ('needBindPhone' in authResult) { + setWxSessionKey(authResult.wxSessionKey); + setShowWechatBindPhone(true); + setPendingSubmit(true); + return; + } + return; + } + await doSubmit(); + } catch (e) { + setMsg(e instanceof Error ? e.message : '下单失败'); + } finally { + setLoading(false); + } + })(); + } }} onSuccess={handlePhoneVerified} /> @@ -430,10 +458,26 @@ export default function OrderConfirmPage() { mode="wechat_bind_phone" wxSessionKey={wxSessionKey ?? undefined} defaultPhone={selectedAddress?.phone} + title="建议绑定手机号" + description="绑定后便于订单通知与售后联系;关闭即可跳过继续下单。" onClose={() => { setShowWechatBindPhone(false); setWxSessionKey(null); - setPendingSubmit(false); + if (pendingSubmit) { + phonePromptSkipped.current = true; + setPendingSubmit(false); + void (async () => { + setLoading(true); + setMsg(''); + try { + await doSubmit(); + } catch (e) { + setMsg(e instanceof Error ? e.message : '下单失败'); + } finally { + setLoading(false); + } + })(); + } }} onSuccess={handleWechatPhoneBound} /> diff --git a/apps/h5-user/src/styles.css b/apps/h5-user/src/styles.css index 7c68771..89e617c 100644 --- a/apps/h5-user/src/styles.css +++ b/apps/h5-user/src/styles.css @@ -5663,6 +5663,18 @@ line-height: 1.5; } +.phone-verify-skip { + display: block; + width: 100%; + margin-top: 12px; + padding: 10px; + border: none; + background: transparent; + font-size: 14px; + color: var(--color-on-surface-variant, #888); + cursor: pointer; +} + .login-msg--hint { color: var(--color-success, #2d6a4f); } diff --git a/apps/mini-user/src/components/WechatShareBootstrap.tsx b/apps/mini-user/src/components/WechatShareBootstrap.tsx index a101541..4a2070a 100644 --- a/apps/mini-user/src/components/WechatShareBootstrap.tsx +++ b/apps/mini-user/src/components/WechatShareBootstrap.tsx @@ -68,13 +68,6 @@ export default function WechatShareBootstrap() { handleWechatAuthCallback() .then((result) => { if (!result) return; - if (result.needBindPhone && result.wxSessionKey) { - goLogin(returnFromLogin, { - bindMode: '1', - wxSessionKey: result.wxSessionKey, - }); - return; - } if (saveWechatLoginResult(result)) { toast('微信授权成功', 'success'); if ( @@ -83,6 +76,14 @@ export default function WechatShareBootstrap() { ) { finishLoginNavigate(returnFromLogin || params.get('return') || undefined); } + return; + } + // 兼容旧接口:仅 needBindPhone 时引导可选绑定,不阻塞浏览 + if (result.needBindPhone && result.wxSessionKey) { + goLogin(returnFromLogin, { + bindMode: '1', + wxSessionKey: result.wxSessionKey, + }); } }) .catch((e) => { diff --git a/apps/mini-user/src/lib/pay-ready.ts b/apps/mini-user/src/lib/pay-ready.ts index 704dfa7..25c95cb 100644 --- a/apps/mini-user/src/lib/pay-ready.ts +++ b/apps/mini-user/src/lib/pay-ready.ts @@ -5,7 +5,7 @@ import { fetchClientConfig, fetchUserProfile, needsWechatAuthForPay } from './pa /** * 支付前门禁: - * - 未登录 / 未验手机 → 跳转登录页 + * - 未登录 → 跳转登录页(微信授权即可,不强制手机号) * - H5 微信内缺 openId → 尝试 OAuth(可能跳转微信授权页) * - 小程序缺绑定 → 跳转登录页 needWechat */ @@ -17,10 +17,6 @@ export async function ensurePayReady(returnPath: string): Promise { try { const [config, profile] = await Promise.all([fetchClientConfig(), fetchUserProfile()]); - if (!profile.phoneVerified) { - goLogin(returnPath, { needPhone: '1' }); - return false; - } if (!needsWechatAuthForPay(config, profile)) { return true; } @@ -28,8 +24,9 @@ export async function ensurePayReady(returnPath: string): Promise { if (process.env.TARO_ENV === 'h5') { const auth = await ensureWechatAuthForPay(); if (auth.ok) return true; + // 旧版 needBindPhone 已不再返回;缺 openId 时走登录补微信绑定 if ('needBindPhone' in auth && auth.needBindPhone) { - goLogin(returnPath, { bindMode: '1', wxSessionKey: auth.wxSessionKey }); + goLogin(returnPath, { needWechat: '1' }); return false; } // redirecting:正在跳转微信 OAuth diff --git a/apps/mini-user/src/pages/login/index.tsx b/apps/mini-user/src/pages/login/index.tsx index c5617f7..2a10047 100644 --- a/apps/mini-user/src/pages/login/index.tsx +++ b/apps/mini-user/src/pages/login/index.tsx @@ -121,17 +121,18 @@ export default function LoginPage() { } function handleWechatLoginResult(result: WechatLoginResult, wxInfo?: MiniWechatProfile | null) { + // 微信授权成功即登录;手机号改为下单页可选绑定 + if (result.accessToken) { + applySessionAndLeave(result, undefined, wxInfo); + return; + } if (result.needBindPhone && result.wxSessionKey) { setBindMode(true); setWxSessionKey(result.wxSessionKey); - setMsg('微信授权成功,请绑定手机号完成登录'); + setMsg('微信授权成功,可绑定手机号(也可跳过,稍后在下单时再绑定)'); setSentHint(''); return; } - if (result.accessToken) { - applySessionAndLeave(result, undefined, wxInfo); - return; - } setMsg('微信登录未完成,请重试或使用手机号登录'); } @@ -286,13 +287,17 @@ export default function LoginPage() { {completeMode === 'phone' - ? '完成手机验证' + ? '建议绑定手机号' : completeMode === 'wechat' ? '完成微信授权' : '欢迎来到杜康好客'} - {completeMode ? '完成后将返回继续支付' : '买美酒,享好礼'} + {completeMode === 'phone' + ? '便于订单通知与售后,也可稍后绑定' + : completeMode === 'wechat' + ? '完成后将返回继续支付' + : '买美酒,享好礼'} @@ -365,6 +370,17 @@ export default function LoginPage() { : '登录'} + {completeMode === 'phone' ? ( + finishLoginNavigate(returnTo)} + style={{ marginTop: 12, textAlign: 'center' }} + > + + 暂不绑定,继续下单 + + + ) : null} )} diff --git a/apps/mini-user/src/pages/order-confirm/index.tsx b/apps/mini-user/src/pages/order-confirm/index.tsx index 946f175..851a501 100644 --- a/apps/mini-user/src/pages/order-confirm/index.tsx +++ b/apps/mini-user/src/pages/order-confirm/index.tsx @@ -1,12 +1,14 @@ -import { useEffect, useMemo, useState } from 'react'; +import { useEffect, useMemo, useRef, useState } from 'react'; import { View, Text, Image } from '@tarojs/components'; import Taro, { useRouter } from '@tarojs/taro'; import PageShell from '../../components/PageShell'; import SubPageHeader from '../../components/SubPageHeader'; +import { goLogin } from '../../lib/auth-nav'; import { buildAddressListUrl, buildPayUrl, readCheckoutContext } from '../../lib/checkout-nav'; import { tryGetClientGpsLocation } from '../../lib/client-location'; import { maskPhone } from '../../lib/phone'; import { ensurePayReady } from '../../lib/pay-ready'; +import { fetchUserProfile } from '../../lib/pay-wechat'; import { request } from '../../lib/api'; import { getProductMainImage } from '../../lib/product-images'; @@ -58,6 +60,7 @@ export default function OrderConfirmPage() { const [previewLoading, setPreviewLoading] = useState(false); const [loading, setLoading] = useState(false); const [msg, setMsg] = useState(''); + const phonePromptSkipped = useRef(false); useEffect(() => { request('/user/addresses') @@ -161,6 +164,30 @@ export default function OrderConfirmPage() { } const returnPath = `/pages/order-confirm/index?productId=${productId}&qty=${quantity}&addressId=${addressId}${forceCross ? '&cross=1' : ''}`; + + if (!phonePromptSkipped.current) { + try { + const profile = await fetchUserProfile(); + if (!profile.phoneVerified) { + const { confirm, cancel } = await Taro.showModal({ + title: '建议绑定手机号', + content: '绑定后便于订单通知与售后联系;也可跳过,不绑定也能继续下单。', + confirmText: '去绑定', + cancelText: '暂不绑定', + }); + if (confirm) { + goLogin(returnPath, { needPhone: '1' }); + return; + } + if (cancel) { + phonePromptSkipped.current = true; + } + } + } catch { + /* 拉取档案失败不阻塞下单 */ + } + } + const ready = await ensurePayReady(returnPath); if (!ready) return; diff --git a/server/dukang-api/src/modules/iam/auth.service.ts b/server/dukang-api/src/modules/iam/auth.service.ts index cb22ad4..3be0690 100644 --- a/server/dukang-api/src/modules/iam/auth.service.ts +++ b/server/dukang-api/src/modules/iam/auth.service.ts @@ -1059,7 +1059,8 @@ export class AuthService { include: { avatar: true }, }); - if (user?.phone && user.phoneVerifiedAt) { + // 微信登录不再强制绑定手机号;phoneVerified=false 也可签发会话,下单页仅提示可选绑定 + if (user) { let activeUser: UserRow = guestId && guestId !== user.id ? await this.mergeUsers(guestId, user.id) : (user as UserRow); activeUser = await this.prisma.user.update({ @@ -1087,7 +1088,7 @@ export class AuthService { if (guestId) { try { const guest = await this.assertActiveUser(guestId); - if (guest.phoneVerifiedAt && !guest.wxOpenId) { + if (!guest.wxOpenId) { const activeUser = await this.attachWechatToUser(guest.id, session, clientApp, platform); return this.buildSessionResponse(activeUser, clientApp, activeUser.deviceKey); } @@ -1096,36 +1097,34 @@ export class AuthService { } } - const wxSessionKey = randomUUID(); - await this.redis.setJson( - `wx:session:${wxSessionKey}`, - { - openId: session.openId, - unionId: session.unionId, - sessionKey: 'sessionKey' in session ? session.sessionKey : undefined, - accessToken: session.accessToken, - clientApp, - guestId: guestId?.toString(), - } satisfies WxSessionPayload, - 1800, - ); - - if (user && !user.phoneVerifiedAt) { - return { - needBindPhone: true, - wxSessionKey, - actorType: 'USER', - actorId: user.id.toString(), - phoneVerified: false, - user: this.formatUserProfile(user), - }; + let created = await this.prisma.user.create({ + data: { + userNo: generateUserNo(), + wxOpenId: session.openId, + wxUnionId: session.unionId, + nickname: '微信用户', + cityPreference: { + create: { + selectedCityCode: '410100', + selectedDistrict: '郑州市', + }, + }, + }, + include: { avatar: true }, + }); + if (session.accessToken) { + const synced = await this.syncWechatUserProfile(created.id, session.accessToken, session.openId); + if (synced) created = synced as UserRow; } - - return { - needBindPhone: true, - wxSessionKey, - phoneVerified: false, - }; + this.analyticsService.trackOneSafe(created.id, clientApp, { + eventName: 'wechat_login', + extraJson: { platform }, + }); + this.analyticsService.trackOneSafe(created.id, clientApp, { + eventName: 'login_success', + extraJson: { method: 'wechat', platform }, + }); + return this.buildSessionResponse(created, clientApp, created.deviceKey); } async bindWechatPhone( diff --git a/server/dukang-api/src/modules/trade/trade.controller.ts b/server/dukang-api/src/modules/trade/trade.controller.ts index 05a0e11..4dcc1f0 100644 --- a/server/dukang-api/src/modules/trade/trade.controller.ts +++ b/server/dukang-api/src/modules/trade/trade.controller.ts @@ -3,7 +3,6 @@ import type { Request } from 'express'; import { TradeService } from './trade.service'; import { JwtAuthGuard, AuthUser } from '../../common/guards/jwt-auth.guard'; import { PartnerPrimaryGuard } from '../../common/guards/partner-primary.guard'; -import { PhoneVerifiedGuard } from '../../common/guards/phone-verified.guard'; import { CurrentUser } from '../../common/decorators/current-user.decorator'; import { PartnerProxyOrderCreateDto, @@ -22,7 +21,6 @@ export class TradeController { } @Post() - @UseGuards(PhoneVerifiedGuard) create(@CurrentUser() user: AuthUser, @Body() body: Record, @Req() req: Request) { return this.tradeService.createOrder(user.actorId, body as never, req); } @@ -43,7 +41,6 @@ export class TradeController { } @Post(':id/pay') - @UseGuards(PhoneVerifiedGuard) pay(@CurrentUser() user: AuthUser, @Param('id') id: string) { return this.tradeService.payOrder(user.actorId, BigInt(id), user.clientApp); } diff --git a/杜康好客-v3-PRD.md b/杜康好客-v3-PRD.md index 85bfa66..36fa540 100644 --- a/杜康好客-v3-PRD.md +++ b/杜康好客-v3-PRD.md @@ -229,7 +229,7 @@ | 模块 | 要点 | |------|------| -| 导航账号 | 四 Tab;无感登录;确认下单强制手机号;仅微信支付;7 天免登 | +| 导航账号 | 四 Tab;无感登录;确认下单提示绑定手机号(可选、不强制);仅微信支付;7 天免登 | | 商品下单 | 4 款酒祖杜康 SKU;同城≥2瓶免运费;跨城≥1箱;现场提货隐藏;锁单30分钟 | | 权益核销 | 1:1 发放;出码 3 分钟;核销前规则弹窗(OPT-011);附件一规则详情 | | 门店 | 列表/详情/搜索/省市区筛选;仅营业中展示;立即核销 | diff --git a/杜康好客-v3-现状对照.md b/杜康好客-v3-现状对照.md index d0864c7..d083911 100644 --- a/杜康好客-v3-现状对照.md +++ b/杜康好客-v3-现状对照.md @@ -99,7 +99,7 @@ | REQ | 功能 | 证据 | 备注 | |-----|------|------|------| | REQ-U-001 | 四 Tab 导航 | `src/layouts/TabLayout.tsx` | 形态为 H5 非小程序 | -| REQ-U-002 | 登录 + 下单强制手机号 | `OrderConfirmPage.tsx`、`PhoneVerifiedGuard` | ✅ | +| REQ-U-002 | 登录 + 下单提示手机号(可选) | `OrderConfirmPage` / `order-confirm`、微信登录签发会话 | ✅ | | REQ-U-003 | 微信支付 | `pay-wechat.ts` + 后端 callback | Mock/真实均有 | | REQ-U-004 | 定位/开城 | `HomePage.tsx`、`wechat-location.ts` | 🔶 H5 定位 API | | REQ-U-005~006 | 商品列表/详情 | `HomePage.tsx`、`ProductDetailPage.tsx` | ✅ seed 已对齐酒祖杜康 | From 5fe1ff1fc3acc31a4fb6fd61a6ca09476a1e33a8 Mon Sep 17 00:00:00 2001 From: jacy <18049821889@163.com> Date: Wed, 15 Jul 2026 20:03:06 +0800 Subject: [PATCH 4/4] =?UTF-8?q?mock=E7=9F=AD=E4=BF=A1=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=9B=9E=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin-web/src/pages/SystemSettingsPage.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/admin-web/src/pages/SystemSettingsPage.tsx b/apps/admin-web/src/pages/SystemSettingsPage.tsx index d5ca185..4b27e1d 100644 --- a/apps/admin-web/src/pages/SystemSettingsPage.tsx +++ b/apps/admin-web/src/pages/SystemSettingsPage.tsx @@ -276,6 +276,16 @@ export default function SystemSettingsPage() { const data = await request('/admin/system-config'); + if (silent) { + // 仅刷新 Mock 验证码列表,避免轮询用服务端值覆盖未保存的表单(含 MOCK_SMS 开关) + setMeta((prev) => + prev + ? { ...prev, mockSmsCodes: data.mockSmsCodes, updatedAt: data.updatedAt } + : data, + ); + return; + } + setMeta(data); form.setFieldsValue(data.values); @@ -304,6 +314,7 @@ export default function SystemSettingsPage() { useEffect(() => { + // 以表单开关为准展示验证码;轮询只刷列表,不回写表单 if (!mockSmsEnabled) return; const timer = window.setInterval(() => void load(true), 5000);