feat(v3.4.14): mini-user store UX, brand config, client settings
Store list/detail package flow, configurable WeChat mini brand assets and customer service, shop H5 home refresh. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import {
|
||||
BRAND_LOGO_MARK_URL,
|
||||
BRAND_LOGO_URL,
|
||||
BRAND_LOGO_WIDE_URL,
|
||||
CUSTOMER_SERVICE_PHONE,
|
||||
QUALIFICATION_DISCLOSURE_URL,
|
||||
type ClientRuntimeConfig,
|
||||
} from '@dukang/shared-types';
|
||||
import { fetchClientConfig } from './pay-wechat';
|
||||
|
||||
export type BrandAssets = {
|
||||
brandLogoUrl: string;
|
||||
brandLogoWideUrl: string;
|
||||
brandLogoMarkUrl: string;
|
||||
qualificationDisclosureUrl: string;
|
||||
customerServicePhone: string;
|
||||
};
|
||||
|
||||
const FALLBACK: BrandAssets = {
|
||||
brandLogoUrl: BRAND_LOGO_URL,
|
||||
brandLogoWideUrl: BRAND_LOGO_WIDE_URL,
|
||||
brandLogoMarkUrl: BRAND_LOGO_MARK_URL,
|
||||
qualificationDisclosureUrl: QUALIFICATION_DISCLOSURE_URL,
|
||||
customerServicePhone: CUSTOMER_SERVICE_PHONE,
|
||||
};
|
||||
|
||||
let cached: BrandAssets | null = null;
|
||||
let inflight: Promise<BrandAssets> | null = null;
|
||||
|
||||
function fromConfig(config: ClientRuntimeConfig | null | undefined): BrandAssets {
|
||||
return {
|
||||
brandLogoUrl: config?.brandLogoUrl?.trim() || FALLBACK.brandLogoUrl,
|
||||
brandLogoWideUrl: config?.brandLogoWideUrl?.trim() || FALLBACK.brandLogoWideUrl,
|
||||
brandLogoMarkUrl: config?.brandLogoMarkUrl?.trim() || FALLBACK.brandLogoMarkUrl,
|
||||
qualificationDisclosureUrl:
|
||||
config?.qualificationDisclosureUrl?.trim() || FALLBACK.qualificationDisclosureUrl,
|
||||
customerServicePhone: config?.customerServicePhone?.trim() || FALLBACK.customerServicePhone,
|
||||
};
|
||||
}
|
||||
|
||||
/** 同步读取最近一次缓存(未拉取前返回代码默认常量) */
|
||||
export function getBrandAssetsSync(): BrandAssets {
|
||||
return cached ?? FALLBACK;
|
||||
}
|
||||
|
||||
/** 拉取 /common/client-config 中的品牌与客服配置并缓存 */
|
||||
export async function loadBrandAssets(force = false): Promise<BrandAssets> {
|
||||
if (!force && cached) return cached;
|
||||
if (!force && inflight) return inflight;
|
||||
inflight = fetchClientConfig()
|
||||
.then((cfg) => {
|
||||
cached = fromConfig(cfg);
|
||||
return cached;
|
||||
})
|
||||
.catch(() => {
|
||||
cached = FALLBACK;
|
||||
return cached;
|
||||
})
|
||||
.finally(() => {
|
||||
inflight = null;
|
||||
});
|
||||
return inflight;
|
||||
}
|
||||
|
||||
export function applyBrandFromClientConfig(config: ClientRuntimeConfig | null | undefined) {
|
||||
cached = fromConfig(config);
|
||||
return cached;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import Taro from '@tarojs/taro';
|
||||
import { fetchClientConfig } from './pay-wechat';
|
||||
|
||||
/** 与 package.json version 同步,供服务端 minClientVersion 比对 */
|
||||
export const APP_VERSION = '3.4.13';
|
||||
export const APP_VERSION = '3.4.14';
|
||||
|
||||
export const APP_VERSION_LABEL = `v${APP_VERSION}`;
|
||||
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
import Taro from '@tarojs/taro';
|
||||
import { BRAND_LOGO_URL } from '@dukang/shared-types';
|
||||
import type { WechatShareData } from '@dukang/weixin-sdk';
|
||||
import { getWechatShareLink, isWechatBrowser, isMiniProgram } from '@dukang/weixin-sdk';
|
||||
import { toast } from './api';
|
||||
import { getBrandAssetsSync, loadBrandAssets } from './brand-assets';
|
||||
import { isWechatEnv, weixinSdk } from './weixin';
|
||||
|
||||
export const DEFAULT_SHARE_TITLE = '你吃饭,杜康买单';
|
||||
export const DEFAULT_SHARE_TITLE = '你吃饭,我买单';
|
||||
export const DEFAULT_SHARE_DESC = '杜康好客 · 买美酒,享好礼,全城门店可用';
|
||||
export const WECHAT_SHARE_HINT = '请点击右上角 ··· 分享给好友';
|
||||
|
||||
export function getDefaultShareImageUrl(): string {
|
||||
return BRAND_LOGO_URL;
|
||||
return getBrandAssetsSync().brandLogoUrl;
|
||||
}
|
||||
|
||||
/** 预热分享默认图(来自系统设置) */
|
||||
export function prefetchShareBrandAssets() {
|
||||
void loadBrandAssets();
|
||||
}
|
||||
|
||||
export function buildDefaultShareData(
|
||||
|
||||
Reference in New Issue
Block a user