fix(mini-user): address URL, form align, agreement checkbox, shop scan resume
CI / verify (pull_request) Has been cancelled
CI / verify (pull_request) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -166,14 +166,14 @@ html {
|
||||
|
||||
.partner-checkbox-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-top: var(--space-md);
|
||||
font-size: 12px;
|
||||
color: var(--color-on-surface-variant);
|
||||
}
|
||||
|
||||
.partner-checkbox-row input { margin-top: 2px; accent-color: var(--color-heritage-red); }
|
||||
.partner-checkbox-row input { margin-top: 0; accent-color: var(--color-heritage-red); }
|
||||
|
||||
.partner-auth-footer {
|
||||
margin-top: var(--space-lg);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { Link, useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { useStoreSession } from '../contexts/StoreSessionContext';
|
||||
import { request } from '../lib/api';
|
||||
@@ -43,13 +43,37 @@ export default function HomePage() {
|
||||
const [authLoading, setAuthLoading] = useState(false);
|
||||
const [authError, setAuthError] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
request<Record<string, unknown>>('SHOP_H5', '/shop/dashboard').then((d) => {
|
||||
const loadDashboard = useCallback(() => {
|
||||
return request<Record<string, unknown>>('SHOP_H5', '/shop/dashboard')
|
||||
.then((d) => {
|
||||
setDash(d);
|
||||
setOpen(String((d.store as Record<string, unknown>)?.status) === 'OPEN');
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
void loadDashboard();
|
||||
}, [loadDashboard]);
|
||||
|
||||
useEffect(() => {
|
||||
function onResume() {
|
||||
setScanning(false);
|
||||
void loadDashboard();
|
||||
}
|
||||
function onVisibility() {
|
||||
if (document.visibilityState === 'visible') onResume();
|
||||
}
|
||||
document.addEventListener('visibilitychange', onVisibility);
|
||||
window.addEventListener('pageshow', onResume);
|
||||
window.addEventListener('focus', onResume);
|
||||
return () => {
|
||||
document.removeEventListener('visibilitychange', onVisibility);
|
||||
window.removeEventListener('pageshow', onResume);
|
||||
window.removeEventListener('focus', onResume);
|
||||
};
|
||||
}, [loadDashboard]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isWechatEnv() || !searchParams.get('code')) return;
|
||||
void handleShopWechatCallback()
|
||||
@@ -84,7 +108,10 @@ export default function HomePage() {
|
||||
try {
|
||||
await weixinSdk.init();
|
||||
const raw = await weixinSdk.scanQrCode();
|
||||
if (!raw) return;
|
||||
if (!raw) {
|
||||
void loadDashboard();
|
||||
return;
|
||||
}
|
||||
const token = parseRedeemTokenFromScan(raw);
|
||||
if (!token) {
|
||||
setScanMsg('无法识别核销码,请扫描用户出示的核销二维码');
|
||||
|
||||
@@ -248,14 +248,14 @@
|
||||
|
||||
.shop-login-agreement {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
max-width: 280px;
|
||||
margin: 32px auto 0;
|
||||
}
|
||||
|
||||
.shop-login-agreement input {
|
||||
margin-top: 4px;
|
||||
margin-top: 0;
|
||||
accent-color: var(--color-heritage-red);
|
||||
}
|
||||
|
||||
|
||||
@@ -1553,7 +1553,7 @@
|
||||
|
||||
.login-agreement {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-family: var(--font-label);
|
||||
font-size: 12px;
|
||||
@@ -1565,7 +1565,7 @@
|
||||
}
|
||||
|
||||
.login-agreement input {
|
||||
margin-top: 2px;
|
||||
margin-top: 0;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
flex-shrink: 0;
|
||||
|
||||
@@ -29,7 +29,8 @@ export function buildAddressListUrl(ctx: CheckoutContext): string {
|
||||
export function buildAddressEditUrl(id: string | undefined, ctx: CheckoutContext): string {
|
||||
const base = id ? `/pages/address-edit/index?id=${encodeURIComponent(id)}` : '/pages/address-edit/index';
|
||||
const extra = buildQuery(ctx);
|
||||
return extra ? `${base}&${extra}` : base;
|
||||
if (!extra) return base;
|
||||
return `${base}${base.includes('?') ? '&' : '?'}${extra}`;
|
||||
}
|
||||
|
||||
export function buildPayUrl(params: {
|
||||
|
||||
@@ -82,6 +82,7 @@ export default function AddressEditPage() {
|
||||
const validationError = validateForm();
|
||||
if (validationError) {
|
||||
setError(validationError);
|
||||
toast(validationError);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -110,7 +111,9 @@ export default function AddressEditPage() {
|
||||
});
|
||||
}, 400);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : '保存失败');
|
||||
const msg = e instanceof Error ? e.message : '保存失败';
|
||||
setError(msg);
|
||||
toast(msg);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,9 @@ export default function AddressesPage() {
|
||||
className="address-action"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
Taro.navigateTo({ url: buildAddressEditUrl(a.id, checkoutCtx) });
|
||||
Taro.navigateTo({ url: buildAddressEditUrl(a.id, checkoutCtx) }).catch((err) => {
|
||||
toast(err instanceof Error ? err.message : '无法打开编辑页');
|
||||
});
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
@@ -120,7 +122,11 @@ export default function AddressesPage() {
|
||||
</View>
|
||||
<View
|
||||
className="address-fab"
|
||||
onClick={() => Taro.navigateTo({ url: buildAddressEditUrl(undefined, checkoutCtx) })}
|
||||
onClick={() => {
|
||||
Taro.navigateTo({ url: buildAddressEditUrl(undefined, checkoutCtx) }).catch((e) => {
|
||||
toast(e instanceof Error ? e.message : '无法打开新增地址页');
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Text>新增地址</Text>
|
||||
</View>
|
||||
|
||||
@@ -59,8 +59,8 @@
|
||||
|
||||
.address-fab {
|
||||
position: fixed;
|
||||
left: 16px;
|
||||
right: 16px;
|
||||
left: var(--space-page, 16px);
|
||||
right: var(--space-page, 16px);
|
||||
bottom: calc(16px + env(safe-area-inset-bottom, 0px));
|
||||
height: 48px;
|
||||
border-radius: 999px;
|
||||
@@ -71,15 +71,19 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
.address-form-field {
|
||||
margin: 0 var(--space-page) 12px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.address-form-label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
color: var(--color-on-surface-variant);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
@@ -88,22 +92,63 @@
|
||||
width: 100%;
|
||||
height: 48px;
|
||||
padding: 0 14px;
|
||||
border: none;
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--color-card);
|
||||
box-shadow: var(--shadow-card);
|
||||
font-size: 15px;
|
||||
line-height: 48px;
|
||||
color: var(--color-on-surface);
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* Taro H5:样式常落在包装节点,需强制原生控件铺满对齐 */
|
||||
.address-form-input input,
|
||||
.address-form-input .taro-input,
|
||||
.address-form-input .weui-input {
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
min-height: 0 !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
border: none !important;
|
||||
background: transparent !important;
|
||||
box-sizing: border-box !important;
|
||||
font-size: 15px !important;
|
||||
line-height: normal !important;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.address-form-textarea {
|
||||
width: 100%;
|
||||
min-height: 88px;
|
||||
padding: 12px 14px;
|
||||
border: none;
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--color-card);
|
||||
box-shadow: var(--shadow-card);
|
||||
font-size: 15px;
|
||||
line-height: 1.5;
|
||||
color: var(--color-on-surface);
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.address-form-textarea textarea,
|
||||
.address-form-textarea .taro-textarea,
|
||||
.address-form-textarea .weui-textarea {
|
||||
width: 100% !important;
|
||||
min-height: 64px !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
border: none !important;
|
||||
background: transparent !important;
|
||||
box-sizing: border-box !important;
|
||||
font-size: 15px !important;
|
||||
line-height: 1.5 !important;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.address-form-row {
|
||||
@@ -112,9 +157,11 @@
|
||||
justify-content: space-between;
|
||||
margin: 0 var(--space-page) 12px;
|
||||
padding: 12px 14px;
|
||||
min-height: 48px;
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--color-card);
|
||||
box-shadow: var(--shadow-card);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.address-form-error {
|
||||
|
||||
@@ -285,14 +285,14 @@
|
||||
|
||||
.login-agreement {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.login-agreement-check {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-top: 2px;
|
||||
margin-top: 0;
|
||||
border-radius: 4px;
|
||||
border: 1px solid var(--color-outline, #c8c4be);
|
||||
flex-shrink: 0;
|
||||
@@ -300,6 +300,7 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 11px;
|
||||
line-height: 1;
|
||||
color: #fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user