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 {
|
.partner-checkbox-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: center;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
margin-top: var(--space-md);
|
margin-top: var(--space-md);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: var(--color-on-surface-variant);
|
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 {
|
.partner-auth-footer {
|
||||||
margin-top: var(--space-lg);
|
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 { Link, useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
import { useStoreSession } from '../contexts/StoreSessionContext';
|
import { useStoreSession } from '../contexts/StoreSessionContext';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
@@ -43,13 +43,37 @@ export default function HomePage() {
|
|||||||
const [authLoading, setAuthLoading] = useState(false);
|
const [authLoading, setAuthLoading] = useState(false);
|
||||||
const [authError, setAuthError] = useState('');
|
const [authError, setAuthError] = useState('');
|
||||||
|
|
||||||
useEffect(() => {
|
const loadDashboard = useCallback(() => {
|
||||||
request<Record<string, unknown>>('SHOP_H5', '/shop/dashboard').then((d) => {
|
return request<Record<string, unknown>>('SHOP_H5', '/shop/dashboard')
|
||||||
|
.then((d) => {
|
||||||
setDash(d);
|
setDash(d);
|
||||||
setOpen(String((d.store as Record<string, unknown>)?.status) === 'OPEN');
|
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(() => {
|
useEffect(() => {
|
||||||
if (!isWechatEnv() || !searchParams.get('code')) return;
|
if (!isWechatEnv() || !searchParams.get('code')) return;
|
||||||
void handleShopWechatCallback()
|
void handleShopWechatCallback()
|
||||||
@@ -84,7 +108,10 @@ export default function HomePage() {
|
|||||||
try {
|
try {
|
||||||
await weixinSdk.init();
|
await weixinSdk.init();
|
||||||
const raw = await weixinSdk.scanQrCode();
|
const raw = await weixinSdk.scanQrCode();
|
||||||
if (!raw) return;
|
if (!raw) {
|
||||||
|
void loadDashboard();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const token = parseRedeemTokenFromScan(raw);
|
const token = parseRedeemTokenFromScan(raw);
|
||||||
if (!token) {
|
if (!token) {
|
||||||
setScanMsg('无法识别核销码,请扫描用户出示的核销二维码');
|
setScanMsg('无法识别核销码,请扫描用户出示的核销二维码');
|
||||||
|
|||||||
@@ -248,14 +248,14 @@
|
|||||||
|
|
||||||
.shop-login-agreement {
|
.shop-login-agreement {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
max-width: 280px;
|
max-width: 280px;
|
||||||
margin: 32px auto 0;
|
margin: 32px auto 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.shop-login-agreement input {
|
.shop-login-agreement input {
|
||||||
margin-top: 4px;
|
margin-top: 0;
|
||||||
accent-color: var(--color-heritage-red);
|
accent-color: var(--color-heritage-red);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1553,7 +1553,7 @@
|
|||||||
|
|
||||||
.login-agreement {
|
.login-agreement {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
font-family: var(--font-label);
|
font-family: var(--font-label);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
@@ -1565,7 +1565,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.login-agreement input {
|
.login-agreement input {
|
||||||
margin-top: 2px;
|
margin-top: 0;
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ export function buildAddressListUrl(ctx: CheckoutContext): string {
|
|||||||
export function buildAddressEditUrl(id: string | undefined, 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 base = id ? `/pages/address-edit/index?id=${encodeURIComponent(id)}` : '/pages/address-edit/index';
|
||||||
const extra = buildQuery(ctx);
|
const extra = buildQuery(ctx);
|
||||||
return extra ? `${base}&${extra}` : base;
|
if (!extra) return base;
|
||||||
|
return `${base}${base.includes('?') ? '&' : '?'}${extra}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildPayUrl(params: {
|
export function buildPayUrl(params: {
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ export default function AddressEditPage() {
|
|||||||
const validationError = validateForm();
|
const validationError = validateForm();
|
||||||
if (validationError) {
|
if (validationError) {
|
||||||
setError(validationError);
|
setError(validationError);
|
||||||
|
toast(validationError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +111,9 @@ export default function AddressEditPage() {
|
|||||||
});
|
});
|
||||||
}, 400);
|
}, 400);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(e instanceof Error ? e.message : '保存失败');
|
const msg = e instanceof Error ? e.message : '保存失败';
|
||||||
|
setError(msg);
|
||||||
|
toast(msg);
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,9 @@ export default function AddressesPage() {
|
|||||||
className="address-action"
|
className="address-action"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
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>
|
||||||
<View
|
<View
|
||||||
className="address-fab"
|
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>
|
<Text>新增地址</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -59,8 +59,8 @@
|
|||||||
|
|
||||||
.address-fab {
|
.address-fab {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
left: 16px;
|
left: var(--space-page, 16px);
|
||||||
right: 16px;
|
right: var(--space-page, 16px);
|
||||||
bottom: calc(16px + env(safe-area-inset-bottom, 0px));
|
bottom: calc(16px + env(safe-area-inset-bottom, 0px));
|
||||||
height: 48px;
|
height: 48px;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
@@ -71,15 +71,19 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
z-index: 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
.address-form-field {
|
.address-form-field {
|
||||||
margin: 0 var(--space-page) 12px;
|
margin: 0 var(--space-page) 12px;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.address-form-label {
|
.address-form-label {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
line-height: 18px;
|
||||||
color: var(--color-on-surface-variant);
|
color: var(--color-on-surface-variant);
|
||||||
margin-bottom: 6px;
|
margin-bottom: 6px;
|
||||||
}
|
}
|
||||||
@@ -88,22 +92,63 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
padding: 0 14px;
|
padding: 0 14px;
|
||||||
|
border: none;
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
background: var(--color-card);
|
background: var(--color-card);
|
||||||
box-shadow: var(--shadow-card);
|
box-shadow: var(--shadow-card);
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
line-height: 48px;
|
||||||
|
color: var(--color-on-surface);
|
||||||
box-sizing: border-box;
|
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 {
|
.address-form-textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 88px;
|
min-height: 88px;
|
||||||
padding: 12px 14px;
|
padding: 12px 14px;
|
||||||
|
border: none;
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
background: var(--color-card);
|
background: var(--color-card);
|
||||||
box-shadow: var(--shadow-card);
|
box-shadow: var(--shadow-card);
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: var(--color-on-surface);
|
||||||
box-sizing: border-box;
|
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 {
|
.address-form-row {
|
||||||
@@ -112,9 +157,11 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin: 0 var(--space-page) 12px;
|
margin: 0 var(--space-page) 12px;
|
||||||
padding: 12px 14px;
|
padding: 12px 14px;
|
||||||
|
min-height: 48px;
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
background: var(--color-card);
|
background: var(--color-card);
|
||||||
box-shadow: var(--shadow-card);
|
box-shadow: var(--shadow-card);
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.address-form-error {
|
.address-form-error {
|
||||||
|
|||||||
@@ -285,14 +285,14 @@
|
|||||||
|
|
||||||
.login-agreement {
|
.login-agreement {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-agreement-check {
|
.login-agreement-check {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
margin-top: 2px;
|
margin-top: 0;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
border: 1px solid var(--color-outline, #c8c4be);
|
border: 1px solid var(--color-outline, #c8c4be);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
@@ -300,6 +300,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
|
line-height: 1;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user