Commit 5d9cd376 by 张立顺

Merge branch 'v1.4.0' into V5.8.2

2 parents fee0c673 037af353
......@@ -123,11 +123,27 @@ public class Agreement extends AuditingEntity implements Serializable {
FAPAI_PRIVACY,
/**
* 优惠券协议 1
*/
COUPON_1,
/**
* 优惠券协议 2
*/
COUPON_2,
/**
* 优惠券协议 3
*/
COUPON_3,
/**
* 优惠券协议 4
*/
COUPON_4,
/**
* 优惠券协议 5
*/
COUPON_5,
;
}
......
......@@ -4,19 +4,9 @@ MODE = 'development'
# 发布路径
PUBLISH_PATH = '/'
# 平台端请求路径
# VITE_APP_API_BASE_URL = 'http://192.168.0.108:5001/rest/'
# VITE_APP_API_URL = 'http://localhost:6901/api/'
# VITE_APP_API_BASE_URL = 'http://localhost:6901/'
# VITE_APP_API_URL = 'https://aus.glsx.com.cn/app/api/'
# VITE_APP_API_BASE_URL = 'https://aus.glsx.com.cn/app/'
VITE_APP_API_URL = 'https://aus.test.glsx.com.cn/app/api/'
VITE_APP_API_BASE_URL = 'https://aus.test.glsx.com.cn/app/'
# VITE_APP_API_URL = 'http://192.168.1.125:6901/api/'
# VITE_APP_API_BASE_URL = 'http://192.168.1.125:6901/'
# 平台端请求路径(生产/回退默认;开发态改 src/config/activeDevApiEnv.ts)
VITE_APP_API_URL=https://aus.test.glsx.com.cn/app/api/
VITE_APP_API_BASE_URL=https://aus.test.glsx.com.cn/app/
# 优惠券相关 CDN 图:`{BASE}/{文件名}`,与 dj-aus 小程序资源路径对齐
VITE_APP_COUPON_IMAGE_BASE_URL=https://img01.glsx.com.cn/weapp/resource/dj-aus/images/coupon
......
......@@ -9,11 +9,11 @@ PUBLISH_PATH = '/'
# VITE_APP_API_URL = 'http://120.237.107.125:6911/api/'
# VITE_APP_API_BASE_URL = 'http://120.237.107.125:6911/'
# VITE_APP_API_URL = 'https://aus.glsx.com.cn/app/api/'
# VITE_APP_API_BASE_URL = 'https://aus.glsx.com.cn/app/'
VITE_APP_API_URL = 'https://aus.glsx.com.cn/app/api/'
VITE_APP_API_BASE_URL = 'https://aus.glsx.com.cn/app/'
VITE_APP_API_URL = 'https://aus.test.glsx.com.cn/app/api/'
VITE_APP_API_BASE_URL = 'https://aus.test.glsx.com.cn/app/'
# VITE_APP_API_URL = 'https://aus.test.glsx.com.cn/app/api/'
# VITE_APP_API_BASE_URL = 'https://aus.test.glsx.com.cn/app/'
VITE_APP_COUPON_IMAGE_BASE_URL=https://img01.glsx.com.cn/weapp/resource/dj-aus/images/coupon
......
......@@ -52,7 +52,7 @@ const getLocationFn = () => {
},
fail(err) {
console.error('获取位置失败', err);
if (err.errMsg.indexOf('deny') !== -1) {
if (err?.errMsg?.indexOf('deny') !== -1) {
uni.showModal({
title: '权限提示',
content: '您拒绝了位置权限,是否去设置中开启?',
......
export type CouponFacePresent =
| { mode: "wan"; wanMain: string }
| { mode: "yuan"; text: string };
/** 去掉小数点后无意义的尾随 0(如 9.00 → 9,9.50 → 9.5) */
function trimTrailingDotZeros(s: string): string {
let t = s;
if (t.endsWith(".00")) {
return t.slice(0, -3);
}
while (t.endsWith("0") && t.includes(".")) {
t = t.slice(0, -1);
}
return t.endsWith(".") ? t.slice(0, -1) : t;
}
/** 防抖到分再格式化为字符串,去掉无意义的尾随 0(如 9.00 → 9,9.50 → 9.5) */
function trimYuanDisplay(amount: number): string {
const centsSafe = Math.round(amount * 100) / 100;
return trimTrailingDotZeros(centsSafe.toFixed(2));
}
/**
* ≥10000:以「万」为单位,金额按元先向下截断到「分」再换算(与 /10000 四舍五入取整相比不误进位)。
* 例:9999999.99 元 → 999.99万,而非 round 后的 1000万。
*/
function formatWanMainFromAmount(amount: number): string {
const wanTruncToCent = Math.floor(amount / 100 + 1e-9) / 100;
return trimTrailingDotZeros(wanTruncToCent.toFixed(2));
}
/** 优惠券卡面左侧主数字语义:≥10000 用「万」展示(最多两位小数,截断非四舍五入);否则为元 */
export function getCouponFacePresent(amount: number): CouponFacePresent {
if (!Number.isFinite(amount) || amount <= 0) {
return { mode: "yuan", text: "0" };
}
if (amount >= 10000) {
const wanMain = formatWanMainFromAmount(amount);
return { mode: "wan", wanMain: wanMain || "0" };
}
return { mode: "yuan", text: trimYuanDisplay(amount) };
}
/** 金额紧凑文案(不带 ¥):过万为 「1万」「999.99万」;未满万只数字片段;不含汉字「元」 */
export function formatCouponMoneyCompact(amount: number): string {
const p = getCouponFacePresent(amount);
if (p.mode === "wan") return `${p.wanMain}万`;
return p.text;
}
/** 用于单行文案的金额段:过万为 「¥1万」;未满万只数字,不写「元」、不加 ¥ */
export function formatCouponCaptionWithMoneySymbol(amount: number): string {
const p = getCouponFacePresent(amount);
const compact = formatCouponMoneyCompact(amount);
if (p.mode === "wan") {
return `¥${compact}`;
}
return compact;
}
/** 支付明细行「−…」:过万 `-¥1万`,未满万 `−金额`(无 ¥、无「元」) */
export function formatCouponDeductionMinus(amount: number): string {
const p = getCouponFacePresent(amount);
const compact = formatCouponMoneyCompact(amount);
if (p.mode === "wan") {
return `-¥${compact}`;
}
return `-${compact}`;
}
const DENSE_SM = "coupon-face--sm";
const DENSE_XS = "coupon-face--xs";
/**
* 收窄容器内避免单行撑破:根据紧凑文案长度档位缩小字号。
* 绑定在左侧金额外层(与 mode 无关,统一看最终展示跨度)。
*/
export function couponFaceAmountDenseClass(amount: number): string {
const compact = formatCouponMoneyCompact(amount);
const digitLen = compact.replace(/\./g, "").replace("万", "").length;
if (compact.includes("万")) {
if (digitLen >= 5) return DENSE_XS;
if (digitLen >= 2) return DENSE_SM;
return "";
}
if (digitLen >= 6) return DENSE_XS;
if (digitLen >= 4) return DENSE_SM;
return "";
}
......@@ -15,9 +15,18 @@
<scroll-view scroll-y class="benefit-scroll" :show-scrollbar="true">
<view v-for="item in payload.couponList" :key="item.couponId" class="coupon-ticket">
<view class="coupon-ticket__amt">
<view class="coupon-ticket__amt" :class="couponFaceDenseClass(item.faceAmount)">
<text class="coupon-ticket__y">¥</text>
<text class="coupon-ticket__num">{{ formatFaceThousands(item.faceAmount) }}</text>
<template v-if="couponFacePresent(item.faceAmount).mode === 'wan'">
<text class="coupon-ticket__wan-num">{{
couponFacePresent(item.faceAmount).wanMain
}}</text>
<text class="coupon-ticket__wan-unit">万</text>
</template>
<template v-else>
<text class="coupon-ticket__num">{{
couponFacePresent(item.faceAmount).text }}</text>
</template>
</view>
<view class="coupon-ticket__body">
<view class="coupon-ticket__name">{{ item.templateName }}</view>
......@@ -64,6 +73,11 @@ import {
trackCouponPopupClose,
} from "@/common/eventTracking";
import { couponImageUrl } from "@/common/couponImageUrl";
import {
couponFaceAmountDenseClass,
getCouponFacePresent,
type CouponFacePresent,
} from "@/common/couponFaceAmount";
/** CDN 文件名(基础域名见 `VITE_APP_COUPON_IMAGE_BASE_URL`);popupType===1 过户成功与其余类型各一张 */
const COUPON_HEADER_SUCCESS = "success.png";
......@@ -198,16 +212,12 @@ export default class CouponHomeBenefitPopup extends Vue {
return this.layoutVariant === "aggregateRewards" ? "一键收下" : "我知道了";
}
formatFaceThousands(n: number): string {
const x = Number(n);
if (!Number.isFinite(x)) {
return "0";
}
return x.toLocaleString("zh-CN", {
useGrouping: true,
minimumFractionDigits: 0,
maximumFractionDigits: 2,
});
couponFacePresent(amount: number): CouponFacePresent {
return getCouponFacePresent(amount);
}
couponFaceDenseClass(amount: number): string {
return couponFaceAmountDenseClass(amount);
}
formatValidEndDate(raw: string): string {
......@@ -455,8 +465,11 @@ export default class CouponHomeBenefitPopup extends Vue {
}
.coupon-ticket__amt {
width: 76px;
height: 76px;
max-width: 72px;
width: 72px;
max-height: 72px;
aspect-ratio: 1;
box-sizing: border-box;
flex-shrink: 0;
background: #fff0f0;
display: flex;
......@@ -468,15 +481,60 @@ export default class CouponHomeBenefitPopup extends Vue {
margin-right: 6px;
margin-bottom: 6px;
margin-left: 6px;
box-sizing: border-box;
flex-wrap: nowrap;
min-width: 0;
}
.coupon-ticket__y {
font-family: "numberNor", sans-serif;
font-size: 20px;
font-weight: 700;
font-size: 14px;
font-weight: 600;
color: #ff5500;
line-height: 1.15;
margin-right: 1px;
}
.coupon-ticket__wan-num {
font-family: "numberNor", sans-serif;
font-size: 22px;
font-weight: 700;
color: #ff5500;
line-height: 1.05;
}
.coupon-ticket__wan-unit {
font-family: "numberNor", sans-serif;
font-size: 16px;
font-weight: 700;
color: #ff5500;
line-height: 1.1;
margin-left: 1px;
}
.coupon-ticket__amt.coupon-face--sm .coupon-ticket__y {
font-size: 12px;
}
.coupon-ticket__amt.coupon-face--sm .coupon-ticket__wan-num,
.coupon-ticket__amt.coupon-face--sm .coupon-ticket__num {
font-size: 18px;
}
.coupon-ticket__amt.coupon-face--sm .coupon-ticket__wan-unit {
font-size: 14px;
}
.coupon-ticket__amt.coupon-face--xs .coupon-ticket__y {
font-size: 11px;
}
.coupon-ticket__amt.coupon-face--xs .coupon-ticket__wan-num,
.coupon-ticket__amt.coupon-face--xs .coupon-ticket__num {
font-size: 14px;
}
.coupon-ticket__amt.coupon-face--xs .coupon-ticket__wan-unit {
font-size: 12px;
}
.coupon-ticket__num {
......@@ -484,7 +542,7 @@ export default class CouponHomeBenefitPopup extends Vue {
font-size: 20px;
font-weight: 700;
color: #ff5500;
margin-left: 2px;
margin-left: 1px;
line-height: 1.15;
}
......
import type { DevApiEnvKey } from "@/config/devApiEnvironments";
/**
* 开发态 API 环境:改下面这一行并保存,在微信开发者工具里编译/刷新即可。
* 无需改 `.env`、无需重启 `npm run dev:mp-weixin`。
*
* 可选值见 `devApiEnvironments.ts`:test | prod | local-125 | local-6901 | local-108
*/
// export const ACTIVE_DEV_API_ENV: DevApiEnvKey = "local-125";
export const ACTIVE_DEV_API_ENV: DevApiEnvKey = "test";
/** 各环境 URL 定义;切换请改 `activeDevApiEnv.ts` 中的 `ACTIVE_DEV_API_ENV` */
export type DevApiEnvKey = 'test' | 'prod' | 'local-125' | 'local-6901' | 'local-108';
export interface ApiEnvConfig {
apiUrl: string;
baseUrl: string;
label: string;
}
/** 开发态可切换的 API 预设(与 `.env.development` 历史注释块对齐) */
export const DEV_API_ENVIRONMENTS: Record<DevApiEnvKey, ApiEnvConfig> = {
test: {
label: '测试 aus.test',
apiUrl: 'https://aus.test.glsx.com.cn/app/api/',
baseUrl: 'https://aus.test.glsx.com.cn/app/',
},
prod: {
label: '生产 aus',
apiUrl: 'https://aus.glsx.com.cn/app/api/',
baseUrl: 'https://aus.glsx.com.cn/app/',
},
'local-125': {
label: '内网 192.168.1.125',
apiUrl: 'http://192.168.1.125:6901/api/',
baseUrl: 'http://192.168.1.125:6901/',
},
'local-6901': {
label: '本机 localhost:6901',
apiUrl: 'http://localhost:6901/api/',
baseUrl: 'http://localhost:6901/',
},
'local-108': {
label: '内网 192.168.0.108',
apiUrl: 'http://192.168.0.108:5001/rest/api/',
baseUrl: 'http://192.168.0.108:5001/rest/',
},
};
export const DEV_API_ENV_KEYS = Object.keys(DEV_API_ENVIRONMENTS) as DevApiEnvKey[];
export function isDevApiEnvKey(key: string): key is DevApiEnvKey {
return (DEV_API_ENV_KEYS as string[]).includes(key);
}
import {ACTIVE_DEV_API_ENV} from '@/config/activeDevApiEnv';
import {DEV_API_ENVIRONMENTS, type DevApiEnvKey} from '@/config/devApiEnvironments';
export interface ResolvedApiConfig {
apiUrl: string;
baseUrl: string;
devEnvKey?: DevApiEnvKey;
}
function trimEnvUrl(value: unknown): string {
return String(value ?? '').trim().replace(/^['"]|['"]$/g, '');
}
export function getEnvDefaultApiConfig(): Pick<ResolvedApiConfig, 'apiUrl' | 'baseUrl'> {
return {
apiUrl: trimEnvUrl(import.meta.env.VITE_APP_API_URL),
baseUrl: trimEnvUrl(import.meta.env.VITE_APP_API_BASE_URL),
};
}
/**
* 生产:仅用 `.env.production`。
* 开发:使用 `activeDevApiEnv.ts` 中的 `ACTIVE_DEV_API_ENV`。
*/
export function resolveApiConfig(): ResolvedApiConfig {
const defaults = getEnvDefaultApiConfig();
if (!import.meta.env.DEV) {
return defaults;
}
const preset = DEV_API_ENVIRONMENTS[ACTIVE_DEV_API_ENV];
return {
apiUrl: preset.apiUrl,
baseUrl: preset.baseUrl,
devEnvKey: ACTIVE_DEV_API_ENV,
};
}
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_APP_API_URL?: string;
readonly VITE_APP_API_BASE_URL?: string;
readonly VITE_APP_COUPON_IMAGE_BASE_URL?: string;
/** 业务埋点 `POST`,默认相对 `VITE_APP_API_URL` 为 `eventTracking/batchSave` */
readonly VITE_APP_EVENT_TRACKING_PATH?: string;
......@@ -21,6 +23,7 @@ declare module "@vue/runtime-core" {
$filters: any;
$auth: AuthService;
$apiUrl: string;
$baseUrl: string;
$store: Store<any>;
$goBack: () => void;
axios: any;
......
......@@ -15,6 +15,7 @@ import {CustomTokenInterceptor} from "@/common/CustomTokenInterceptor";
import store from "@/store";
import mpAdapter from 'axios-miniprogram-adapter'
import {BurialPoint} from "@/common/BurialPoint";
import {resolveApiConfig} from "@/config/resolveApiConfig";
/// <reference types="@dcloudio/types" /> // 引入 uni 类型
......@@ -35,9 +36,10 @@ const systemI18n = {
dayjs.extend(duration);
export function createApp() {
let apiUrl = import.meta.env.VITE_APP_API_URL;
let baseUrl = import.meta.env.VITE_APP_API_BASE_URL;
console.log('baseUrl', apiUrl);
const {apiUrl, baseUrl, devEnvKey} = resolveApiConfig();
if (import.meta.env.DEV) {
console.log('[dev] API', devEnvKey ?? 'env-default', apiUrl);
}
const authService: AuthService = new AuthService();
// authService.deleteAuthentication();
......@@ -114,6 +116,7 @@ export function createApp() {
app.config.globalProperties.$store = store;
app.config.globalProperties.$auth = authService;
return {
app,
};
......
......@@ -36,7 +36,7 @@
"quickapp": {},
/* 小程序特有相关 */
"mp-weixin": {
// "appid": "wxa719209ed933d667",
// "appid": "wxa719209ed933d667",
"appid": "wx568d02f6352efd49",
"setting": {
"urlCheck": false,
......@@ -47,9 +47,7 @@
},
"usingComponents": true,
"lazyCodeLoading": "requiredComponents",
"requiredPrivateInfos": [
"getLocation"
],
"requiredPrivateInfos": ["getLocation"],
"permission": {
"scope.userLocation": {
"desc": "用于获取当前所在城市信息"
......
# AuctionVehiclePage 朋友圈分享问题排查与修复总结
> 维护说明:本文档与 [`AuctionVehiclePage.vue`](./AuctionVehiclePage.vue) 同目录,记录车辆详情页「分享到朋友圈」相关问题的现象、根因、排查思路与最终方案。修改分享逻辑或单页模式适配时请先阅读本文。
## 1. 背景与现象
| 场景 | 表现 |
|------|------|
| 分享给微信好友 | 正常打开详情页 |
| 分享到朋友圈(真机) | 曾出现白屏、标题显示 `uni-app`、内容区域空白 |
| 朋友圈打开后底部 | 固定显示「前往小程序」——**这是微信单页模式的正常 UI,不是 bug** |
Short Link 示例:`#小程序://优加车拍/车辆详情/xxxxx`
中间段为**页面标题**(取自 `pages.json` 的 `navigationBarTitleText`),不是页面路径。
---
## 2. 根因分层(按排查顺序)
### 2.1 分享参数名错误(第一层)
- **问题**:`onShareTimeline` 曾使用 `query: id=xxx`,而页面 `onLoad` 只读取 `aucvehId`。
- **结果**:车辆 ID 丢失,`auctionVehicle` 无法加载,内容区空白。
- **修复**:`query` 改为 `aucvehId=${id}`;`onLoad` 兼容 `option.aucvehId || option.id`。
### 2.2 页面配置缺失
- **问题**:未配置 `enableShareTimeline`;全局 `navigationBarTitleText` 默认为 `uni-app`。
- **结果**:朋友圈单页模式顶部标题显示 `uni-app`;分享能力未正确开启。
- **修复**:见 [`pages.json`](../../pages.json) 中 `AuctionVehiclePage` 配置块。
### 2.3 微信单页模式限制(scene 1154 / 1179)
从朋友圈打开时进入**单页模式**,特点:
- 无登录态(`wx.login` 等不可用)
- 禁止跳转其他小程序页面
- 顶部/底部固定栏由微信渲染,不可自定义
- 页面内容与小程序内为同一路径,但交互受限
因此单页模式下应:**只读展示完整详情**,竞拍/跳转等引导用户点击「前往小程序」。
### 2.4 单页模式未识别(真机白屏 + API 400)
- **问题**:仅在 `created()` 内注册 `onLoad` 时,朋友圈**冷启动**可能错过首次 `onLoad`,`isSinglePageMode` 保持 `false`。
- **证据**:真机 vConsole 出现 `GET bid/getLastedBidByLoginAccount → 400`(单页无登录态却调用了需登录接口)。
- **修复**:
- 类字段初始化阶段**同步**调用 `detectSinglePageMode()`、`parseAucvehIdFromEnterOptions()`
- 单页模式下跳过 `loadBidInfo`、收藏数、优惠券等需登录逻辑
### 2.5 `@Hook('onLoad') onPageLoad` 误用(首页回归)
- **问题**:`@Hook('onLoad') onPageLoad()` 被 vue-facing-decorator 注册为方法名 `onPageLoad`,uni-app 只识别 **`onLoad`**。
- **结果**:首页 `navigateTo` 进入详情时 `aucvehId` 未写入,提示「页面参数缺失」。
- **修复**:在 `created()` 内使用 `@dcloudio/uni-app` 的 `onLoad` / `onShow` / `onUnload` composable 注册(与 `@Hook('onShareTimeline')` 可并存,因分享钩子方法名与微信一致)。
### 2.6 uni-app 构建缺陷(shadow-grey.png)
- **问题**:编译后 `vendor.js` 中 `wx.preloadAssets` 预加载 `shadow-grey.png` 失败(500)。
- **修复**:[`vite.config.ts`](../../vite.config.ts) 中 `fixUniShadowGreyPreload` 插件在 `closeBundle` 时 patch。
### 2.7 已废弃方案
| 方案 | 说明 |
|------|------|
| 主包中转页 `AuctionVehicleSharePage` | 用户要求详情页右上角直接分享,已放弃 |
| 轻量预览 `VehicleTimelinePreview` | 内容过少,已改为单页模式展示完整详情只读 UI;**组件已删除,勿再引用** |
| `App.vue` 中 `wx.preloadSubpackage` | 曾导致首页空白,已移除,改用 `pages.json` 的 `preloadRule` |
---
## 3. 排查思路(建议真机 vConsole)
1. **Network**
- 接口域名是否正确(测试 `aus.test.glsx.com.cn` / 生产 `aus.glsx.com.cn`)
- 是否误调 `bid/getLastedBidByLoginAccount` → 单页模式未生效
2. **场景值**
- `uni.getEnterOptionsSync().scene === 1154` 或 `1179` → 单页模式
- `wx.getApiCategory() === 'browseOnly'` → 补充判断
3. **模拟 vs 真机**
- 开发者工具「模拟朋友圈」通常在已运行小程序内切换场景,**时序与真机冷启动不同**
- **以真机朋友圈打开为准**
4. **编译报错 `VehicleTimelinePreview.wxml`**
- 源文件已删但 `dist` 或开发者工具缓存残留
- 清理 `dist/dev/mp-weixin`、`dist/build/mp-weixin` 后重新 `npm run build:mp-weixin`,并清除微信开发者工具缓存
5. **标题仍显示 uni-app**
- 检查 `pages.json` 全局及页面级 `navigationBarTitleText`
- 确认已上传最新体验版
---
## 4. 最终方案架构
```
详情页右上角分享
→ onShareTimeline({ query: 'aucvehId=xxx' })
→ 朋友圈冷启动 scene=1154
→ 类字段同步 detectSinglePageMode + parseAucvehId
→ 渲染完整详情(只读)
→ onShow 调用 loadData()
→ 隐藏 customNav / 竞拍栏 / 弹窗
→ 用户点击「前往小程序」→ 完整小程序内交互
首页 navigateTo
→ created() 内 onLoad composable
→ isSinglePageMode=false
→ 完整详情 + 竞拍功能
```
---
## 5. 涉及文件
| 文件 | 作用 |
|------|------|
| [`AuctionVehiclePage.vue`](./AuctionVehiclePage.vue) | 单页检测、分享钩子、只读布局、生命周期 |
| [`pages.json`](../../pages.json) | `enableShareTimeline`、`navigationBarTitleText`、`navigationBarFit`、`preloadRule` |
| [`vite.config.ts`](../../vite.config.ts) | shadow-grey preload 补丁 |
| [`App.vue`](../../App.vue) | 无 `preloadSubpackage`(已移除) |
---
## 6. 验证清单
- [ ] 首页 → 点击车辆 → 详情正常,可竞拍
- [ ] 详情 → 分享朋友圈 → 真机打开:完整详情只读,非白屏
- [ ] 真机 vConsole 无 `getLastedBidByLoginAccount` 400
- [ ] 点击「前往小程序」→ 完整详情可交互
- [ ] 重新 build 后无 `VehicleTimelinePreview` 编译错误
---
## 7. 注意事项(勿踩坑)
1. **朋友圈分享**必须用 `onShareTimeline` + **`query`**,参数名 **`aucvehId`**;好友分享用 `onShareAppMessage` + **`path`**。
2. **单页模式**不可用 `@Hook('onLoad') onPageLoad`,须用 composable 或方法名 literally 为 `onLoad`。
3. **`isSinglePageMode` 必须在类字段初始化时同步检测**,不能仅依赖 `created()` 内的 `onLoad`。
4. **单页模式**禁止 `navigateTo`,应 toast 引导「请前往小程序使用完整服务」。
5. **API 环境**:开发改 `src/config/activeDevApiEnv.ts`;体验版/构建改 `.env.production` 后重新编译。
6. 修改分享或单页逻辑后,务必**真机朋友圈**验证,不要仅依赖开发者工具模拟。
---
## 8. 变更历史(摘要)
| 阶段 | 改动 |
|------|------|
| 1 | 修复 `onShareTimeline` query 参数名 |
| 2 | pages.json 分享配置 + 单页 loading 兜底 |
| 3 | 同步单页检测 + 登录 API 守卫 |
| 4 | 恢复 composable 生命周期,修复首页参数缺失 |
| 5 | 单页模式展示完整详情只读 UI |
| 6 | 删除 VehicleTimelinePreview,清理 dist 编译残留 |
<template>
<!-- <page-meta :page-style="'overflow:'+(show?'hidden':'visible')"></page-meta> -->
<customNav :status-bar-height="statusBarHeight"></customNav>
<view class="car-detail-container" v-if="auctionVehicle" :style="{ paddingTop: statusBarHeight + 43 + 'px' }">
<!-- 朋友圈单页模式:隐藏 customNav,顶栏由微信固定渲染,详见 AuctionVehiclePage.share-timeline.md -->
<customNav v-if="!isSinglePageMode" :status-bar-height="statusBarHeight"></customNav>
<view v-if="!auctionVehicle" class="page-loading-placeholder" :style="{ paddingTop: pageContentPaddingTop + 'px' }">
<view v-if="isLoading" class="loading-state">
<text>加载中...</text>
</view>
<view v-else-if="loadFailed" class="loading-state">
<text>加载失败,请点击底部「前往小程序」查看完整内容</text>
</view>
<view v-else-if="pageParamsReady && !aucvehId" class="loading-state">
<text>页面参数缺失,请从分享链接重新打开</text>
</view>
</view>
<view class="car-detail-container" v-if="auctionVehicle" :style="pageContainerStyle">
<view v-if="currentAnchorId && currentAnchorId != 'section0'" class="header-anchor"
:style="{ top: statusBarHeight + 41 + 'px' }">
:style="{ top: pageAnchorTop + 'px' }">
<view class="header-anchor-list" :class="{ headerActive: currentAnchorId === 'section1' }"
@click="scrollToSection('section1')">
车辆档案
......@@ -232,11 +243,15 @@
</view>
</view>
</section>
<view :style="{ height: auctionVehicle.auction.auctionMode == 2 ? '146px' : '60px' }"></view>
<view :style="{ height: pageBottomSpacerHeight + 'px' }"></view>
<view v-if="isSinglePageMode" class="single-page-hint">
<!-- 单页模式只读提示:竞拍/跳转需点击底部「前往小程序」 -->
<text class="single-page-hint-text">点击底部「前往小程序」参与竞拍或查看更多信息</text>
</view>
</view>
<!-- 底部操作栏 -->
<view class="bottom-action-bar" v-if="auctionVehicle.auction.auctionMode != 2">
<!-- 单页模式隐藏底部竞拍栏 -->
<view class="bottom-action-bar" v-if="!isSinglePageMode && auctionVehicle.auction.auctionMode != 2">
<template v-if="auctionVehicle.auctionState === 'AUCTIONING'">
<van-button type="primary" hairline round block @click="showBidPopup">参与竞拍</van-button>
</template>
......@@ -247,15 +262,15 @@
</view>
<!-- 轮询出价底部操作栏 -->
<view v-if="auctionVehicle.auction.auctionMode == 2">
<view v-if="!isSinglePageMode && auctionVehicle.auction.auctionMode == 2">
<roundBidBottom ref="roundBidBottomRef" :auctionVehicle="auctionVehicle" @nextAucVehData="nextAucVeh" />
</view>
<!-- 轮询出价确认弹窗 -->
<RoundBidPopup ref="roundBidPopupRef" />
<RoundBidPopup v-if="!isSinglePageMode" ref="roundBidPopupRef" />
<uni-popup class="popup-modal"
v-if="auctionVehicle && (auctionVehicle.auctionState === 'PREVIEW' || auctionVehicle.auctionState === 'AUCTIONING')"
<uni-popup v-if="!isSinglePageMode && auctionVehicle && (auctionVehicle.auctionState === 'PREVIEW' || auctionVehicle.auctionState === 'AUCTIONING')"
class="popup-modal"
ref="bidPopup" type="bottom" background-color="#fff" @change="change">
<view class="bid-container">
<view class="bid-title">{{ auctionVehicle.auction.auctionType === 'LIGHT' ? '明拍出价' : '暗拍出价' }}</view>
......@@ -373,13 +388,13 @@
</view>
</uni-popup>
<!-- <van-dialog id="van-dialog"/>-->
<van-dialog use-slot :show="showBidSuccessDialog" :show-cancel-button="false" :show-confirm-button="false">
<van-dialog v-if="!isSinglePageMode" use-slot :show="showBidSuccessDialog" :show-cancel-button="false" :show-confirm-button="false">
<bid-success-dialog :order-id="orderId" ref="bidSuccessDialogRef" :auctionVehicle="auctionVehicle"
@close="closeBidSuccessDialog"></bid-success-dialog>
</van-dialog>
</view>
<coupon-home-benefit-popup :show="showCouponBenefitPopup" :payload="couponBenefitPayload"
<coupon-home-benefit-popup v-if="!isSinglePageMode" :show="showCouponBenefitPopup" :payload="couponBenefitPayload"
@close="onCouponBenefitPopupClose" />
</template>
......@@ -415,6 +430,43 @@ import RoundBidPopup from "@/components/RoundBidPopup.vue";
import customNav from "@/module/auction/customNav.vue";
import InspectionReport from "@/module/auction/InspectionReport.vue";
/**
* 检测是否处于微信朋友圈/短链「单页模式」。
* 必须在类字段初始化阶段同步调用:冷启动时 composable onLoad 可能尚未执行,
* 若仅靠 onLoad 赋值 isSinglePageMode,会误走完整详情逻辑并调用需登录 API。
* @see AuctionVehiclePage.share-timeline.md
* @returns scene 为 1154/1179,或 wx.getApiCategory() 为 browseOnly 时返回 true
*/
function detectSinglePageMode(): boolean {
const enter = (uni.getEnterOptionsSync?.() ?? {}) as { scene?: number };
const launch = (uni.getLaunchOptionsSync?.() ?? {}) as { scene?: number };
const scene = enter.scene ?? launch.scene;
if (scene === 1154 || scene === 1179) {
return true;
}
// #ifdef MP-WEIXIN
if (typeof wx !== 'undefined' && (wx as any).getApiCategory?.() === 'browseOnly') {
return true;
}
// #endif
return false;
}
/**
* 从启动参数同步解析车辆 ID(供朋友圈冷启动首屏使用)。
* composable onLoad 触发前,enter.query 是 aucvehId 的唯一来源。
* @returns 解析到的 aucvehId,缺失时 undefined
*/
function parseAucvehIdFromEnterOptions(): number | undefined {
const enter = uni.getEnterOptionsSync?.() ?? {};
const query = (enter as { query?: Record<string, string> }).query ?? {};
const id = query.aucvehId ?? query.id;
if (id === undefined || id === null || id === '') {
return undefined;
}
return Number(id);
}
@Component({
components: { BidSuccessDialog, roundBidBottom, RoundBidPopup, customNav, InspectionReport, CouponHomeBenefitPopup }
})
......@@ -434,9 +486,20 @@ export default class AuctionVehiclePage extends Vue {
/** 由参拍记录 BidPage 进入时不展示优惠券弹窗 */
fromBidRecordEntry = false;
/** 朋友圈/短链单页模式;类字段阶段同步初始化,见 detectSinglePageMode() */
isSinglePageMode = detectSinglePageMode();
isLoading = false;
loadFailed = false;
currentImageIndex = 0;
aucvehId: number;
/** 车辆拍卖 ID;冷启动时由 parseAucvehIdFromEnterOptions 预填,onLoad 再次补全 */
aucvehId: number | undefined = parseAucvehIdFromEnterOptions();
/** onLoad 完成后为 true,避免正常导航时在 aucvehId 写入前误报「参数缺失」 */
pageParamsReady = false;
favoriteCount = 0;
......@@ -529,7 +592,13 @@ export default class AuctionVehiclePage extends Vue {
return true;
}
/**
* 拉取首页优惠券弹窗;单页模式或未登录时不请求。
*/
fetchCouponBenefitPopup(): void {
if (this.isSinglePageMode || !this.$auth.isLogin()) {
return;
}
if (this.fromBidRecordEntry) {
return;
}
......@@ -639,21 +708,38 @@ export default class AuctionVehiclePage extends Vue {
return true;
}
/**
* 页面生命周期注册。
* 必须使用 @dcloudio/uni-app 的 onLoad/onShow composable,不可用 @Hook('onLoad') onPageLoad:
* vue-facing-decorator 会把方法注册为 onPageLoad,uni-app 无法识别,导致 navigateTo 参数丢失。
* 单页模式:onLoad 只解析参数;onShow 仍 loadData 展示完整详情只读 UI。
* @see AuctionVehiclePage.share-timeline.md
*/
created(): void {
const that = this;
onLoad((option) => {
this.aucvehId = option.aucvehId;
this.fromBidRecordEntry = option.fromBidRecord === '1' || option.fromBidRecord === 'true';
this.statusBarHeight = uni.getWindowInfo().statusBarHeight;
this.loadBidPriceRange();
FavoriteController.getFavoriteCountByAucvehId(this.axios, this.aucvehId).then(res => {
this.favoriteCount = res.data;
});
this.fetchCouponBenefitPopup();
this.isSinglePageMode = detectSinglePageMode();
const optionId = option.aucvehId || option.id;
if (optionId) {
this.aucvehId = Number(optionId);
}
this.pageParamsReady = true;
if (!this.isSinglePageMode) {
this.fromBidRecordEntry = option.fromBidRecord === '1' || option.fromBidRecord === 'true';
this.statusBarHeight = uni.getWindowInfo().statusBarHeight;
this.loadBidPriceRange();
if (this.aucvehId) {
FavoriteController.getFavoriteCountByAucvehId(this.axios, this.aucvehId).then(res => {
this.favoriteCount = res.data;
});
this.fetchCouponBenefitPopup();
}
}
});
onShow((option) => {
onShow(() => {
this.loadData();
this.loadBidInfo();
if (!this.isSinglePageMode) {
this.loadBidInfo();
}
this.updateAnchorPositions();
});
onUnload(() => {
......@@ -661,6 +747,35 @@ export default class AuctionVehiclePage extends Vue {
});
}
/** 内容区顶部 padding:单页模式为 0(微信顶栏),正常模式含 customNav 高度 */
get pageContentPaddingTop(): number {
return this.isSinglePageMode ? 0 : this.statusBarHeight + 43;
}
/** 锚点栏 sticky top:单页模式贴顶,正常模式在 customNav 下方 */
get pageAnchorTop(): number {
return this.isSinglePageMode ? 0 : this.statusBarHeight + 41;
}
/** 详情容器样式;单页模式增加 paddingBottom 避免被「前往小程序」底栏遮挡 */
get pageContainerStyle(): Record<string, string> {
const style: Record<string, string> = {
paddingTop: this.pageContentPaddingTop + 'px',
};
if (this.isSinglePageMode) {
style.paddingBottom = '80px';
}
return style;
}
/** 底部占位高度:单页模式无竞拍栏,正常模式为 bottom-action-bar / roundBidBottom 预留空间 */
get pageBottomSpacerHeight(): number {
if (this.isSinglePageMode) {
return 24;
}
return this.auctionVehicle?.auction?.auctionMode === 2 ? 146 : 60;
}
get hasBidPrivilege(): boolean {
const authService: AuthService = this.$auth as AuthService;
if (authService.isLogin() && authService.getAuthentication().accountType !== 'COMMON') {
......@@ -680,7 +795,13 @@ export default class AuctionVehiclePage extends Vue {
/**
* 加载加价幅度配置
*/
/**
* 加载加价幅度配置;单页模式只读浏览,无需出价配置。
*/
loadBidPriceRange(): void {
if (this.isSinglePageMode) {
return;
}
ConfigController.getLightBidPriceRange(this.axios).then(res => {
this.lightBidPriceRange = res.data;
});
......@@ -695,7 +816,9 @@ export default class AuctionVehiclePage extends Vue {
@Hook('onPullDownRefresh')
async onPullDownRefresh() {
this.loadData().finally(() => uni.stopPullDownRefresh());
this.loadBidInfo();
if (!this.isSinglePageMode) {
this.loadBidInfo();
}
this.updateAnchorPositions();
}
......@@ -719,10 +842,19 @@ export default class AuctionVehiclePage extends Vue {
}
loadData(): Promise<void> {
if (!this.aucvehId) {
this.isLoading = false;
this.loadFailed = false;
return Promise.resolve();
}
this.isLoading = true;
this.loadFailed = false;
return AuctionController.getAuctionVehicleDetailById(this.axios, this.aucvehId).then(res => {
this.auctionVehicle = res.data;
this.formData.bidAmount = this.minBidPrice;
this.noticeBidEnd();
if (!this.isSinglePageMode) {
this.noticeBidEnd();
}
this.bidStartRemaining = this.auctionVehicle.bidStartRemaining;
this.bidEndRemaining = this.auctionVehicle.bidEndRemaining;
if (this.albums.length === 0 && this.vehicle.albums && this.vehicle.albums.length > 0) {
......@@ -745,6 +877,10 @@ export default class AuctionVehiclePage extends Vue {
}, 300);
});
return Promise.resolve();
}).catch(() => {
this.loadFailed = true;
}).finally(() => {
this.isLoading = false;
});
}
......@@ -789,7 +925,13 @@ export default class AuctionVehiclePage extends Vue {
}
/**
* 加载当前用户对该车的最新出价;单页模式无登录态,或未登录时跳过。
*/
loadBidInfo(): void {
if (this.isSinglePageMode || !this.$auth.isLogin()) {
return;
}
BidController.getLastedBidByLoginAccount(this.axios, this.aucvehId).then(res => {
this.bid = res.data;
});
......@@ -1020,11 +1162,27 @@ export default class AuctionVehiclePage extends Vue {
});
}
/**
* 页面内跳转;单页模式禁止 navigateTo,toast 引导用户点击「前往小程序」。
* @param url 目标小程序页面路径
*/
navigateTo(url: string): void {
if (this.isSinglePageMode) {
uni.showToast({ title: '请前往小程序使用完整服务', icon: 'none' });
return;
}
uni.navigateTo({ url: url });
}
/**
* 跳转协议页;单页模式下同 navigateTo,仅 toast 提示。
* @param value 协议 key,'commission' 为佣金规则
*/
navigateToAgreement(value: string) {
if (this.isSinglePageMode) {
uni.showToast({ title: '请前往小程序使用完整服务', icon: 'none' });
return;
}
// 手动阻止事件冒泡
// event.stopPropagation();
if (value === 'commission') {
......@@ -1038,7 +1196,10 @@ export default class AuctionVehiclePage extends Vue {
this.$refs.roundBidPopupRef.initData(data);
}
// 定义分享内容(必写)
/**
* 分享给微信好友:使用 path 携带完整路径与 query。
* 参数名必须为 aucvehId,与 onLoad 读取字段一致。
*/
@Hook('onShareAppMessage')
onShareAppMessage(res: any) {
// res.from 可判断分享触发来源:'button'(按钮触发)、'menu'(右上角菜单)
......@@ -1051,12 +1212,17 @@ export default class AuctionVehiclePage extends Vue {
};
}
/**
* 分享到朋友圈:仅支持 query(非 path),追加到当前页路径。
* query 参数名必须为 aucvehId;打开后进入单页模式 scene=1154。
* @see AuctionVehiclePage.share-timeline.md
*/
@Hook('onShareTimeline')
onShareTimeline() {
const title = `【${this.vehicle.ownership.carCityName}】 ${this.vehicle.baseInfo.carSeriesName} ${this.vehicle.baseInfo.carTypeName}`;
return {
title: title,
query: `id=${this.auctionVehicle.aucvehId}`, // 分享参数
query: `aucvehId=${this.auctionVehicle.aucvehId}`,
imageUrl: this.vehicle.cover?.url
};
}
......@@ -1721,6 +1887,36 @@ export default class AuctionVehiclePage extends Vue {
gap: 4px;
}
.page-loading-placeholder {
min-height: 60vh;
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
}
.single-page-hint {
padding: 16px 24px 8px;
text-align: center;
}
.single-page-hint-text {
font-size: 13px;
color: #999999;
line-height: 1.6;
}
.loading-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 14px;
color: #999999;
text-align: center;
line-height: 1.6;
}
.currency {
margin-top: 4px;
font-size: 20px;
......
......@@ -57,8 +57,7 @@
<view class="recharge-footer">
<view class="warning-text" v-if="order.orderState==='CONTRACT_UNSIGNED'">
<template v-if="getRemainingBreachContract(order)>0">
<van-count-down class="red-count-down" :time="getRemainingBreachContract(order)" format="HH:mm:ss"/>
后将违约
<van-count-down class="red-count-down" :time="getRemainingBreachContract(order)" format="HH:mm:ss 后将违约"/>
</template>
<template v-else>
请尽快签署合同并付款
......@@ -67,8 +66,7 @@
<view class="warning-text" v-if="order.orderState==='UNPAID'">
<template v-if="getRemainingBreachContract(order)>0">
<template v-if="order.auditState!=='UNAUDITED'">
<van-count-down class="red-count-down" :time="getRemainingBreachContract(order)" format="HH:mm:ss"/>
后将违约
<van-count-down class="red-count-down" :time="getRemainingBreachContract(order)" format="HH:mm:ss 后将违约"/>
</template>
<template v-else>
支付审核中
......@@ -421,8 +419,21 @@ export default class AuctionOrderPage extends PaginationComponent<AuctionOrder>
.warning-text {
display: flex;
align-items: center;
flex: 1;
min-width: 0;
font-size: 26rpx;
color: #EE3040FF;
:deep(.red-count-down) {
display: inline-flex;
align-items: center;
}
:deep(.red-count-down .van-count-down) {
font-size: 26rpx;
line-height: 1.4;
}
}
.exception-text {
......
......@@ -20,9 +20,17 @@
<view v-for="item in displayList" :key="item.couponId" class="coupon-card"
:class="cardModifierClass(item.status)">
<view class="coupon-card__main">
<view class="coupon-card__amount">
<view class="coupon-card__amount" :class="couponFaceDenseClass(item.faceAmount)">
<text class="coupon-card__currency">¥</text>
<text class="coupon-card__amount-num">{{ formatFaceAmount(item.faceAmount) }}</text>
<template v-if="couponFacePresent(item.faceAmount).mode === 'wan'">
<text class="coupon-card__wan-num">{{ couponFacePresent(item.faceAmount).wanMain
}}</text>
<text class="coupon-card__wan-unit">万</text>
</template>
<template v-else>
<text class="coupon-card__amount-num">{{ couponFacePresent(item.faceAmount).text
}}</text>
</template>
</view>
<view class="coupon-card__body">
<view class="coupon-card__body-stack">
......@@ -112,6 +120,11 @@ import {
import type { AxiosStatic } from "axios";
import { trackCouponRuleClick } from "@/common/eventTracking";
import { couponImageUrl } from "@/common/couponImageUrl";
import {
couponFaceAmountDenseClass,
getCouponFacePresent,
type CouponFacePresent,
} from "@/common/couponFaceAmount";
type CouponTabKey = "unused" | "verified" | "expired";
......@@ -305,10 +318,12 @@ export default class CouponPage extends Vue {
return "抵扣车款";
}
formatFaceAmount(amount: number): string {
const f = this.$filters?.formatCouponMoney;
if (typeof f === "function") return f(amount);
return String(amount);
couponFacePresent(amount: number): CouponFacePresent {
return getCouponFacePresent(amount);
}
couponFaceDenseClass(amount: number): string {
return couponFaceAmountDenseClass(amount);
}
isInstructionExpanded(couponId: string): boolean {
......@@ -441,7 +456,6 @@ export default class CouponPage extends Vue {
}
.coupon-card__main {
--coupon-amount-size: 64px;
display: flex;
flex-direction: row;
align-items: stretch;
......@@ -450,16 +464,19 @@ export default class CouponPage extends Vue {
}
.coupon-card__amount {
width: var(--coupon-amount-size);
height: var(--coupon-amount-size);
min-height: var(--coupon-amount-size);
width: 100%;
max-width: 72px;
max-height: 72px;
aspect-ratio: 1;
border-radius: 6px;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
flex-shrink: 0;
box-sizing: border-box;
min-width: 0;
}
.coupon-card--unused .coupon-card__amount {
......@@ -479,14 +496,20 @@ export default class CouponPage extends Vue {
}
.coupon-card--unused .coupon-card__currency,
.coupon-card--unused .coupon-card__amount-num {
.coupon-card--unused .coupon-card__amount-num,
.coupon-card--unused .coupon-card__wan-num,
.coupon-card--unused .coupon-card__wan-unit {
color: #ff6b35;
}
.coupon-card--verified .coupon-card__currency,
.coupon-card--verified .coupon-card__amount-num,
.coupon-card--expired .coupon-card__currency,
.coupon-card--expired .coupon-card__amount-num {
.coupon-card--expired .coupon-card__amount-num,
.coupon-card--verified .coupon-card__wan-num,
.coupon-card--verified .coupon-card__wan-unit,
.coupon-card--expired .coupon-card__wan-num,
.coupon-card--expired .coupon-card__wan-unit {
color: #646566;
}
......@@ -497,10 +520,51 @@ export default class CouponPage extends Vue {
line-height: 1;
}
.coupon-card__wan-num {
font-family: "numberNor", sans-serif;
font-size: 22px;
font-weight: 700;
line-height: 1;
}
.coupon-card__wan-unit {
font-family: "numberNor", sans-serif;
font-size: 16px;
font-weight: 700;
line-height: 1;
margin-left: 1px;
}
.coupon-card__amount.coupon-face--sm .coupon-card__currency {
font-size: 12px;
}
.coupon-card__amount.coupon-face--sm .coupon-card__amount-num,
.coupon-card__amount.coupon-face--sm .coupon-card__wan-num {
font-size: 18px;
}
.coupon-card__amount.coupon-face--sm .coupon-card__wan-unit {
font-size: 14px;
}
.coupon-card__amount.coupon-face--xs .coupon-card__currency {
font-size: 11px;
}
.coupon-card__amount.coupon-face--xs .coupon-card__amount-num,
.coupon-card__amount.coupon-face--xs .coupon-card__wan-num {
font-size: 14px;
}
.coupon-card__amount.coupon-face--xs .coupon-card__wan-unit {
font-size: 12px;
}
.coupon-card__body {
flex: 1;
min-width: 0;
max-height: 64px;
max-height: 72px;
min-height: 0;
display: flex;
flex-direction: column;
......
......@@ -56,8 +56,8 @@
<text v-if="couponVerifyLoading"
class="coupon-row-value coupon-row-value--muted">处理中…</text>
<template v-else>
<text class="coupon-row-value" :class="couponRowValueClass">{{ couponRowRightText
}}</text>
<text class="coupon-row-value" :class="couponRowValueClass">¥ {{ couponRowRightText
}}</text>
<text v-if="couponRowShowUseBtn" class="coupon-row-use-btn"
@click.stop="onOpenCouponVerifyDialog">立即使用</text>
</template>
......@@ -110,13 +110,21 @@
:class="{ 'contract-coupon-card--selected': isCouponCardSelected(item) }"
@click="chooseCoupon(item)">
<view class="contract-coupon-card__left">
<view class="contract-coupon-card__amount-row">
<view class="contract-coupon-card__amount-row"
:class="couponFaceDenseClass(item.faceAmount)">
<text class="contract-coupon-card__currency">¥</text>
<text class="contract-coupon-card__face">{{ formatCouponAmount(item.faceAmount)
<template v-if="couponFacePresent(item.faceAmount).mode === 'wan'">
<text class="contract-coupon-card__wan-num">{{
couponFacePresent(item.faceAmount).wanMain
}}</text>
<text class="contract-coupon-card__wan-unit">万</text>
</template>
<text v-else class="contract-coupon-card__face">{{
couponFacePresent(item.faceAmount).text
}}</text>
</view>
<text class="contract-coupon-card__cap">最高抵扣¥{{
formatCouponAmount(item.actualDeduction) }}</text>
<text class="contract-coupon-card__cap">最高抵扣{{
formatCouponDeductionCaption(item.actualDeduction) }}</text>
</view>
<view class="contract-coupon-card__mid">
<view class="contract-coupon-card__title-row">
......@@ -127,7 +135,7 @@
:class="item.deductionType === 2 ? 'contract-coupon-card__tag--commission' : 'contract-coupon-card__tag--car'">
{{ deductionTypeLabel(item.deductionType) }}</view>
<text class="contract-coupon-card__period">有效期至{{ formatValidEnd(item.validEndTime)
}}</text>
}}</text>
</view>
<view class="contract-coupon-card__radio">
<view class="coupon-radio coupon-radio--lg"
......@@ -147,13 +155,21 @@
<view v-for="u in unavailableCoupons" :key="u.couponId"
class="contract-coupon-card contract-coupon-card--disabled">
<view class="contract-coupon-card__left contract-coupon-card__left--muted">
<view class="contract-coupon-card__amount-row">
<view class="contract-coupon-card__amount-row"
:class="couponFaceDenseClass(u.faceAmount)">
<text class="contract-coupon-card__currency">¥</text>
<text class="contract-coupon-card__face">{{ formatCouponAmount(u.faceAmount)
<template v-if="couponFacePresent(u.faceAmount).mode === 'wan'">
<text class="contract-coupon-card__wan-num">{{
couponFacePresent(u.faceAmount).wanMain
}}</text>
<text class="contract-coupon-card__wan-unit">万</text>
</template>
<text v-else class="contract-coupon-card__face">{{
couponFacePresent(u.faceAmount).text
}}</text>
</view>
<text class="contract-coupon-card__cap">最高抵扣¥{{
formatCouponAmount(u.actualDeduction) }}</text>
<text class="contract-coupon-card__cap">最高抵扣{{
formatCouponDeductionCaption(u.actualDeduction) }}</text>
</view>
<view class="contract-coupon-card__mid">
<text class="contract-coupon-card__name contract-coupon-card__name--muted">{{
......@@ -162,11 +178,11 @@
:class="u.deductionType === 2 ? 'contract-coupon-card__tag--commission' : 'contract-coupon-card__tag--car'">
{{ deductionTypeLabel(u.deductionType) }}</view>
<text class="contract-coupon-card__period">有效期至{{ formatValidEnd(u.validEndTime)
}}</text>
}}</text>
</view>
<view class="contract-coupon-card__stamp">
<text class="contract-coupon-card__stamp-txt">{{ u.unavailableReason || '不可用'
}}</text>
}}</text>
</view>
</view>
</view>
......@@ -192,7 +208,7 @@
@click="onCouponVerifyConfirm">
<text class="coupon-verify-dialog__btn-txt coupon-verify-dialog__btn-txt--inv">{{
couponVerifyLoading ? "核销中…" : "确认核销"
}}</text>
}}</text>
</view>
</view>
</uni-popup>
......@@ -226,6 +242,14 @@ import {
import dayjs from "dayjs";
import { couponImageUrl } from "@/common/couponImageUrl";
import {
couponFaceAmountDenseClass,
formatCouponCaptionWithMoneySymbol,
formatCouponDeductionMinus,
formatCouponMoneyCompact,
getCouponFacePresent,
type CouponFacePresent,
} from "@/common/couponFaceAmount";
import {
trackOrderCouponChangeClick,
trackOrderPaySubmitClick,
} from "@/common/eventTracking";
......@@ -337,6 +361,30 @@ export default class ContractPage extends Vue {
});
}
/** 核销成功后拉取订单详情,同步订单状态等字段。 */
reloadOrderDetail(): Promise<boolean> {
return AuctionOrderController.getAuctionOrderDetailById(
this.axios,
this.orderId
)
.then((res) => {
this.order = res.data;
return true;
})
.catch(() => {
uni.showToast({ title: "订单加载失败", icon: "none" });
return false;
});
}
/** 核销成功后并行刷新订单详情与优惠券列表;成功判定以券列表为准。 */
reloadAfterCouponVerify(): Promise<boolean> {
return Promise.all([
this.reloadOrderDetail().catch(() => false),
this.reloadOrderCoupons(),
]).then(([, couponOk]) => couponOk);
}
/**
* 本单券已核销/占用时锁定入口;否则按「最大 actualDeduction → 最近过期 → 最早领取」选默认券。
*/
......@@ -426,7 +474,9 @@ export default class ContractPage extends Vue {
get couponRowRightText(): string {
if (this.isCouponRowLocked && this.lockedUsedInfo) {
return `-¥${this.formatCouponAmount(this.lockedUsedInfo.actualDeduction)}`;
return formatCouponDeductionMinus(
this.lockedUsedInfo.actualDeduction
);
}
if (!this.hasSelectableCoupon) {
return "暂无优惠券";
......@@ -436,7 +486,7 @@ export default class ContractPage extends Vue {
}
const item = this.findCouponById(this.selectedCouponId);
if (item) {
return `-¥${this.formatCouponAmount(item.actualDeduction)}`;
return formatCouponDeductionMinus(item.actualDeduction);
}
return "未选择";
}
......@@ -530,10 +580,20 @@ export default class ContractPage extends Vue {
}
formatCouponAmount(n: number): string {
const f = (this as unknown as { $filters?: { formatCouponMoney?: (v: number) => string } }).$filters
?.formatCouponMoney;
if (typeof f === "function") return f(n);
return String(n);
return formatCouponMoneyCompact(n);
}
/** 「最高抵扣…」中与卡面一致的金额写法:过万带 ¥+万;未满万只数字不带「元」 */
formatCouponDeductionCaption(amount: number): string {
return formatCouponCaptionWithMoneySymbol(amount);
}
couponFacePresent(amount: number): CouponFacePresent {
return getCouponFacePresent(amount);
}
couponFaceDenseClass(amount: number): string {
return couponFaceAmountDenseClass(amount);
}
formatValidEnd(iso: string): string {
......@@ -650,7 +710,7 @@ export default class ContractPage extends Vue {
row.actualDeduction = parsed.data.actualDeduction;
}
}
return this.reloadOrderCoupons();
return this.reloadAfterCouponVerify();
})
.then((reloadOk: boolean | null | undefined) => {
if (reloadOk === null) {
......@@ -718,12 +778,12 @@ export default class ContractPage extends Vue {
if (face > ad) {
uni.showToast({
icon: "none",
title: `本单仅可使用${ad}元,超出部分将失效`,
title: `本单仅可使用${formatCouponMoneyCompact(ad)},超出部分将失效`,
});
} else {
uni.showToast({
icon: "none",
title: `可抵扣${ad}元`,
title: `可抵扣${formatCouponMoneyCompact(ad)}`,
});
}
}
......@@ -800,7 +860,7 @@ export default class ContractPage extends Vue {
title: parsed.message || "核销失败",
icon: "none",
});
return;
return Promise.resolve(false);
}
if (
parsed.data?.actualDeduction != null &&
......@@ -811,7 +871,12 @@ export default class ContractPage extends Vue {
row.actualDeduction = parsed.data.actualDeduction;
}
}
this.navigateTo(url);
return this.reloadAfterCouponVerify();
})
.then((reloadOk: boolean | undefined) => {
if (reloadOk === true) {
this.navigateTo(url);
}
})
.catch(() => {
uni.showToast({ title: "核销失败", icon: "none" });
......@@ -1131,7 +1196,7 @@ export default class ContractPage extends Vue {
right: 0;
bottom: 16px;
padding: 24rpx;
background-color: #ffffff;
// background-color: #ffffff;
}
/* —— 选券弹层:顶部圆角由 uni-popup border-radius 属性注入,此处仅保证白底裁切 —— */
......@@ -1299,6 +1364,37 @@ export default class ContractPage extends Vue {
flex-direction: row;
align-items: baseline;
flex-wrap: nowrap;
justify-content: center;
max-width: 72px;
margin-left: auto;
margin-right: auto;
min-width: 0;
}
.contract-coupon-card__amount-row.coupon-face--sm .contract-coupon-card__currency {
font-size: 13px !important;
}
.contract-coupon-card__amount-row.coupon-face--sm .contract-coupon-card__face,
.contract-coupon-card__amount-row.coupon-face--sm .contract-coupon-card__wan-num {
font-size: 18px !important;
}
.contract-coupon-card__amount-row.coupon-face--sm .contract-coupon-card__wan-unit {
font-size: 14px !important;
}
.contract-coupon-card__amount-row.coupon-face--xs .contract-coupon-card__currency {
font-size: 11px !important;
}
.contract-coupon-card__amount-row.coupon-face--xs .contract-coupon-card__face,
.contract-coupon-card__amount-row.coupon-face--xs .contract-coupon-card__wan-num {
font-size: 14px !important;
}
.contract-coupon-card__amount-row.coupon-face--xs .contract-coupon-card__wan-unit {
font-size: 12px !important;
}
.contract-coupon-card__left--muted {
......@@ -1307,9 +1403,10 @@ export default class ContractPage extends Vue {
.contract-coupon-card__currency {
font-family: "numberNor", sans-serif;
font-size: 22px;
font-size: 14px;
font-weight: 600;
color: #ff6010;
font-weight: 700;
margin-right: 2px;
}
.contract-coupon-card__face {
......@@ -1320,8 +1417,27 @@ export default class ContractPage extends Vue {
line-height: 1.2;
}
.contract-coupon-card__wan-num {
font-family: "numberNor", sans-serif;
font-size: 22px;
font-weight: 700;
color: #ff6010;
line-height: 1.2;
}
.contract-coupon-card__wan-unit {
font-family: "numberNor", sans-serif;
font-size: 16px;
font-weight: 700;
color: #ff6010;
line-height: 1.15;
margin-left: 1px;
}
.contract-coupon-card__left--muted .contract-coupon-card__currency,
.contract-coupon-card__left--muted .contract-coupon-card__face,
.contract-coupon-card__left--muted .contract-coupon-card__wan-num,
.contract-coupon-card__left--muted .contract-coupon-card__wan-unit,
.contract-coupon-card__left--muted .contract-coupon-card__cap {
color: #969799;
}
......
......@@ -60,6 +60,7 @@
"subPackages": [
{
"root": "module/auction",
"name": "auction",
"pages": [
{
"path": "AuctionSessionPage",
......@@ -70,9 +71,14 @@
}
},
{
// 车辆详情:enableShareTimeline 开启朋友圈分享;navigationBarFit=float 适配单页模式顶栏
"path": "AuctionVehiclePage",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "车辆详情",
"navigationBarFit": "float",
"enableShareAppMessage": true,
"enableShareTimeline": true,
"disableScroll": false,
"enablePullDownRefresh": false
}
......@@ -496,6 +502,16 @@
}
]
},
"preloadRule": {
"pages/tabbar/HomePage": {
"network": "all",
"packages": ["auction"]
},
"pages/tabbar/AuctionPage": {
"network": "all",
"packages": ["auction"]
}
},
"easycom": {
"autoscan": true,
"custom": {
......@@ -508,7 +524,7 @@
},
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarTitleText": "优加车拍",
"navigationBarBackgroundColor": "#F8F9FB",
"backgroundColor": "#ffffff",
"usingComponents": {
......
<template>
<!-- 单根节点:避免 mp 差量编译在多根 fragment 下偶发解析为空 SFC -->
<view class="home-page-root">
<view class="page-container">
<view class="bg-image" :style="{ backgroundImage: `url(${backgroundImageUrl})` }"></view>
<custom-nav-bar title="专电优拍" :status-bar-height="statusBarHeight"></custom-nav-bar>
<!-- 顶部导航 -->
<view class="header" :style="{ top: statusBarHeight + 44 + 'px' }">
<view class="location-search-container">
<!-- 位置选择 -->
<view class="location-selector" @click="openChangeCity()">
<uni-icons type="location" size="16" color="#333" />
<text class="location-text">{{ getCityName }}</text>
</view>
<!-- 搜索框 -->
<view class="search-bar" @click="onSearch">
<view class="search-bar-container">
<view class="search-input-wrapper">
<uni-icons type="search" size="16" color="#999" class="search-icon" />
<input class="search-input" type="text" :placeholder="businessConfig?.searchSuggestion"
@focus="true" @input="onSearch" />
<!-- <view class="clear-button">-->
<!-- <uni-icons type="clear" size="16" color="#999"/>-->
<!-- </view>-->
<view class="page-container">
<view class="bg-image" :style="{ backgroundImage: `url(${backgroundImageUrl})` }"></view>
<custom-nav-bar title="专电优拍" :status-bar-height="statusBarHeight"></custom-nav-bar>
<!-- 顶部导航 -->
<view class="header" :style="{ top: statusBarHeight + 44 + 'px' }">
<view class="location-search-container">
<!-- 位置选择 -->
<view class="location-selector" @click="openChangeCity()">
<uni-icons type="location" size="16" color="#333" />
<text class="location-text">{{ getCityName }}</text>
</view>
<!-- 搜索框 -->
<view class="search-bar" @click="onSearch">
<view class="search-bar-container">
<view class="search-input-wrapper">
<uni-icons type="search" size="16" color="#999" class="search-icon" />
<input class="search-input" type="text" :placeholder="businessConfig?.searchSuggestion"
@focus="true" @input="onSearch" />
<!-- <view class="clear-button">-->
<!-- <uni-icons type="clear" size="16" color="#999"/>-->
<!-- </view>-->
</view>
</view>
</view>
<!-- 消息图标 -->
<view class="message-icon">
<button open-type="contact" bindcontact="handleContact" session-from="sessionFrom"
class="custom-contact-btn">
<uni-icons open-type="contact" bindcontact="handleContact" session-from="sessionFrom"
type="chat" size="20" color="#333" />
</button>
</view>
</view>
<!-- 消息图标 -->
<view class="message-icon">
<button open-type="contact" bindcontact="handleContact" session-from="sessionFrom"
class="custom-contact-btn">
<uni-icons open-type="contact" bindcontact="handleContact" session-from="sessionFrom"
type="chat" size="20" color="#333" />
</button>
</view>
</view>
</view>
<!-- 滚动内容(随页面滚动) -->
<scroll-view class="scroll-content" scroll-y
:style="{ paddingTop: statusBarHeight + 80 + 'px', height: `calc(100vh - 6px)` }">
<!-- 轮播图 -->
<view class="banner" v-if="carouselPhotos && carouselPhotos.length > 0">
<uni-swiper-dot :info="carouselPhotos.length" :current="currentIndex" @clickItem="onClickDot">
<swiper :current="currentIndex" @change="onSwiperChange" class="swiper" autoplay :circular="true"
interval="3000">
<template v-for="carousel in carousels" :key="carousel.carouselId">
<swiper-item v-for="(item, index) in carousel.photos" :key="index">
<image :src="item.url" class="banner-image" mode="aspectFill"
@click="carouselLink(carousel)"></image>
</swiper-item>
</template>
</swiper>
</uni-swiper-dot>
</view>
<!-- 拍卖场广告位 -->
<view class="auction-section">
<view class="auction-item" @click="goToAuction('light')">
<image src="https://img02.glsx.com.cn/aus/images/banner1.png"></image>
<!-- <text class="auction-title">明拍场</text>-->
<!-- <text class="auction-desc">海量车源</text>-->
</view>
<view class="auction-item" @click="goToAuction('dark')">
<image src="https://img02.glsx.com.cn/aus/images/banner2.png"></image>
<!-- <text class="auction-title">暗拍场</text>-->
<!-- <text class="auction-desc">限时优惠</text>-->
<!-- 滚动内容(随页面滚动) -->
<scroll-view class="scroll-content" scroll-y
:style="{ paddingTop: statusBarHeight + 80 + 'px', height: `calc(100vh - 6px)` }">
<!-- 轮播图 -->
<view class="banner" v-if="carouselPhotos && carouselPhotos.length > 0">
<uni-swiper-dot :info="carouselPhotos.length" :current="currentIndex" @clickItem="onClickDot">
<swiper :current="currentIndex" @change="onSwiperChange" class="swiper" autoplay
:circular="true" interval="3000">
<template v-for="carousel in carousels" :key="carousel.carouselId">
<swiper-item v-for="(item, index) in carousel.photos" :key="index">
<image :src="item.url" class="banner-image" mode="aspectFill"
@click="carouselLink(carousel)"></image>
</swiper-item>
</template>
</swiper>
</uni-swiper-dot>
</view>
</view>
<!-- 筛选标签 -->
<view class="filter-tags">
<view class="tag-row">
<view class="filter-tag" v-for="tag in carTypeTags" :key="tag.id" @click="selectCarType(tag)">{{
tag.name }}
<!-- 拍卖场广告位 -->
<view class="auction-section">
<view class="auction-item" @click="goToAuction('light')">
<image src="https://img02.glsx.com.cn/aus/images/banner1.png"></image>
<!-- <text class="auction-title">明拍场</text>-->
<!-- <text class="auction-desc">海量车源</text>-->
</view>
<view class="auction-item" @click="goToAuction('dark')">
<image src="https://img02.glsx.com.cn/aus/images/banner2.png"></image>
<!-- <text class="auction-title">暗拍场</text>-->
<!-- <text class="auction-desc">限时优惠</text>-->
</view>
</view>
<view class="tag-row">
<view class="filter-tag" v-for="tag in priceRangeTags" :key="tag.name"
@click="selectPriceRange(tag)">
{{ tag.name }}
<!-- 筛选标签 -->
<view class="filter-tags">
<view class="tag-row">
<view class="filter-tag" v-for="tag in carTypeTags" :key="tag.id" @click="selectCarType(tag)">{{
tag.name }}
</view>
</view>
<view class="tag-row">
<view class="filter-tag" v-for="tag in priceRangeTags" :key="tag.name"
@click="selectPriceRange(tag)">
{{ tag.name }}
</view>
<view class="filter-tag" @click="showMoreFilters">{{ '更多条件' }}</view>
</view>
<view class="filter-tag" @click="showMoreFilters">{{ '更多条件' }}</view>
</view>
</view>
<!-- 推荐车源 -->
<view class="car-recommendation">
<view class="tab-nav">
<view class="tab-item" :class="{ active: tabType === 'recommend' }" @click="tabType = 'recommend'">
本地精选
<!-- 推荐车源 -->
<view class="car-recommendation">
<view class="tab-nav">
<view class="tab-item" :class="{ active: tabType === 'recommend' }"
@click="tabType = 'recommend'">
本地精选
</view>
<view class="tab-item" :class="{ active: tabType === 'like' }" @click="tabType = 'like'">猜你喜欢
</view>
</view>
<view class="tab-item" :class="{ active: tabType === 'like' }" @click="tabType = 'like'">猜你喜欢</view>
<recommend-auction-vehicles :style="showRecommends"></recommend-auction-vehicles>
<like-auction-vehicles :style="showLikes"></like-auction-vehicles>
</view>
<recommend-auction-vehicles :style="showRecommends"></recommend-auction-vehicles>
<like-auction-vehicles :style="showLikes"></like-auction-vehicles>
</view>
</scroll-view>
</view>
<van-dialog id="van-dialog" />
</scroll-view>
</view>
<van-dialog id="van-dialog" />
<van-dialog use-slot :show="showCertifyDialog" :show-cancel-button="false" :show-confirm-button="false">
<certification-dialog @close="onCertifyDialogClosed"></certification-dialog>
</van-dialog>
<van-dialog use-slot :show="showCertifyDialog" :show-cancel-button="false" :show-confirm-button="false">
<certification-dialog @close="onCertifyDialogClosed"></certification-dialog>
</van-dialog>
<latest-coupon-activity-popup :show="showLatestActivityPopup" :activity="latestActivityForPopup"
@close="onLatestActivityPopupClose" />
<latest-coupon-activity-popup :show="showLatestActivityPopup" :activity="latestActivityForPopup"
@close="onLatestActivityPopupClose" />
<!-- 完善收车偏好弹窗:由首页在认证与最新活动弹窗流程结束后触发 -->
<improve-popup ref="improvePopupRef" :parent-controlled="true" />
<!-- 完善收车偏好弹窗:由首页在认证与最新活动弹窗流程结束后触发 -->
<improve-popup ref="improvePopupRef" :parent-controlled="true" />
</view>
</template>
<script lang="ts">
......@@ -274,6 +276,8 @@ export default class HomePage extends Vue {
// 跳转
carouselLink(carousel: Carousel) {
console.log(carousel.link);
if (carousel.link && carousel.link.trim().length > 0) {
if (carousel.linkType === 'INTERNAL_PAGE') {
uni.navigateTo({
......
import {defineConfig} from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import vue from '@vitejs/plugin-vue';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig, type Plugin } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
function patchVendorShadowGrey(vendorPath: string): boolean {
if (!fs.existsSync(vendorPath)) {
return false;
}
const code = fs.readFileSync(vendorPath, 'utf8');
if (!code.includes('shadow-grey.png')) {
return false;
}
const patched = code.replace(
/wx\.preloadAssets\(\{data:\[\{type:"image",src:e\+"\/[^"]*shadow-grey\.png"\}\]\}\)/g,
'void 0 /* shadow-grey preload disabled */'
);
if (patched === code) {
return false;
}
fs.writeFileSync(vendorPath, patched);
return true;
}
/**
* 禁用 uni-app 编译产物中对 shadow-grey.png 的错误 preloadAssets 调用。
* 分包/朋友圈冷启动时该预加载会 500,可能导致页面异常;构建后 patch vendor.js,勿删此插件。
* @see src/module/auction/AuctionVehiclePage.share-timeline.md
*/
function fixUniShadowGreyPreload(): Plugin {
return {
name: 'fix-uni-shadow-grey-preload',
closeBundle() {
const distRoot = path.resolve(__dirname, 'dist');
for (const mode of ['dev', 'build'] as const) {
const vendorPath = path.join(distRoot, mode, 'mp-weixin', 'common', 'vendor.js');
if (patchVendorShadowGrey(vendorPath)) {
console.log(`[fix-uni-shadow-grey-preload] patched ${vendorPath}`);
}
}
},
};
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [uni()],
plugins: [uni(), fixUniShadowGreyPreload()],
transpileDependencies: ['@dcloudio/uni-ui'],
});
......@@ -48,6 +48,7 @@ export class Agreement extends AuditingEntity {
* ACCOUNT 用户协议
* PRIVACY 隐私协议
* ABOUT_US 关于我们
* COUPON_1 ~ COUPON_5 优惠券协议(多档活动可分别配置)
*/
export type Agreement_AgreementKey = 'AUCTION'|'TRANSACTION'|'VIOLATION'|'CONTRACT'|'ACCOUNT'|'PRIVACY'|'ABOUT_US'|'FAPAI_ACCOUNT'|'FAPAI_PRIVACY'|'COUPON_1'|'COUPON_2'|'COUPON_3'|'COUPON_4'|'COUPON_5';
export const AGREEMENT_AGREEMENT_KEYS = ['AUCTION','TRANSACTION','VIOLATION','CONTRACT','ACCOUNT','PRIVACY','ABOUT_US', 'FAPAI_ACCOUNT', 'FAPAI_PRIVACY', 'COUPON_1', 'COUPON_2', 'COUPON_3', 'COUPON_4', 'COUPON_5'];
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!