From 64abd3d4ab3985a4d0599bac22348f2562f14d86 Mon Sep 17 00:00:00 2001 From: fuchao <2577131060@qq.com> Date: Thu, 27 Nov 2025 15:38:24 +0800 Subject: [PATCH] revert 33c22eaad9cef70d703042a737b87499bffbfc86 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit revert 解决冲突 --- api/interceptors/response.ts | 19 +- api/modules/order.ts | 5 +- api/request.ts | 9 +- components/order/Confirm.vue | 405 ++++++++++++++++++----------- components/order/GoodsPrice.vue | 72 ----- components/order/GoodsSelector.vue | 90 ++++++- components/order/PayWay.vue | 28 +- components/order/ProductInfo.vue | 2 +- locale/en.json | 20 +- locale/zh-Hans.json | 18 +- pages/book/detail.vue | 61 +++-- pages/book/index.vue | 130 +++++---- pages/book/listen/index.vue | 29 ++- pages/book/listen/player.vue | 10 +- pages/book/review.vue | 135 ++++++---- pages/book/search.vue | 37 ++- pages/course/details/chapter.vue | 24 +- pages/course/details/course.vue | 153 ++++++----- pages/course/index.vue | 110 +++++--- pages/course/list/category.vue | 42 +-- pages/login/forget.vue | 38 +-- pages/login/login.vue | 18 +- pages/order/goodsConfirm.vue | 92 ++++++- pages/user/index.vue | 15 +- pages/user/order/index.vue | 2 +- pages/user/profile/index.vue | 192 +++++++------- pages/vip/course.vue | 0 types/order.d.ts | 8 - 28 files changed, 1059 insertions(+), 705 deletions(-) delete mode 100644 components/order/GoodsPrice.vue delete mode 100644 pages/vip/course.vue diff --git a/api/interceptors/response.ts b/api/interceptors/response.ts index 7e0236e..aa90e85 100644 --- a/api/interceptors/response.ts +++ b/api/interceptors/response.ts @@ -34,7 +34,7 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) { } // 可能为字符串,尝试解析(原项目也做了类似处理) - let httpData: IApiResponse | string = res.data; + let httpData: IApiResponse | string = res.data as any; if (typeof httpData === 'string') { try { httpData = JSON.parse(httpData); @@ -44,20 +44,19 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) { } // 规范化 message 字段 - const message = (httpData as IApiResponse).msg || (httpData as IApiResponse).message || (httpData as IApiResponse).errMsg || ''; + const message = (httpData as any).msg || (httpData as any).message || (httpData as any).errMsg || ''; - const code = (httpData as IApiResponse).code; - - // 成功判断 - const successFlag = (httpData as IApiResponse).success === true || code === 0; + // 成功判断:与原项目一致的条件 + const successFlag = (httpData as any).success === true || (httpData as any).code === 0; if (successFlag) { - // 返回原始 httpData - // 实际数据每个接口不同,调用者需根据实际情况取 .data 字段 + // 返回原始 httpData(与原项目 dataFactory 返回 Promise.resolve(httpData) 保持一致) + // 但大多数调用者更关心 data 字段,这里返回整个 httpData,调用者可取 .data return Promise.resolve(httpData); } - // 登录失效或需要强制登录的一些 code + // 登录失效或需要强制登录的一些 code(与原项目一致) + const code = (httpData as any).code; if (code === '401' || code === 401) { // 触发登出流程 handleAuthExpired(); @@ -65,7 +64,7 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) { } // 原项目还将 1000,1001,1100,402 等视作需要强制登录 - if (code == 1000 || code == 1001 || code === 1100 || code === 402) { + if (code === '1000' || code === '1001' || code === 1000 || code === 1001 || code === 1100 || code === '402' || code === 402) { handleAuthExpired(); return Promise.reject({ statusCode: 0, errMsg: message || t('global.loginExpired'), data: httpData }); } diff --git a/api/modules/order.ts b/api/modules/order.ts index b933e21..2b66a02 100644 --- a/api/modules/order.ts +++ b/api/modules/order.ts @@ -8,8 +8,7 @@ import type { IOrderGoods, ICoupon, ICourseOrderCreateParams, - IOrderInitData, - IGoodsDiscountParams + IOrderInitData } from '@/types/order' import type { IUserInfo } from '@/types/user' @@ -109,7 +108,7 @@ export const orderApi = { * 获取地区优惠金额 * @param productList 商品列表 */ - async getDistrictAmount(productList: IGoodsDiscountParams[]) { + async getDistrictAmount(productList: Array<{ productId: number; quantity: number }>) { const res = await mainClient.request>({ url: 'book/buyOrder/getDistrictAmount', method: 'POST', diff --git a/api/request.ts b/api/request.ts index 3f5f7a9..b908f14 100644 --- a/api/request.ts +++ b/api/request.ts @@ -8,7 +8,6 @@ import { t } from '@/utils/i18n' export function createRequestClient(cfg: ICreateClientConfig) { const baseURL = cfg.baseURL; const timeout = cfg.timeout ?? REQUEST_TIMEOUT; - let reqCount= 0 async function request(options: IRequestOptions): Promise { // 组装 final options @@ -24,18 +23,14 @@ export function createRequestClient(cfg: ICreateClientConfig) { // 全局处理请求 loading const loading = !cfg.loading ? true : cfg.loading // 接口请求参数不传loading,默认显示loading - if (loading) { - uni.showLoading({ mask: true }) - reqCount++ - } + loading && uni.showLoading() return new Promise((resolve, reject) => { uni.request({ ...intercepted, complete() { // 请求完成关闭 loading - loading && reqCount-- - reqCount <= 0 && uni.hideLoading() + loading && uni.hideLoading() }, success(res: any) { // 委托给响应拦截器处理 diff --git a/components/order/Confirm.vue b/components/order/Confirm.vue index 46af04e..68fb531 100644 --- a/components/order/Confirm.vue +++ b/components/order/Confirm.vue @@ -26,47 +26,53 @@ {{ $t('order.totalPrice') }} - {{ totalAmount.toFixed(2) }} {{ t('global.coin') }} + {{ totalPrice.toFixed(2) }} 天医币 - - {{ $t('order.promotionDiscounted') }} - -{{ promotionDiscounted.toFixed(2) }} {{ t('global.coin') }} + + {{ $t('order.activityDiscount') }} + -¥{{ activityDiscountAmount.toFixed(2) }} - + VIP {{ $t('order.vipDiscount') }} - -{{ vipDiscounted.toFixed(2) }} {{ t('global.coin') }} + -¥{{ vipPrice.toFixed(2) }} + + + + + {{ $t('order.districtDiscount') }} + -¥{{ districtAmount.toFixed(2) }} - + {{ $t('order.points') }} - ({{ $t('order.allPoints') }}:{{ userInfo?.jf || 0 }}) + ({{ $t('order.allPoints') }}:{{ userInfo.jf }}) - -{{ pointsDiscounted.toFixed(2) }} + -{{ jfNumber.toFixed(2) }} - + - {{ $t('order.maxPoints', { max: pointsUsableMax }) }} + {{ $t('order.maxPoints', { max: jfNumberMax }) }} {{ $t('order.total') }}: - {{ finalAmount }} {{ t('global.coin') }} + {{ actualPayment.toFixed(2) }} 天医币 - + {{ $t('order.submit') }} @@ -114,7 +120,7 @@ - {{ $t('global.ok') }} + {{ $t('global.ok') }} @@ -122,61 +128,93 @@ diff --git a/components/order/GoodsPrice.vue b/components/order/GoodsPrice.vue deleted file mode 100644 index 739417e..0000000 --- a/components/order/GoodsPrice.vue +++ /dev/null @@ -1,72 +0,0 @@ - - - - - \ No newline at end of file diff --git a/components/order/GoodsSelector.vue b/components/order/GoodsSelector.vue index c5ace12..1e82068 100644 --- a/components/order/GoodsSelector.vue +++ b/components/order/GoodsSelector.vue @@ -2,14 +2,18 @@ {{ goods[selectedIndex].productName }} - - + + {{ selectedGoodsPrice.lowestPrice }} 天医币 + {{ selectedGoodsPrice.priceLabel }} + {{ goods[selectedIndex].price }} 天医币 + @@ -28,8 +32,11 @@ {{ item.productName }} - - + + {{ calculatePrice(item).lowestPrice }} 天医币 + {{ calculatePrice(item).priceLabel }} + {{ item.price }} 天医币 + @@ -45,10 +52,12 @@