解决冲突
This commit is contained in:
@@ -34,7 +34,7 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 可能为字符串,尝试解析(原项目也做了类似处理)
|
// 可能为字符串,尝试解析(原项目也做了类似处理)
|
||||||
let httpData: IApiResponse | string = res.data as any;
|
let httpData: IApiResponse | string = res.data;
|
||||||
if (typeof httpData === 'string') {
|
if (typeof httpData === 'string') {
|
||||||
try {
|
try {
|
||||||
httpData = JSON.parse(httpData);
|
httpData = JSON.parse(httpData);
|
||||||
@@ -44,19 +44,20 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 规范化 message 字段
|
// 规范化 message 字段
|
||||||
const message = (httpData as any).msg || (httpData as any).message || (httpData as any).errMsg || '';
|
const message = (httpData as IApiResponse).msg || (httpData as IApiResponse).message || (httpData as IApiResponse).errMsg || '';
|
||||||
|
|
||||||
// 成功判断:与原项目一致的条件
|
const code = (httpData as IApiResponse).code;
|
||||||
const successFlag = (httpData as any).success === true || (httpData as any).code === 0;
|
|
||||||
|
// 成功判断
|
||||||
|
const successFlag = (httpData as IApiResponse).success === true || code === 0;
|
||||||
|
|
||||||
if (successFlag) {
|
if (successFlag) {
|
||||||
// 返回原始 httpData(与原项目 dataFactory 返回 Promise.resolve(httpData) 保持一致)
|
// 返回原始 httpData
|
||||||
// 但大多数调用者更关心 data 字段,这里返回整个 httpData,调用者可取 .data
|
// 实际数据每个接口不同,调用者需根据实际情况取 .data 字段
|
||||||
return Promise.resolve(httpData);
|
return Promise.resolve(httpData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 登录失效或需要强制登录的一些 code(与原项目一致)
|
// 登录失效或需要强制登录的一些 code
|
||||||
const code = (httpData as any).code;
|
|
||||||
if (code === '401' || code === 401) {
|
if (code === '401' || code === 401) {
|
||||||
// 触发登出流程
|
// 触发登出流程
|
||||||
handleAuthExpired();
|
handleAuthExpired();
|
||||||
@@ -64,7 +65,7 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 原项目还将 1000,1001,1100,402 等视作需要强制登录
|
// 原项目还将 1000,1001,1100,402 等视作需要强制登录
|
||||||
if (code === '1000' || code === '1001' || code === 1000 || code === 1001 || code === 1100 || code === '402' || code === 402) {
|
if (code == 1000 || code == 1001 || code === 1100 || code === 402) {
|
||||||
handleAuthExpired();
|
handleAuthExpired();
|
||||||
return Promise.reject({ statusCode: 0, errMsg: message || t('global.loginExpired'), data: httpData });
|
return Promise.reject({ statusCode: 0, errMsg: message || t('global.loginExpired'), data: httpData });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import type {
|
|||||||
IOrderGoods,
|
IOrderGoods,
|
||||||
ICoupon,
|
ICoupon,
|
||||||
ICourseOrderCreateParams,
|
ICourseOrderCreateParams,
|
||||||
IOrderInitData
|
IOrderInitData,
|
||||||
|
IGoodsDiscountParams
|
||||||
} from '@/types/order'
|
} from '@/types/order'
|
||||||
import type { IUserInfo } from '@/types/user'
|
import type { IUserInfo } from '@/types/user'
|
||||||
|
|
||||||
@@ -108,7 +109,7 @@ export const orderApi = {
|
|||||||
* 获取地区优惠金额
|
* 获取地区优惠金额
|
||||||
* @param productList 商品列表
|
* @param productList 商品列表
|
||||||
*/
|
*/
|
||||||
async getDistrictAmount(productList: Array<{ productId: number; quantity: number }>) {
|
async getDistrictAmount(productList: IGoodsDiscountParams[]) {
|
||||||
const res = await mainClient.request<IApiResponse<{ districtAmount: number }>>({
|
const res = await mainClient.request<IApiResponse<{ districtAmount: number }>>({
|
||||||
url: 'book/buyOrder/getDistrictAmount',
|
url: 'book/buyOrder/getDistrictAmount',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { t } from '@/utils/i18n'
|
|||||||
export function createRequestClient(cfg: ICreateClientConfig) {
|
export function createRequestClient(cfg: ICreateClientConfig) {
|
||||||
const baseURL = cfg.baseURL;
|
const baseURL = cfg.baseURL;
|
||||||
const timeout = cfg.timeout ?? REQUEST_TIMEOUT;
|
const timeout = cfg.timeout ?? REQUEST_TIMEOUT;
|
||||||
|
let reqCount= 0
|
||||||
|
|
||||||
async function request<T = any>(options: IRequestOptions): Promise<T> {
|
async function request<T = any>(options: IRequestOptions): Promise<T> {
|
||||||
// 组装 final options
|
// 组装 final options
|
||||||
@@ -23,14 +24,18 @@ export function createRequestClient(cfg: ICreateClientConfig) {
|
|||||||
|
|
||||||
// 全局处理请求 loading
|
// 全局处理请求 loading
|
||||||
const loading = !cfg.loading ? true : cfg.loading // 接口请求参数不传loading,默认显示loading
|
const loading = !cfg.loading ? true : cfg.loading // 接口请求参数不传loading,默认显示loading
|
||||||
loading && uni.showLoading()
|
if (loading) {
|
||||||
|
uni.showLoading({ mask: true })
|
||||||
|
reqCount++
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.request({
|
uni.request({
|
||||||
...intercepted,
|
...intercepted,
|
||||||
complete() {
|
complete() {
|
||||||
// 请求完成关闭 loading
|
// 请求完成关闭 loading
|
||||||
loading && uni.hideLoading()
|
loading && reqCount--
|
||||||
|
reqCount <= 0 && uni.hideLoading()
|
||||||
},
|
},
|
||||||
success(res: any) {
|
success(res: any) {
|
||||||
// 委托给响应拦截器处理
|
// 委托给响应拦截器处理
|
||||||
|
|||||||
@@ -26,53 +26,47 @@
|
|||||||
<!-- 商品总价 -->
|
<!-- 商品总价 -->
|
||||||
<view class="price-item">
|
<view class="price-item">
|
||||||
<text class="label">{{ $t('order.totalPrice') }}</text>
|
<text class="label">{{ $t('order.totalPrice') }}</text>
|
||||||
<text class="value">{{ totalPrice.toFixed(2) }} 天医币</text>
|
<text class="value">{{ totalAmount.toFixed(2) }} {{ t('global.coin') }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 优惠券 -->
|
<!-- 优惠券 -->
|
||||||
<!-- <coupon v-model="selectedCoupon" /> -->
|
<!-- <coupon v-model="selectedCoupon" /> -->
|
||||||
|
|
||||||
<!-- 活动立减 -->
|
<!-- 活动立减 -->
|
||||||
<view v-if="hasActivityDiscount" class="price-item">
|
<view v-if="promotionDiscounted > 0" class="price-item">
|
||||||
<text class="label">{{ $t('order.activityDiscount') }}</text>
|
<text class="label">{{ $t('order.promotionDiscounted') }}</text>
|
||||||
<text class="discount-value">-¥{{ activityDiscountAmount.toFixed(2) }}</text>
|
<text class="discount-value">-{{ promotionDiscounted.toFixed(2) }} {{ t('global.coin') }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- VIP专享立减 -->
|
<!-- VIP专享立减 -->
|
||||||
<view v-if="vipPrice > 0" class="price-item">
|
<view v-if="vipDiscounted > 0" class="price-item">
|
||||||
<view class="label-row">
|
<view class="label-row">
|
||||||
<text class="vip-icon">VIP</text>
|
<text class="vip-icon">VIP</text>
|
||||||
<text class="label">{{ $t('order.vipDiscount') }}</text>
|
<text class="label">{{ $t('order.vipDiscount') }}</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="discount-value">-¥{{ vipPrice.toFixed(2) }}</text>
|
<text class="discount-value">-{{ vipDiscounted.toFixed(2) }} {{ t('global.coin') }}</text>
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 地区优惠 -->
|
|
||||||
<view v-if="districtAmount > 0" class="price-item">
|
|
||||||
<text class="label">{{ $t('order.districtDiscount') }}</text>
|
|
||||||
<text class="discount-value">-¥{{ districtAmount.toFixed(2) }}</text>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 积分 -->
|
<!-- 积分 -->
|
||||||
<view v-if="allowPointPay && userInfo.jf > 0" class="price-item">
|
<view v-if="allowPointPay && userInfo?.jf > 0" class="price-item">
|
||||||
<view class="label-row">
|
<view class="label-row">
|
||||||
<image src="/static/icon/jifen.png" class="icon-img" />
|
<image src="/static/icon/jifen.png" class="icon-img" />
|
||||||
<text class="label">{{ $t('order.points') }}</text>
|
<text class="label">{{ $t('order.points') }}</text>
|
||||||
<text class="points-total">
|
<text class="points-total">
|
||||||
({{ $t('order.allPoints') }}:{{ userInfo.jf }})
|
({{ $t('order.allPoints') }}:{{ userInfo?.jf || 0 }})
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="discount-value">-{{ jfNumber.toFixed(2) }}</text>
|
<text class="discount-value">-{{ pointsDiscounted.toFixed(2) }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 积分输入 -->
|
<!-- 积分输入 -->
|
||||||
<view v-if="allowPointPay && userInfo.jf > 0" class="points-input-section">
|
<view v-if="allowPointPay && userInfo?.jf > 0" class="points-input-section">
|
||||||
<text class="points-label">
|
<text class="points-label">
|
||||||
{{ $t('order.maxPoints', { max: jfNumberMax }) }}
|
{{ $t('order.maxPoints', { max: pointsUsableMax }) }}
|
||||||
</text>
|
</text>
|
||||||
<view class="points-input-box">
|
<view class="points-input-box">
|
||||||
<input
|
<input
|
||||||
v-model="jfNumber"
|
v-model="pointsDiscounted"
|
||||||
type="number"
|
type="number"
|
||||||
clearable
|
clearable
|
||||||
:placeholder="$t('order.pointsPlaceholder')"
|
:placeholder="$t('order.pointsPlaceholder')"
|
||||||
@@ -94,9 +88,9 @@
|
|||||||
<view class="bottom-bar">
|
<view class="bottom-bar">
|
||||||
<view class="total-info">
|
<view class="total-info">
|
||||||
<text class="label">{{ $t('order.total') }}:</text>
|
<text class="label">{{ $t('order.total') }}:</text>
|
||||||
<text class="amount">{{ actualPayment.toFixed(2) }} 天医币</text>
|
<text class="amount">{{ finalAmount }} {{ t('global.coin') }}</text>
|
||||||
</view>
|
</view>
|
||||||
<wd-button type="primary" :loading="submitting" @click="handleSubmit">
|
<wd-button type="primary" @click="handleSubmit">
|
||||||
{{ $t('order.submit') }}
|
{{ $t('order.submit') }}
|
||||||
</wd-button>
|
</wd-button>
|
||||||
</view>
|
</view>
|
||||||
@@ -120,7 +114,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="popup-footer">
|
<view class="popup-footer">
|
||||||
<wd-button type="primary" block @click="handleRemarkConfirm">{{ $t('global.ok') }}</wd-button>
|
<wd-button type="primary" block @click="showRemarkPopup = false">{{ $t('global.ok') }}</wd-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</wd-popup>
|
</wd-popup>
|
||||||
@@ -128,93 +122,61 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import { orderApi } from '@/api/modules/order'
|
import { orderApi } from '@/api/modules/order'
|
||||||
import { t } from '@/utils/i18n'
|
import { t } from '@/utils/i18n'
|
||||||
import type { IOrderGoods } from '@/types/order'
|
import type { IGoods, IGoodsDiscountParams } from '@/types/order'
|
||||||
import PayWay from '@/components/order/PayWay.vue'
|
import PayWay from '@/components/order/PayWay.vue'
|
||||||
|
|
||||||
// 使用页面传参
|
// 使用页面传参
|
||||||
interface Props {
|
interface Props {
|
||||||
goodsList: IOrderGoods[],
|
goodsList: IGoods[],
|
||||||
userInfo: object,
|
userInfo: object,
|
||||||
allowPointPay: boolean,
|
allowPointPay: boolean,
|
||||||
|
orderType: string,
|
||||||
}
|
}
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
goodsList: () => [],
|
goodsList: () => [],
|
||||||
userInfo: () => ({}),
|
userInfo: () => ({}),
|
||||||
allowPointPay: () => true
|
allowPointPay: () => true,
|
||||||
|
orderType: () => 'order',
|
||||||
})
|
})
|
||||||
|
|
||||||
// 价格相关
|
|
||||||
const totalPrice = ref(0)
|
|
||||||
const vipPrice = ref(0)
|
|
||||||
const districtAmount = ref(0)
|
|
||||||
const actualPayment = ref(0)
|
|
||||||
|
|
||||||
// 积分相关
|
|
||||||
const jfNumber = ref(0)
|
|
||||||
const jfNumberMax = ref(0)
|
|
||||||
|
|
||||||
// 优惠券相关
|
|
||||||
|
|
||||||
|
|
||||||
// 订单备注
|
// 订单备注
|
||||||
const remark = ref('')
|
const remark = ref('')
|
||||||
const showRemarkPopup = ref(false)
|
const showRemarkPopup = ref(false)
|
||||||
|
|
||||||
// 支付相关
|
// 价格相关
|
||||||
|
const totalAmount = ref(0) // 商品总价
|
||||||
|
const vipDiscounted = ref(0) // VIP专享立减
|
||||||
|
const promotionDiscounted = ref(0) // 活动优惠金额
|
||||||
|
const couponDiscounted = ref(0) // 优惠券优惠金额
|
||||||
|
const finalAmount = ref<string | number>('--') // 最终支付金额
|
||||||
|
|
||||||
// UI状态
|
// 积分相关
|
||||||
const submitting = ref(false)
|
const pointsDiscounted = ref(0) // 积分支付金额
|
||||||
|
const pointsUsableMax = ref(0) // 最大可用积分
|
||||||
|
|
||||||
|
// 优惠券相关
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠价格的请求参数
|
||||||
|
*/
|
||||||
|
const goodsListParams = ref<IGoodsDiscountParams[]>([])
|
||||||
|
const getDiscountParams = (goodsList: IGoods[]) => {
|
||||||
|
goodsListParams.value = goodsList.map(item => ({
|
||||||
|
productId: item.productId,
|
||||||
|
quantity: item.productAmount || 1
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听商品列表变化,更新价格
|
||||||
watch(() => props.goodsList, () => {
|
watch(() => props.goodsList, () => {
|
||||||
|
getDiscountParams(props.goodsList)
|
||||||
// 初始化价格
|
// 初始化价格
|
||||||
calculateAllPrices()
|
calculateAllPrices()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否有活动优惠
|
|
||||||
*/
|
|
||||||
const hasActivityDiscount = computed(() => {
|
|
||||||
return props.goodsList.some(item => item.activityPrice && item.activityPrice > 0)
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 活动优惠金额
|
|
||||||
*/
|
|
||||||
const activityDiscountAmount = computed(() => {
|
|
||||||
return props.goodsList.reduce((sum, item) => {
|
|
||||||
if (item.activityPrice && item.activityPrice > 0) {
|
|
||||||
return sum + (item.price - item.activityPrice) * item.productAmount
|
|
||||||
}
|
|
||||||
return sum
|
|
||||||
}, 0)
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理商品数量变化
|
|
||||||
*/
|
|
||||||
const handleQuantityChange = async (item: IOrderGoods, value: number) => {
|
|
||||||
try {
|
|
||||||
// 更新购物车
|
|
||||||
await orderApi.updateCart({
|
|
||||||
productId: item.productId,
|
|
||||||
productAmount: value,
|
|
||||||
price: item.price
|
|
||||||
})
|
|
||||||
|
|
||||||
// 重新获取商品列表和计算价格
|
|
||||||
// await getGoodsList()
|
|
||||||
} catch (error) {
|
|
||||||
console.error('更新数量失败:', error)
|
|
||||||
uni.showToast({
|
|
||||||
title: '更新失败',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算所有价格
|
* 计算所有价格
|
||||||
*/
|
*/
|
||||||
@@ -223,14 +185,16 @@ const calculateAllPrices = async () => {
|
|||||||
// 计算商品总价
|
// 计算商品总价
|
||||||
calculateTotalPrice()
|
calculateTotalPrice()
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
// 获取VIP优惠
|
// 获取VIP优惠
|
||||||
// await calculateVipDiscount()
|
calculateVipDiscounted(),
|
||||||
|
|
||||||
// 获取地区优惠
|
// 获取活动优惠
|
||||||
// await calculateDistrictDiscount()
|
calculatePromotionDiscounted()
|
||||||
|
|
||||||
// 获取优惠券列表
|
// 获取优惠券列表
|
||||||
// await getAvailableCoupons()
|
// await getAvailableCoupons()
|
||||||
|
])
|
||||||
|
|
||||||
// 计算最终价格
|
// 计算最终价格
|
||||||
calculateFinalPrice()
|
calculateFinalPrice()
|
||||||
@@ -243,8 +207,7 @@ const calculateAllPrices = async () => {
|
|||||||
* 计算商品总价
|
* 计算商品总价
|
||||||
*/
|
*/
|
||||||
const calculateTotalPrice = () => {
|
const calculateTotalPrice = () => {
|
||||||
console.log('商品列表:', props.goodsList)
|
totalAmount.value = props.goodsList.reduce((sum: number, item: IGoods) => {
|
||||||
totalPrice.value = props.goodsList.reduce((sum, item) => {
|
|
||||||
// return sum + (item.price * item.productAmount)
|
// return sum + (item.price * item.productAmount)
|
||||||
return sum + (item.price * 1)
|
return sum + (item.price * 1)
|
||||||
}, 0)
|
}, 0)
|
||||||
@@ -253,95 +216,47 @@ const calculateTotalPrice = () => {
|
|||||||
/**
|
/**
|
||||||
* 计算VIP优惠
|
* 计算VIP优惠
|
||||||
*/
|
*/
|
||||||
const calculateVipDiscount = async () => {
|
const calculateVipDiscounted = async () => {
|
||||||
try {
|
const res = await orderApi.getVipDiscountAmount(goodsListParams.value)
|
||||||
const productList = props.goodsList.map(item => ({
|
vipDiscounted.value = res.discountAmount
|
||||||
productId: item.productId,
|
|
||||||
quantity: item.productAmount
|
|
||||||
}))
|
|
||||||
|
|
||||||
const res = await orderApi.getVipDiscountAmount(productList)
|
|
||||||
if (res.code === 0 && res.data) {
|
|
||||||
vipPrice.value = res.data.discountAmount
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('获取VIP优惠失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算活动优惠
|
* 计算活动优惠
|
||||||
*/
|
*/
|
||||||
const calculateDistrictDiscount = async () => {
|
const calculatePromotionDiscounted = async () => {
|
||||||
try {
|
const res = await orderApi.getDistrictAmount(goodsListParams.value)
|
||||||
const productList = props.goodsList.map(item => ({
|
promotionDiscounted.value = res.districtAmount
|
||||||
productId: item.productId,
|
|
||||||
quantity: item.productAmount
|
|
||||||
}))
|
|
||||||
|
|
||||||
const res = await orderApi.getDistrictAmount(productList)
|
|
||||||
if (res.code === 0 && res.data) {
|
|
||||||
districtAmount.value = res.data.districtAmount
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('获取地区优惠失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取可用优惠券
|
* 获取可用优惠券
|
||||||
*/
|
*/
|
||||||
const getAvailableCoupons = async () => {
|
// const getAvailableCoupons = async () => {
|
||||||
try {
|
// try {
|
||||||
const shopProductInfos = props.goodsList.map(item => {
|
// const shopProductInfos = props.goodsList.map(item => {
|
||||||
const price = item.activityPrice && item.activityPrice > 0 ? item.activityPrice : item.price
|
// const price = item.activityPrice && item.activityPrice > 0 ? item.activityPrice : item.price
|
||||||
return `${item.productId}:${price}:${item.productAmount}`
|
// return `${item.productId}:${price}:${item.productAmount}`
|
||||||
}).join(',')
|
// }).join(',')
|
||||||
|
|
||||||
const res = await orderApi.getCouponListPayment(shopProductInfos)
|
// const res = await orderApi.getCouponListPayment(shopProductInfos)
|
||||||
if (res.code === 0 && res.data) {
|
// if (res.code === 0 && res.data) {
|
||||||
couponList.value = res.data.couponHistoryList || []
|
// couponList.value = res.data.couponHistoryList || []
|
||||||
|
|
||||||
// 如果当前选中的优惠券不可用,清除选择
|
// // 如果当前选中的优惠券不可用,清除选择
|
||||||
if (selectedCoupon.value) {
|
// if (selectedCoupon.value) {
|
||||||
const stillAvailable = couponList.value.find(
|
// const stillAvailable = couponList.value.find(
|
||||||
c => c.couponId === selectedCoupon.value?.couponId && c.canUse === 1
|
// c => c.couponId === selectedCoupon.value?.couponId && c.canUse === 1
|
||||||
)
|
// )
|
||||||
if (!stillAvailable) {
|
// if (!stillAvailable) {
|
||||||
selectedCoupon.value = null
|
// selectedCoupon.value = null
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error('获取优惠券失败:', error)
|
// console.error('获取优惠券失败:', error)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
|
||||||
* 计算最终价格
|
|
||||||
*/
|
|
||||||
const calculateFinalPrice = () => {
|
|
||||||
// const couponAmount = selectedCoupon.value?.couponEntity.couponAmount || 0
|
|
||||||
const couponAmount = 0
|
|
||||||
|
|
||||||
// 计算最大可用积分
|
|
||||||
const orderAmountAfterDiscount = totalPrice.value - districtAmount.value - vipPrice.value
|
|
||||||
jfNumberMax.value = Math.min(
|
|
||||||
props.userInfo.jf || 0,
|
|
||||||
Math.floor(orderAmountAfterDiscount - couponAmount)
|
|
||||||
)
|
|
||||||
|
|
||||||
// 限制当前积分不超过最大值
|
|
||||||
if (jfNumber.value > jfNumberMax.value) {
|
|
||||||
jfNumber.value = jfNumberMax.value
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算实付款
|
|
||||||
actualPayment.value = Math.max(
|
|
||||||
0,
|
|
||||||
totalPrice.value - couponAmount - jfNumber.value - districtAmount.value - vipPrice.value
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理积分输入
|
* 处理积分输入
|
||||||
@@ -353,7 +268,7 @@ const handlePointsInput = (value: any) => {
|
|||||||
val = val.replace(/[^0-9]/g, '')
|
val = val.replace(/[^0-9]/g, '')
|
||||||
|
|
||||||
if (val === '0' || val === '') {
|
if (val === '0' || val === '') {
|
||||||
jfNumber.value = 0
|
pointsDiscounted.value = 0
|
||||||
} else {
|
} else {
|
||||||
let numericValue = parseInt(val, 10)
|
let numericValue = parseInt(val, 10)
|
||||||
if (numericValue < 0 || isNaN(numericValue)) {
|
if (numericValue < 0 || isNaN(numericValue)) {
|
||||||
@@ -361,11 +276,11 @@ const handlePointsInput = (value: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确保不超过最大值
|
// 确保不超过最大值
|
||||||
if (numericValue >= jfNumberMax.value) {
|
if (numericValue >= pointsUsableMax.value) {
|
||||||
numericValue = jfNumberMax.value
|
numericValue = pointsUsableMax.value
|
||||||
}
|
}
|
||||||
|
|
||||||
jfNumber.value = numericValue
|
pointsDiscounted.value = numericValue
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重新计算实付款
|
// 重新计算实付款
|
||||||
@@ -376,32 +291,52 @@ const handlePointsInput = (value: any) => {
|
|||||||
* 清除积分输入
|
* 清除积分输入
|
||||||
*/
|
*/
|
||||||
const handlePointsClear = () => {
|
const handlePointsClear = () => {
|
||||||
jfNumber.value = 0
|
pointsDiscounted.value = 0
|
||||||
calculateFinalPrice()
|
calculateFinalPrice()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跳转到充值页面
|
* 计算最终价格
|
||||||
*/
|
*/
|
||||||
const goToRecharge = () => {
|
const calculateFinalPrice = () => {
|
||||||
uni.navigateTo({
|
// const couponAmount = selectedCoupon.value?.couponEntity.couponAmount || 0
|
||||||
url: '/pages/user/wallet/recharge/index?source=order'
|
const couponAmount = 0
|
||||||
})
|
|
||||||
|
// 计算最大可用积分
|
||||||
|
const orderAmountAfterDiscount = totalAmount.value - promotionDiscounted.value - vipDiscounted.value
|
||||||
|
pointsUsableMax.value = Math.min(
|
||||||
|
props?.userInfo?.jf || 0,
|
||||||
|
Math.floor(orderAmountAfterDiscount - couponAmount)
|
||||||
|
)
|
||||||
|
|
||||||
|
// 限制当前积分不超过最大值
|
||||||
|
if (pointsDiscounted.value > pointsUsableMax.value) {
|
||||||
|
pointsDiscounted.value = pointsUsableMax.value
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// 计算实付款
|
||||||
* 确认备注
|
const result = Math.max(
|
||||||
*/
|
0,
|
||||||
const handleRemarkConfirm = () => {
|
totalAmount.value - couponAmount - pointsDiscounted.value - promotionDiscounted.value - vipDiscounted.value
|
||||||
showRemarkPopup.value = false
|
)
|
||||||
|
finalAmount.value = result.toFixed(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证订单
|
* 验证订单
|
||||||
*/
|
*/
|
||||||
const validateOrder = (): boolean => {
|
const validateOrder = (): boolean => {
|
||||||
|
// 验证实付金额是否计算完成
|
||||||
|
if (typeof finalAmount.value != 'number') {
|
||||||
|
uni.showToast({
|
||||||
|
title: t('order.invalidPaymentAmount'),
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// 验证天医币余额
|
// 验证天医币余额
|
||||||
if (actualPayment.value > props.userInfo.peanutCoin) {
|
if (finalAmount.value > props.userInfo.peanutCoin) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: t('order.insufficientBalance'),
|
title: t('order.insufficientBalance'),
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@@ -416,21 +351,8 @@ const validateOrder = (): boolean => {
|
|||||||
* 提交订单
|
* 提交订单
|
||||||
*/
|
*/
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (submitting.value) {
|
|
||||||
uni.showToast({
|
|
||||||
title: t('order.tooFrequent'),
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证订单
|
// 验证订单
|
||||||
if (!validateOrder()) {
|
if (!validateOrder()) return
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
submitting.value = true
|
|
||||||
|
|
||||||
// 创建订单 此app用天医币支付,创建订单成功即支付成功
|
// 创建订单 此app用天医币支付,创建订单成功即支付成功
|
||||||
await createOrder()
|
await createOrder()
|
||||||
@@ -439,53 +361,34 @@ const handleSubmit = async () => {
|
|||||||
title: t('order.orderSuccess'),
|
title: t('order.orderSuccess'),
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
})
|
})
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error('提交订单失败:', error)
|
|
||||||
uni.showToast({
|
|
||||||
title: t('order.orderFailed'),
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
} finally {
|
|
||||||
submitting.value = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建订单
|
* 创建订单
|
||||||
*/
|
*/
|
||||||
const createOrder = async (): Promise<string | null> => {
|
const createOrder = async (): Promise<string | null> => {
|
||||||
try {
|
|
||||||
const orderParams = {
|
const orderParams = {
|
||||||
userId: props.userInfo.id,
|
userId: props.userInfo.id,
|
||||||
paymentMethod: 4, // 天医币
|
paymentMethod: 4, // 天医币
|
||||||
orderMoney: totalPrice.value,
|
orderMoney: totalAmount.value,
|
||||||
realMoney: actualPayment.value,
|
realMoney: finalAmount.value,
|
||||||
jfDeduction: jfNumber.value,
|
pointsDeduction: pointsDiscounted.value,
|
||||||
// couponId: selectedCoupon.value?.id,
|
// couponId: selectedCoupon.value?.id,
|
||||||
// couponName: selectedCoupon.value?.couponEntity.couponName,
|
// couponName: selectedCoupon.value?.couponEntity.couponName,
|
||||||
// vipDiscountAmount: vipPrice.value,
|
vipDiscountAmount: vipDiscounted.value,
|
||||||
// districtMoney: districtAmount.value,
|
districtMoney: promotionDiscounted.value,
|
||||||
remark: remark.value,
|
remark: remark.value,
|
||||||
productList: props.goodsList.map(item => ({
|
productList: goodsListParams.value,
|
||||||
productId: item.productId,
|
orderType: props.orderType,
|
||||||
quantity: item.productAmount || 1
|
|
||||||
})),
|
|
||||||
orderType: 'order',
|
|
||||||
come: 10
|
come: 10
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await orderApi.placeCourseOrder(orderParams)
|
const res = await orderApi.placeCourseOrder(orderParams)
|
||||||
|
|
||||||
if (res.code === 0 && res.orderSn) {
|
if (res.orderSn) {
|
||||||
return res.orderSn
|
return res.orderSn
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
} catch (error) {
|
|
||||||
console.error('创建订单失败:', error)
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
72
components/order/GoodsPrice.vue
Normal file
72
components/order/GoodsPrice.vue
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<template>
|
||||||
|
<view class="price-info">
|
||||||
|
<text class="price">{{ goodsPrice.lowestPrice }} {{ t('global.coin') }}</text>
|
||||||
|
<text class="price-label">{{ goodsPrice.priceLabel }}</text>
|
||||||
|
<text v-if="goodsPrice.priceLabel" class="original-price">{{ props.goods.price }} {{ t('global.coin') }}</text>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import { calculateLowestPrice } from '@/utils/index'
|
||||||
|
import { t } from '@/utils/i18n'
|
||||||
|
import type { IGoods } from '@/types/order'
|
||||||
|
|
||||||
|
const userStore = useUserStore()
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
goods: IGoods
|
||||||
|
}
|
||||||
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
|
// 计算商品价格
|
||||||
|
const goodsPrice = computed(() => {
|
||||||
|
const { activityPrice, vipPrice, price } = props.goods
|
||||||
|
const isVipUser = userStore.userVips && userStore.userVips.length > 0
|
||||||
|
const priceLabel = {
|
||||||
|
vipPrice: 'VIP优惠价',
|
||||||
|
activityPrice: '活动价',
|
||||||
|
price: ''
|
||||||
|
}
|
||||||
|
|
||||||
|
let priceData = null
|
||||||
|
if (isVipUser) {
|
||||||
|
priceData = { activityPrice, vipPrice, price }
|
||||||
|
} else {
|
||||||
|
priceData = { activityPrice, price }
|
||||||
|
}
|
||||||
|
const lowestPrice = calculateLowestPrice(priceData)
|
||||||
|
|
||||||
|
return {
|
||||||
|
lowestPrice: parseFloat(lowestPrice.value).toFixed(2),
|
||||||
|
priceLabel: priceLabel[lowestPrice.key as keyof typeof priceLabel]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.price-info {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 10rpx;
|
||||||
|
color: #e97512;
|
||||||
|
|
||||||
|
.price {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #e97512;
|
||||||
|
}
|
||||||
|
|
||||||
|
.price-label {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #e97512;
|
||||||
|
}
|
||||||
|
|
||||||
|
.original-price {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #8a8a8a;
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -2,18 +2,14 @@
|
|||||||
<wd-popup
|
<wd-popup
|
||||||
v-model="visible"
|
v-model="visible"
|
||||||
position="bottom"
|
position="bottom"
|
||||||
@close="handleClose"
|
|
||||||
>
|
>
|
||||||
<view class="goods-selector">
|
<view class="goods-selector">
|
||||||
<view v-if="selectedIndex !== -1" class="goods-info-mini">
|
<view v-if="selectedIndex !== -1" class="goods-info-mini">
|
||||||
<image :src="goods[selectedIndex].productImages" mode="aspectFit" class="goods-cover" />
|
<image :src="goods[selectedIndex].productImages" mode="aspectFit" class="goods-cover" />
|
||||||
<view class="info">
|
<view class="info">
|
||||||
<view class="name">{{ goods[selectedIndex].productName }}</view>
|
<view class="name">{{ goods[selectedIndex].productName }}</view>
|
||||||
<view class="price-info">
|
<!-- 商品价格组件 -->
|
||||||
<text class="price">{{ selectedGoodsPrice.lowestPrice }} 天医币</text>
|
<GoodsPrice :goods="goods[selectedIndex]" />
|
||||||
<text class="price-label">{{ selectedGoodsPrice.priceLabel }}</text>
|
|
||||||
<text v-if="selectedGoodsPrice.priceLabel" class="original-price">{{ goods[selectedIndex].price }} 天医币</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -32,11 +28,8 @@
|
|||||||
<view class="goods-info">
|
<view class="goods-info">
|
||||||
<text class="goods-name">{{ item.productName }}</text>
|
<text class="goods-name">{{ item.productName }}</text>
|
||||||
|
|
||||||
<view class="price-info">
|
<!-- 商品价格组件 -->
|
||||||
<text class="price">{{ calculatePrice(item).lowestPrice }} 天医币</text>
|
<GoodsPrice :goods="item" />
|
||||||
<text class="price-label">{{ calculatePrice(item).priceLabel }}</text>
|
|
||||||
<text v-if="calculatePrice(item).priceLabel" class="original-price">{{ item.price }} 天医币</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -52,12 +45,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue'
|
import { ref, computed, watch } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useUserStore } from '@/stores/user'
|
|
||||||
import { calculateLowestPrice } from '@/utils/index'
|
|
||||||
import type { IGoods } from '@/types/order'
|
import type { IGoods } from '@/types/order'
|
||||||
|
import GoodsPrice from '@/components/order/GoodsPrice.vue';
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const userStore = useUserStore()
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
show: boolean
|
show: boolean
|
||||||
@@ -80,38 +71,8 @@ const visible = computed({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 计算商品价格
|
// 选中商品的索引
|
||||||
const calculatePrice = (goods: IGoods) => {
|
|
||||||
const { activityPrice, vipPrice, price } = goods
|
|
||||||
const isVipUser = userStore.userVips && userStore.userVips.length > 0
|
|
||||||
const priceLabel = {
|
|
||||||
vipPrice: 'VIP优惠价',
|
|
||||||
activityPrice: '活动价',
|
|
||||||
price: ''
|
|
||||||
}
|
|
||||||
|
|
||||||
let priceData = null
|
|
||||||
if (isVipUser) {
|
|
||||||
priceData = { activityPrice, vipPrice, price }
|
|
||||||
} else {
|
|
||||||
priceData = { activityPrice, price }
|
|
||||||
}
|
|
||||||
const lowestPrice = calculateLowestPrice(priceData)
|
|
||||||
|
|
||||||
return {
|
|
||||||
lowestPrice: parseFloat(lowestPrice.value).toFixed(2),
|
|
||||||
priceLabel: priceLabel[lowestPrice.key as keyof typeof priceLabel]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const selectedIndex = ref(-1)
|
const selectedIndex = ref(-1)
|
||||||
// 选中商品的价格
|
|
||||||
const selectedGoodsPrice = computed(() => {
|
|
||||||
if (selectedIndex.value === -1) return 0
|
|
||||||
const selectedGoods = props.goods[selectedIndex.value]
|
|
||||||
return calculatePrice(selectedGoods)
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择商品
|
* 选择商品
|
||||||
*/
|
*/
|
||||||
@@ -135,13 +96,6 @@ const handleConfirm = () => {
|
|||||||
emit('confirm', props.goods[selectedIndex.value])
|
emit('confirm', props.goods[selectedIndex.value])
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 关闭选择器
|
|
||||||
*/
|
|
||||||
const handleClose = () => {
|
|
||||||
emit('close')
|
|
||||||
}
|
|
||||||
|
|
||||||
// 监听显示状态,重置选择
|
// 监听显示状态,重置选择
|
||||||
watch(() => props.show, (newVal: boolean) => {
|
watch(() => props.show, (newVal: boolean) => {
|
||||||
if (newVal && props.goods.length > 0) {
|
if (newVal && props.goods.length > 0) {
|
||||||
@@ -175,30 +129,6 @@ watch(() => props.show, (newVal: boolean) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.price-info {
|
|
||||||
display: flex;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: 10rpx;
|
|
||||||
color: #e97512;
|
|
||||||
|
|
||||||
.price {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #e97512;
|
|
||||||
}
|
|
||||||
|
|
||||||
.price-label {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #e97512;
|
|
||||||
}
|
|
||||||
|
|
||||||
.original-price {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #8a8a8a;
|
|
||||||
text-decoration: line-through;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.goods-info-mini {
|
.goods-info-mini {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -226,13 +156,13 @@ watch(() => props.show, (newVal: boolean) => {
|
|||||||
|
|
||||||
.price-info {
|
.price-info {
|
||||||
padding-top: 20rpx;
|
padding-top: 20rpx;
|
||||||
}
|
|
||||||
|
|
||||||
.price {
|
:deep(.price) {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.goods-list {
|
.goods-list {
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<view class="payment-item">
|
<view class="payment-item">
|
||||||
<view class="payment-left">
|
<view class="payment-left">
|
||||||
<image src="/static/icon/pay_3.png" class="payment-icon" />
|
<image src="/static/icon/pay_3.png" class="payment-icon" />
|
||||||
<text class="">{{ $t('order.virtualCoin') }}</text>
|
<text class="">{{ $t('global.coin') }}</text>
|
||||||
<text class="text-[#7dc1f0]">
|
<text class="text-[#7dc1f0]">
|
||||||
({{ $t('order.balance') }}:{{ peanutCoin || 0 }})
|
({{ $t('order.balance') }}:{{ peanutCoin || 0 }})
|
||||||
</text>
|
</text>
|
||||||
@@ -25,19 +25,12 @@
|
|||||||
<view class="tip-title">{{ $t('order.paymentTipTitle') }}</view>
|
<view class="tip-title">{{ $t('order.paymentTipTitle') }}</view>
|
||||||
<view class="tip-item">{{ $t('order.paymentTip1') }}</view>
|
<view class="tip-item">{{ $t('order.paymentTip1') }}</view>
|
||||||
<view class="tip-item">
|
<view class="tip-item">
|
||||||
{{ $t('order.paymentTip2') }}
|
{{ $t('order.paymentTip2-1') }}
|
||||||
<text class="link-text" @click="makePhoneCall('022-24142321')">022-24142321</text>
|
<text class="link-text" @click="copyToClipboard('yilujiankangkefu')">yilujiankangkefu</text>
|
||||||
</view>
|
{{ $t('order.paymentTip2-2') }}
|
||||||
<view class="tip-item">
|
<text class="link-text" @click="copyToClipboard('AmazingLimited@163.com')">
|
||||||
{{ $t('order.paymentTip3') }}
|
AmazingLimited@163.com
|
||||||
<text class="link-text" @click="copyToClipboard('publisher@tmrjournals.com')">
|
|
||||||
publisher@tmrjournals.com
|
|
||||||
</text>
|
</text>
|
||||||
{{ $t('order.paymentTip3_1') }}
|
|
||||||
<text class="link-text" @click="copyToClipboard('yilujiankangkefu')">
|
|
||||||
yilujiankangkefu
|
|
||||||
</text>
|
|
||||||
{{ $t('order.paymentTip3_2') }}
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -53,6 +46,15 @@ const props = defineProps({
|
|||||||
default: 0
|
default: 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到充值页面
|
||||||
|
*/
|
||||||
|
const goToRecharge = () => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/user/wallet/recharge/index?source=order'
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<view class="order-item-product-name" v-html="title"></view>
|
<view class="order-item-product-name" v-html="title"></view>
|
||||||
</view>
|
</view>
|
||||||
<view class="order-item-product-price">
|
<view class="order-item-product-price">
|
||||||
<view class="price">{{ price }} 天医币</view>
|
<view class="price">{{ price }} {{ t('global.coin') }}</view>
|
||||||
<view class="count">x {{ 1 }}</view>
|
<view class="count">x {{ 1 }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
"dataNull": "No data available",
|
"dataNull": "No data available",
|
||||||
"networkConnectionError": "Network connection error.",
|
"networkConnectionError": "Network connection error.",
|
||||||
"loginExpired": "Login expired. Please log in again.",
|
"loginExpired": "Login expired. Please log in again.",
|
||||||
"requestException": "Request exception"
|
"requestException": "Request exception",
|
||||||
|
"coin": "Coin"
|
||||||
},
|
},
|
||||||
"tabar.course": "COURSE",
|
"tabar.course": "COURSE",
|
||||||
"tabar.book": "EBOOK",
|
"tabar.book": "EBOOK",
|
||||||
@@ -238,7 +239,6 @@
|
|||||||
"amount": "Amount",
|
"amount": "Amount",
|
||||||
"paymentMethod": "Payment Method",
|
"paymentMethod": "Payment Method",
|
||||||
"googlePay": "Google Pay",
|
"googlePay": "Google Pay",
|
||||||
"virtualCoin": "Virtual Coin",
|
|
||||||
"balance": "Balance",
|
"balance": "Balance",
|
||||||
"confirm": "Confirm Order",
|
"confirm": "Confirm Order",
|
||||||
"creating": "Creating order...",
|
"creating": "Creating order...",
|
||||||
@@ -247,6 +247,7 @@
|
|||||||
"paymentFailed": "Payment failed",
|
"paymentFailed": "Payment failed",
|
||||||
"paymentCancelled": "Payment cancelled",
|
"paymentCancelled": "Payment cancelled",
|
||||||
"insufficientBalance": "Insufficient virtual coin balance",
|
"insufficientBalance": "Insufficient virtual coin balance",
|
||||||
|
"invalidPaymentAmount": "Final amount calculation incomplete",
|
||||||
"googlePayNotAvailable": "Google Pay not available",
|
"googlePayNotAvailable": "Google Pay not available",
|
||||||
"productNotFound": "Product not found",
|
"productNotFound": "Product not found",
|
||||||
"orderCreateFailed": "Failed to create order",
|
"orderCreateFailed": "Failed to create order",
|
||||||
@@ -421,11 +422,9 @@
|
|||||||
"coupon": "Coupon",
|
"coupon": "Coupon",
|
||||||
"points": "Points",
|
"points": "Points",
|
||||||
"vipDiscount": "VIP Exclusive Discount",
|
"vipDiscount": "VIP Exclusive Discount",
|
||||||
"activityDiscount": "Activity Discount",
|
"promotionDiscounted": "Promotion Discount",
|
||||||
"districtDiscount": "Regional Discount",
|
|
||||||
"actualPayment": "Total",
|
"actualPayment": "Total",
|
||||||
"paymentMethod": "Payment Method",
|
"paymentMethod": "Payment Method",
|
||||||
"virtualCoin": "Virtual Coin",
|
|
||||||
"balance": "Balance",
|
"balance": "Balance",
|
||||||
"recharge": "Recharge Now",
|
"recharge": "Recharge Now",
|
||||||
"remark": "Order Remark",
|
"remark": "Order Remark",
|
||||||
@@ -452,14 +451,11 @@
|
|||||||
"duplicateConfirm": "Continue",
|
"duplicateConfirm": "Continue",
|
||||||
"duplicateCancel": "Cancel",
|
"duplicateCancel": "Cancel",
|
||||||
"customerService": "Customer Service",
|
"customerService": "Customer Service",
|
||||||
"paymentTip": "1 Virtual Coin = 1 CNY",
|
|
||||||
"paymentTipTitle": "Notes",
|
"paymentTipTitle": "Notes",
|
||||||
"paymentTip1": "1. 1 Virtual Coin = 1 CNY",
|
"paymentTip1": "1.1 points = 1 Tianyi coin",
|
||||||
"paymentTip2": "2. For questions, please call customer service",
|
"paymentTip2-1": "2.1 For assistance, please contact our customer service on WeChat",
|
||||||
"paymentTip3": "3. Non-mainland China users can pay by credit card. Simple and fast, recommended! Credit cards with Visa or MasterCard logos are accepted. Please send payment request to email",
|
"paymentTip2-2": "or by email at",
|
||||||
"paymentTip3_1": "(click to copy) with course name, amount, registered name and phone number, or add WeChat customer service (",
|
"ensureBalance": "Ensure sufficient Tianyi coin balance",
|
||||||
"paymentTip3_2": ") (click to copy). We will send payment link within 24 hours.",
|
|
||||||
"ensureBalance": "Ensure sufficient virtual coin balance",
|
|
||||||
"vipLabel": "VIP Discount",
|
"vipLabel": "VIP Discount",
|
||||||
"activityLabel": "Activity Price",
|
"activityLabel": "Activity Price",
|
||||||
"vipPriceLabel": "VIP Price",
|
"vipPriceLabel": "VIP Price",
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
"dataNull": "暂无数据",
|
"dataNull": "暂无数据",
|
||||||
"networkConnectionError": "网络连接错误。",
|
"networkConnectionError": "网络连接错误。",
|
||||||
"loginExpired": "登录失效,请重新登录。",
|
"loginExpired": "登录失效,请重新登录。",
|
||||||
"requestException": "请求异常"
|
"requestException": "请求异常",
|
||||||
|
"coin": "天医币"
|
||||||
},
|
},
|
||||||
"tabar.course": "课程",
|
"tabar.course": "课程",
|
||||||
"tabar.book": "图书",
|
"tabar.book": "图书",
|
||||||
@@ -265,7 +266,6 @@
|
|||||||
"amount": "金额",
|
"amount": "金额",
|
||||||
"paymentMethod": "支付方式",
|
"paymentMethod": "支付方式",
|
||||||
"googlePay": "Google Pay",
|
"googlePay": "Google Pay",
|
||||||
"virtualCoin": "虚拟币",
|
|
||||||
"balance": "余额",
|
"balance": "余额",
|
||||||
"confirm": "确认下单",
|
"confirm": "确认下单",
|
||||||
"creating": "创建订单中...",
|
"creating": "创建订单中...",
|
||||||
@@ -422,11 +422,9 @@
|
|||||||
"coupon": "优惠券",
|
"coupon": "优惠券",
|
||||||
"points": "积分",
|
"points": "积分",
|
||||||
"vipDiscount": "VIP专享立减",
|
"vipDiscount": "VIP专享立减",
|
||||||
"activityDiscount": "活动立减",
|
"promotionDiscounted": "活动立减",
|
||||||
"districtDiscount": "地区优惠",
|
|
||||||
"actualPayment": "实付款",
|
"actualPayment": "实付款",
|
||||||
"paymentMethod": "支付方式",
|
"paymentMethod": "支付方式",
|
||||||
"virtualCoin": "天医币",
|
|
||||||
"balance": "余额",
|
"balance": "余额",
|
||||||
"recharge": "立即充值",
|
"recharge": "立即充值",
|
||||||
"remark": "订单备注",
|
"remark": "订单备注",
|
||||||
@@ -445,6 +443,7 @@
|
|||||||
"pointsPlaceholder": "请输入积分",
|
"pointsPlaceholder": "请输入积分",
|
||||||
"allPoints": "全部积分",
|
"allPoints": "全部积分",
|
||||||
"insufficientBalance": "天医币余额不足",
|
"insufficientBalance": "天医币余额不足",
|
||||||
|
"invalidPaymentAmount": "实付金额计算未完成",
|
||||||
"orderCreating": "正在请求订单",
|
"orderCreating": "正在请求订单",
|
||||||
"orderSuccess": "购买成功",
|
"orderSuccess": "购买成功",
|
||||||
"orderFailed": "失败,请重新下单",
|
"orderFailed": "失败,请重新下单",
|
||||||
@@ -453,13 +452,10 @@
|
|||||||
"duplicateConfirm": "继续操作",
|
"duplicateConfirm": "继续操作",
|
||||||
"duplicateCancel": "点错了",
|
"duplicateCancel": "点错了",
|
||||||
"customerService": "客服",
|
"customerService": "客服",
|
||||||
"paymentTip": "1天医币 = 1元人民币",
|
|
||||||
"paymentTipTitle": "说明",
|
"paymentTipTitle": "说明",
|
||||||
"paymentTip1": "1. 1天医币 = 1元人民币",
|
"paymentTip1": "1. 1积分=1天医币",
|
||||||
"paymentTip2": "2.若有疑问或意见请致电客服",
|
"paymentTip2-1": "2. 若有疑问请加客服微信:{ customerServiceWechat } { customerServiceEmail }",
|
||||||
"paymentTip3": "3.非中国大陆用户可以信用卡支付。简单快捷,推荐使用!支付时使用的信用卡需要带有Visa或MasterCard的标识。请向邮箱",
|
"paymentTip2-2": "或邮箱联系",
|
||||||
"paymentTip3_1": "(点击复制)发送支付请求,内容需包含:拟购买的课程名称、支付金额、APP注册姓名及手机号码,或者加一路健康客服微信(",
|
|
||||||
"paymentTip3_2": ")(点击复制)联系我们,我们将在24小时内向您的邮箱或者微信发送支付链接,根据提示即可完成信用卡支付,无需兑换外币。",
|
|
||||||
"ensureBalance": "确保您的天医币足够支付",
|
"ensureBalance": "确保您的天医币足够支付",
|
||||||
"vipLabel": "VIP优惠",
|
"vipLabel": "VIP优惠",
|
||||||
"activityLabel": "活动价",
|
"activityLabel": "活动价",
|
||||||
|
|||||||
@@ -230,71 +230,44 @@ function initScrollHeight() {
|
|||||||
|
|
||||||
// 加载书籍详情
|
// 加载书籍详情
|
||||||
async function loadBookInfo() {
|
async function loadBookInfo() {
|
||||||
try {
|
|
||||||
const res = await bookApi.getBookInfo(bookId.value)
|
const res = await bookApi.getBookInfo(bookId.value)
|
||||||
|
|
||||||
if (res.bookInfo) {
|
|
||||||
bookInfo.value = res.bookInfo
|
bookInfo.value = res.bookInfo
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to load book info:', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载购买商品信息
|
// 加载购买商品信息
|
||||||
async function loadGoodsInfo() {
|
async function loadGoodsInfo() {
|
||||||
try {
|
|
||||||
const res = await bookApi.getBookGoods(bookId.value)
|
const res = await bookApi.getBookGoods(bookId.value)
|
||||||
if (res.code === 0) {
|
|
||||||
goodsList.value = res.productList || []
|
goodsList.value = res.productList || []
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to load goods info:', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载统计数据
|
// 加载统计数据
|
||||||
async function loadBookCount() {
|
async function loadBookCount() {
|
||||||
try {
|
|
||||||
const res = await bookApi.getBookReadCount(bookId.value)
|
const res = await bookApi.getBookReadCount(bookId.value)
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
readCount.value = res.readCount || 0
|
readCount.value = res.readCount || 0
|
||||||
listenCount.value = res.listenCount || 0
|
listenCount.value = res.listenCount || 0
|
||||||
buyCount.value = res.buyCount || 0
|
buyCount.value = res.buyCount || 0
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to load book count:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载评论
|
// 加载评论
|
||||||
async function loadComments() {
|
async function loadComments() {
|
||||||
try {
|
|
||||||
const res = await bookApi.getBookComments(bookId.value, 1, 10)
|
const res = await bookApi.getBookComments(bookId.value, 1, 10)
|
||||||
if (res.commentsTree && res.commentsTree.length > 0) {
|
if (res.commentsTree && res.commentsTree.length > 0) {
|
||||||
commentList.value = res.commentsTree
|
commentList.value = res.commentsTree
|
||||||
} else {
|
} else {
|
||||||
nullText.value = t('common.data_null')
|
nullText.value = t('common.data_null')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
nullText.value = t('common.data_null')
|
|
||||||
console.error('Failed to load comments:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载推荐书籍
|
// 加载推荐书籍
|
||||||
async function loadRecommendBooks() {
|
async function loadRecommendBooks() {
|
||||||
try {
|
|
||||||
const res = await bookApi.getRecommendBook(bookId.value)
|
const res = await bookApi.getRecommendBook(bookId.value)
|
||||||
if (res.bookList && res.bookList.length > 0) {
|
if (res.bookList && res.bookList.length > 0) {
|
||||||
relatedBooks.value = res.bookList
|
relatedBooks.value = res.bookList
|
||||||
} else {
|
} else {
|
||||||
nullBookText.value = t('common.data_null')
|
nullBookText.value = t('common.data_null')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
nullBookText.value = t('common.data_null')
|
|
||||||
console.error('Failed to load recommend books:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示购买弹窗
|
// 显示购买弹窗
|
||||||
|
|||||||
@@ -162,7 +162,7 @@
|
|||||||
>
|
>
|
||||||
<image :src="item.images" />
|
<image :src="item.images" />
|
||||||
<text class="book-text">{{ item.name }}</text>
|
<text class="book-text">{{ item.name }}</text>
|
||||||
<text class="book-price">{{ item.minPrice }} 天医币</text>
|
<text class="book-price">{{ item.minPrice }} {{ t('global.coin') }}</text>
|
||||||
<text v-if="formatStats(item)" class="book-flag">{{
|
<text v-if="formatStats(item)" class="book-flag">{{
|
||||||
formatStats(item)
|
formatStats(item)
|
||||||
}}</text>
|
}}</text>
|
||||||
@@ -219,21 +219,16 @@ const vipInfo = ref<IVipInfo | null>(null)
|
|||||||
* 获取VIP信息
|
* 获取VIP信息
|
||||||
*/
|
*/
|
||||||
const getVipInfo = async () => {
|
const getVipInfo = async () => {
|
||||||
try {
|
|
||||||
const res = await homeApi.getVipInfo()
|
const res = await homeApi.getVipInfo()
|
||||||
if (res.vipInfo) {
|
if (res.vipInfo) {
|
||||||
vipInfo.value = res.vipInfo
|
vipInfo.value = res.vipInfo
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取VIP信息失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取我的书单
|
* 获取我的书单
|
||||||
*/
|
*/
|
||||||
const getMyBooks = async () => {
|
const getMyBooks = async () => {
|
||||||
try {
|
|
||||||
const res = await homeApi.getMyBooks(1, 10)
|
const res = await homeApi.getMyBooks(1, 10)
|
||||||
if (res && res.code === 0) {
|
if (res && res.code === 0) {
|
||||||
showMyBooks.value = true
|
showMyBooks.value = true
|
||||||
@@ -246,30 +241,22 @@ const getMyBooks = async () => {
|
|||||||
url: '/pages/login/login'
|
url: '/pages/login/login'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取我的书单失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取推荐图书
|
* 获取推荐图书
|
||||||
*/
|
*/
|
||||||
const getRecommendBooks = async () => {
|
const getRecommendBooks = async () => {
|
||||||
try {
|
|
||||||
const res = await homeApi.getRecommendBooks()
|
const res = await homeApi.getRecommendBooks()
|
||||||
if (res.books && res.books.length > 0) {
|
if (res.books && res.books.length > 0) {
|
||||||
recommendBooksList.value = res.books
|
recommendBooksList.value = res.books
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取推荐图书失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取活动标签列表
|
* 获取活动标签列表
|
||||||
*/
|
*/
|
||||||
const getActivityLabels = async () => {
|
const getActivityLabels = async () => {
|
||||||
try {
|
|
||||||
const res = await homeApi.getBookLabelList(1)
|
const res = await homeApi.getBookLabelList(1)
|
||||||
showActivity.value = true
|
showActivity.value = true
|
||||||
if (res.lableList && res.lableList.length > 0) {
|
if (res.lableList && res.lableList.length > 0) {
|
||||||
@@ -277,16 +264,12 @@ const getActivityLabels = async () => {
|
|||||||
// 默认加载第一个标签的图书列表
|
// 默认加载第一个标签的图书列表
|
||||||
await getBooksByLabel(res.lableList[0].id, 'activity')
|
await getBooksByLabel(res.lableList[0].id, 'activity')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取活动标签失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取分类标签列表
|
* 获取分类标签列表
|
||||||
*/
|
*/
|
||||||
const getCategoryLabels = async () => {
|
const getCategoryLabels = async () => {
|
||||||
try {
|
|
||||||
const res = await homeApi.getBookLabelList(0)
|
const res = await homeApi.getBookLabelList(0)
|
||||||
showCategory.value = true
|
showCategory.value = true
|
||||||
if (res.lableList && res.lableList.length > 0) {
|
if (res.lableList && res.lableList.length > 0) {
|
||||||
@@ -294,16 +277,12 @@ const getCategoryLabels = async () => {
|
|||||||
// 默认加载第一个标签的二级标签
|
// 默认加载第一个标签的二级标签
|
||||||
await getSubLabels(res.lableList[0].id, 0)
|
await getSubLabels(res.lableList[0].id, 0)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取分类标签失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取二级标签列表
|
* 获取二级标签列表
|
||||||
*/
|
*/
|
||||||
const getSubLabels = async (pid: number, index: number) => {
|
const getSubLabels = async (pid: number, index: number) => {
|
||||||
try {
|
|
||||||
const res = await homeApi.getSubLabelList(pid)
|
const res = await homeApi.getSubLabelList(pid)
|
||||||
currentLevel1Index.value = index
|
currentLevel1Index.value = index
|
||||||
if (res.lableList && res.lableList.length > 0) {
|
if (res.lableList && res.lableList.length > 0) {
|
||||||
@@ -316,9 +295,6 @@ const getSubLabels = async (pid: number, index: number) => {
|
|||||||
categoryLevel2List.value = []
|
categoryLevel2List.value = []
|
||||||
await getBooksByLabel(pid, 'category')
|
await getBooksByLabel(pid, 'category')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取二级标签失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -328,7 +304,6 @@ const getBooksByLabel = async (
|
|||||||
labelId: number,
|
labelId: number,
|
||||||
type: 'activity' | 'category'
|
type: 'activity' | 'category'
|
||||||
) => {
|
) => {
|
||||||
try {
|
|
||||||
const res = await homeApi.getBooksByLabel(labelId)
|
const res = await homeApi.getBooksByLabel(labelId)
|
||||||
if (type === 'activity') {
|
if (type === 'activity') {
|
||||||
if (res.bookList && res.bookList.length > 0) {
|
if (res.bookList && res.bookList.length > 0) {
|
||||||
@@ -343,9 +318,6 @@ const getBooksByLabel = async (
|
|||||||
categoryBookList.value = []
|
categoryBookList.value = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取图书列表失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -117,19 +117,12 @@ function initScrollHeight() {
|
|||||||
|
|
||||||
// 加载书籍信息
|
// 加载书籍信息
|
||||||
async function loadBookInfo() {
|
async function loadBookInfo() {
|
||||||
try {
|
|
||||||
const res = await bookApi.getBookInfo(bookId.value)
|
const res = await bookApi.getBookInfo(bookId.value)
|
||||||
if (res.bookInfo) {
|
|
||||||
bookInfo.value = res.bookInfo
|
bookInfo.value = res.bookInfo
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to load book info:', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载章节列表
|
// 加载章节列表
|
||||||
async function loadChapterList() {
|
async function loadChapterList() {
|
||||||
try {
|
|
||||||
const res = await bookApi.getBookChapter({
|
const res = await bookApi.getBookChapter({
|
||||||
bookId: bookId.value
|
bookId: bookId.value
|
||||||
})
|
})
|
||||||
@@ -139,10 +132,6 @@ async function loadChapterList() {
|
|||||||
} else {
|
} else {
|
||||||
nullText.value = t('common.data_null')
|
nullText.value = t('common.data_null')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
nullText.value = t('common.data_null')
|
|
||||||
console.error('Failed to load chapter list:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 播放章节
|
// 播放章节
|
||||||
|
|||||||
@@ -245,15 +245,9 @@ function initAudioContext() {
|
|||||||
|
|
||||||
// 加载书籍信息
|
// 加载书籍信息
|
||||||
async function loadBookInfo() {
|
async function loadBookInfo() {
|
||||||
try {
|
|
||||||
const res = await bookApi.getBookInfo(bookId.value)
|
const res = await bookApi.getBookInfo(bookId.value)
|
||||||
if (res.bookInfo) {
|
|
||||||
bookInfo.value = res.bookInfo
|
bookInfo.value = res.bookInfo
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to load book info:', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载章节列表
|
// 加载章节列表
|
||||||
async function loadChapterList() {
|
async function loadChapterList() {
|
||||||
|
|||||||
@@ -164,14 +164,10 @@ function initScrollHeight() {
|
|||||||
|
|
||||||
// 加载书籍信息
|
// 加载书籍信息
|
||||||
async function loadBookInfo() {
|
async function loadBookInfo() {
|
||||||
try {
|
|
||||||
const res = await bookApi.getBookInfo(bookId.value)
|
const res = await bookApi.getBookInfo(bookId.value)
|
||||||
if (res.bookInfo) {
|
if (res.bookInfo) {
|
||||||
bookInfo.value = res.bookInfo
|
bookInfo.value = res.bookInfo
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to load book info:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载评论列表
|
// 加载评论列表
|
||||||
@@ -180,7 +176,6 @@ async function loadComments() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
const res = await bookApi.getBookComments(bookId.value, page.value.current, page.value.limit)
|
const res = await bookApi.getBookComments(bookId.value, page.value.current, page.value.limit)
|
||||||
|
|
||||||
commentsCount.value = res.commentsCount || 0
|
commentsCount.value = res.commentsCount || 0
|
||||||
@@ -191,10 +186,6 @@ async function loadComments() {
|
|||||||
} else if (commentList.value.length === 0) {
|
} else if (commentList.value.length === 0) {
|
||||||
nullText.value = t('common.data_null')
|
nullText.value = t('common.data_null')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
nullText.value = t('common.data_null')
|
|
||||||
console.error('Failed to load comments:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载更多
|
// 加载更多
|
||||||
@@ -275,7 +266,6 @@ function handleEmj(i: any) {
|
|||||||
|
|
||||||
// 提交评论
|
// 提交评论
|
||||||
async function submitComment() {
|
async function submitComment() {
|
||||||
try {
|
|
||||||
const content = await getEditorContent()
|
const content = await getEditorContent()
|
||||||
|
|
||||||
if (!content || content === '<p><br></p>') {
|
if (!content || content === '<p><br></p>') {
|
||||||
@@ -299,9 +289,6 @@ async function submitComment() {
|
|||||||
editorCtx.value?.clear()
|
editorCtx.value?.clear()
|
||||||
resetComments()
|
resetComments()
|
||||||
}, 500)
|
}, 500)
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to submit comment:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点赞/取消点赞
|
// 点赞/取消点赞
|
||||||
@@ -314,7 +301,6 @@ async function handleLike(comment: IComment) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
if (comment.isLike === 0) {
|
if (comment.isLike === 0) {
|
||||||
await bookApi.likeComment(comment.id)
|
await bookApi.likeComment(comment.id)
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -334,9 +320,6 @@ async function handleLike(comment: IComment) {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
resetComments()
|
resetComments()
|
||||||
}, 200)
|
}, 200)
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to like comment:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除评论
|
// 删除评论
|
||||||
@@ -348,7 +331,6 @@ function handleDelete(comment: IComment) {
|
|||||||
confirmText: t('common.confirm_text'),
|
confirmText: t('common.confirm_text'),
|
||||||
success: async (res) => {
|
success: async (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
try {
|
|
||||||
await bookApi.deleteComment(comment.id)
|
await bookApi.deleteComment(comment.id)
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: t('bookDetails.deleteSuccess'),
|
title: t('bookDetails.deleteSuccess'),
|
||||||
@@ -359,9 +341,6 @@ function handleDelete(comment: IComment) {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
resetComments()
|
resetComments()
|
||||||
}, 500)
|
}, 500)
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to delete comment:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -70,15 +70,9 @@ onLoad((options: any) => {
|
|||||||
* 获取VIP信息
|
* 获取VIP信息
|
||||||
*/
|
*/
|
||||||
const getVipInfo = async () => {
|
const getVipInfo = async () => {
|
||||||
try {
|
|
||||||
const res = await homeApi.getVipInfo()
|
const res = await homeApi.getVipInfo()
|
||||||
if (res.vipInfo) {
|
|
||||||
vipInfo.value = res.vipInfo
|
vipInfo.value = res.vipInfo
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取VIP信息失败:', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理搜索
|
* 处理搜索
|
||||||
@@ -91,7 +85,6 @@ const handleSearch = async () => {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
isEmpty.value = false
|
isEmpty.value = false
|
||||||
|
|
||||||
try {
|
|
||||||
const res = await homeApi.searchBooks({
|
const res = await homeApi.searchBooks({
|
||||||
title: keyword.value.trim(),
|
title: keyword.value.trim(),
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -104,14 +97,8 @@ const handleSearch = async () => {
|
|||||||
searchResults.value = []
|
searchResults.value = []
|
||||||
isEmpty.value = true
|
isEmpty.value = true
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('搜索失败:', error)
|
|
||||||
searchResults.value = []
|
|
||||||
isEmpty.value = true
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理清空
|
* 处理清空
|
||||||
|
|||||||
@@ -164,7 +164,6 @@ onLoad((options: any) => {
|
|||||||
* 加载章节详情
|
* 加载章节详情
|
||||||
*/
|
*/
|
||||||
const loadChapterDetail = async () => {
|
const loadChapterDetail = async () => {
|
||||||
try {
|
|
||||||
const res = await courseApi.getChapterDetail(chapterId.value)
|
const res = await courseApi.getChapterDetail(chapterId.value)
|
||||||
if (res.code === 0 && res.data) {
|
if (res.code === 0 && res.data) {
|
||||||
chapterDetail.value = res.data.detail
|
chapterDetail.value = res.data.detail
|
||||||
@@ -179,9 +178,6 @@ const loadChapterDetail = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('加载章节详情失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -259,9 +259,6 @@ onLoad(async (options: any) => {
|
|||||||
* 加载页面数据
|
* 加载页面数据
|
||||||
*/
|
*/
|
||||||
const loadPageData = async () => {
|
const loadPageData = async () => {
|
||||||
try {
|
|
||||||
uni.showLoading({ title: '加载中...' })
|
|
||||||
|
|
||||||
// 获取课程详情
|
// 获取课程详情
|
||||||
const res = await courseApi.getCourseDetail(courseId.value)
|
const res = await courseApi.getCourseDetail(courseId.value)
|
||||||
if (res.code === 0 && res.data) {
|
if (res.code === 0 && res.data) {
|
||||||
@@ -286,19 +283,12 @@ const loadPageData = async () => {
|
|||||||
|
|
||||||
// 加载评论
|
// 加载评论
|
||||||
await loadComments()
|
await loadComments()
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error('加载页面数据失败:', error)
|
|
||||||
} finally {
|
|
||||||
uni.hideLoading()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查VIP状态
|
* 检查VIP状态
|
||||||
*/
|
*/
|
||||||
const checkVipStatus = async () => {
|
const checkVipStatus = async () => {
|
||||||
try {
|
|
||||||
const res = await courseApi.checkCourseVip(courseId.value)
|
const res = await courseApi.checkCourseVip(courseId.value)
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
userVip.value = res.userVip || null
|
userVip.value = res.userVip || null
|
||||||
@@ -311,9 +301,6 @@ const checkVipStatus = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('检查VIP状态失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -324,7 +311,6 @@ const switchCatalogue = async (index: number) => {
|
|||||||
const catalogue = catalogueList.value[index]
|
const catalogue = catalogueList.value[index]
|
||||||
|
|
||||||
// 获取章节列表
|
// 获取章节列表
|
||||||
try {
|
|
||||||
const res = await courseApi.getCatalogueChapterList(catalogue.id)
|
const res = await courseApi.getCatalogueChapterList(catalogue.id)
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
chapterList.value = res.chapterList || []
|
chapterList.value = res.chapterList || []
|
||||||
@@ -337,9 +323,6 @@ const switchCatalogue = async (index: number) => {
|
|||||||
} else {
|
} else {
|
||||||
showRenewBtn.value = false
|
showRenewBtn.value = false
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('切换目录失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -366,7 +349,6 @@ const handleChapterClick = (chapter: IChapter) => {
|
|||||||
const handleGetFreeCourse = async () => {
|
const handleGetFreeCourse = async () => {
|
||||||
if (!currentCatalogue.value) return
|
if (!currentCatalogue.value) return
|
||||||
|
|
||||||
try {
|
|
||||||
uni.showLoading({ title: '领取中...' })
|
uni.showLoading({ title: '领取中...' })
|
||||||
const res = await courseApi.startStudyForMF(currentCatalogue.value.id)
|
const res = await courseApi.startStudyForMF(currentCatalogue.value.id)
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
@@ -374,11 +356,6 @@ const handleGetFreeCourse = async () => {
|
|||||||
// 刷新页面数据
|
// 刷新页面数据
|
||||||
await loadPageData()
|
await loadPageData()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('领取免费课程失败:', error)
|
|
||||||
} finally {
|
|
||||||
uni.hideLoading()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -387,7 +364,6 @@ const handleGetFreeCourse = async () => {
|
|||||||
const handlePurchase = async () => {
|
const handlePurchase = async () => {
|
||||||
if (!currentCatalogue.value) return
|
if (!currentCatalogue.value) return
|
||||||
|
|
||||||
try {
|
|
||||||
isFudu.value = false
|
isFudu.value = false
|
||||||
const res = await courseApi.getProductListForCourse(currentCatalogue.value.id)
|
const res = await courseApi.getProductListForCourse(currentCatalogue.value.id)
|
||||||
if (res.code === 0 && res.productList.length > 0) {
|
if (res.code === 0 && res.productList.length > 0) {
|
||||||
@@ -396,9 +372,6 @@ const handlePurchase = async () => {
|
|||||||
} else {
|
} else {
|
||||||
uni.showToast({ title: '此课程暂无购买方式', icon: 'none' })
|
uni.showToast({ title: '此课程暂无购买方式', icon: 'none' })
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取商品列表失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -407,7 +380,6 @@ const handlePurchase = async () => {
|
|||||||
const handleRenew = async () => {
|
const handleRenew = async () => {
|
||||||
if (!currentCatalogue.value) return
|
if (!currentCatalogue.value) return
|
||||||
|
|
||||||
try {
|
|
||||||
isFudu.value = true
|
isFudu.value = true
|
||||||
fuduCatalogueId.value = currentCatalogue.value.id
|
fuduCatalogueId.value = currentCatalogue.value.id
|
||||||
const res = await courseApi.getRenewProductList(currentCatalogue.value.id)
|
const res = await courseApi.getRenewProductList(currentCatalogue.value.id)
|
||||||
@@ -417,9 +389,6 @@ const handleRenew = async () => {
|
|||||||
} else {
|
} else {
|
||||||
uni.showToast({ title: '暂无复读方案', icon: 'none' })
|
uni.showToast({ title: '暂无复读方案', icon: 'none' })
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取复读商品列表失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -257,7 +257,6 @@ const handleFirstLevelClick = (item: string) => {
|
|||||||
* 获取课程分类数据
|
* 获取课程分类数据
|
||||||
*/
|
*/
|
||||||
const getMedicalTags = async () => {
|
const getMedicalTags = async () => {
|
||||||
try {
|
|
||||||
const res = await courseSubjectClassificationApi.getCourseMedicalTree()
|
const res = await courseSubjectClassificationApi.getCourseMedicalTree()
|
||||||
if (res && res.code === 0) {
|
if (res && res.code === 0) {
|
||||||
if (res.labels && res.labels.length > 0) {
|
if (res.labels && res.labels.length > 0) {
|
||||||
@@ -278,9 +277,6 @@ const getMedicalTags = async () => {
|
|||||||
curseTagList.value = []
|
curseTagList.value = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取医学课程分类失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 医学
|
* 医学
|
||||||
@@ -309,14 +305,10 @@ const curseClick = (item: IMedicalTag, index: number) => {
|
|||||||
*/
|
*/
|
||||||
const soulCateList = ref<IMedicalTag[]>([])
|
const soulCateList = ref<IMedicalTag[]>([])
|
||||||
const getSoulCateList = async () => {
|
const getSoulCateList = async () => {
|
||||||
try {
|
|
||||||
const res = await courseSubjectClassificationApi.getCourseSoulTree()
|
const res = await courseSubjectClassificationApi.getCourseSoulTree()
|
||||||
if (res.labels&&res.labels.length>0) {
|
if (res.labels&&res.labels.length>0) {
|
||||||
soulCateList.value = res.labels;
|
soulCateList.value = res.labels;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取心理学课程分类失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,14 +317,10 @@ const getSoulCateList = async () => {
|
|||||||
*/
|
*/
|
||||||
const sociologyCateList = ref<IMedicalTag[]>([])
|
const sociologyCateList = ref<IMedicalTag[]>([])
|
||||||
const getSociologyCateList = async () => {
|
const getSociologyCateList = async () => {
|
||||||
try {
|
|
||||||
const res = await courseSubjectClassificationApi.getCourseSociologyTree()
|
const res = await courseSubjectClassificationApi.getCourseSociologyTree()
|
||||||
if (res.labels&&res.labels.length>0) {
|
if (res.labels&&res.labels.length>0) {
|
||||||
sociologyCateList.value = res.labels;
|
sociologyCateList.value = res.labels;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取国学课程分类失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -369,7 +357,6 @@ const learnList = ref<ICourse[]>([]) // 观看记录列表
|
|||||||
* 获取观看记录
|
* 获取观看记录
|
||||||
*/
|
*/
|
||||||
const getLearnCourse = async () => {
|
const getLearnCourse = async () => {
|
||||||
try {
|
|
||||||
const res = await courseApi.getUserLateCourseList()
|
const res = await courseApi.getUserLateCourseList()
|
||||||
if (res && res.code === 0) {
|
if (res && res.code === 0) {
|
||||||
if (res.page && res.page.length > 0) {
|
if (res.page && res.page.length > 0) {
|
||||||
@@ -378,9 +365,6 @@ const getLearnCourse = async () => {
|
|||||||
learnList.value = []
|
learnList.value = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取观看记录失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新闻播报
|
// 新闻播报
|
||||||
@@ -389,7 +373,6 @@ const newsList = ref<INews[]>([]) // 新闻列表
|
|||||||
* 获取新闻列表
|
* 获取新闻列表
|
||||||
*/
|
*/
|
||||||
const getNewsList = async () => {
|
const getNewsList = async () => {
|
||||||
try {
|
|
||||||
const res = await commonApi.getMessageList(0, 1, 0)
|
const res = await commonApi.getMessageList(0, 1, 0)
|
||||||
if (res && res.code === 0) {
|
if (res && res.code === 0) {
|
||||||
if (res.messages && res.messages.length > 0) {
|
if (res.messages && res.messages.length > 0) {
|
||||||
@@ -398,9 +381,6 @@ const getNewsList = async () => {
|
|||||||
newsList.value = []
|
newsList.value = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取新闻列表失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 新闻点击处理
|
* 新闻点击处理
|
||||||
@@ -423,7 +403,6 @@ const tryListenList = ref<ICourse[]>([]) // 试听课程列表
|
|||||||
* 获取试听课程列表
|
* 获取试听课程列表
|
||||||
*/
|
*/
|
||||||
const getTryListenList = async () => {
|
const getTryListenList = async () => {
|
||||||
try {
|
|
||||||
const res = await courseApi.getMarketCourseList({
|
const res = await courseApi.getMarketCourseList({
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 6,
|
limit: 6,
|
||||||
@@ -436,9 +415,6 @@ const getTryListenList = async () => {
|
|||||||
tryListenList.value = []
|
tryListenList.value = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取试听课程失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ const subCategoryList = ref<ICategory[]>([]) // 子级分类列表
|
|||||||
* 获取分类下的子级分类
|
* 获取分类下的子级分类
|
||||||
*/
|
*/
|
||||||
const getSubCategoryList = async () => {
|
const getSubCategoryList = async () => {
|
||||||
try {
|
|
||||||
let res: any = null
|
let res: any = null
|
||||||
switch (subject.value) {
|
switch (subject.value) {
|
||||||
case '医学':
|
case '医学':
|
||||||
@@ -74,9 +73,6 @@ const getSubCategoryList = async () => {
|
|||||||
radio_category_id.value = 0
|
radio_category_id.value = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取分类下的子级分类失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -191,16 +191,12 @@ const getCode = async () => {
|
|||||||
if (!isEmailEmpty()) return
|
if (!isEmailEmpty()) return
|
||||||
if (!isEmailVerified(email.value)) return
|
if (!isEmailVerified(email.value)) return
|
||||||
|
|
||||||
try {
|
|
||||||
await commonApi.sendMailCaptcha(email.value)
|
await commonApi.sendMailCaptcha(email.value)
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: t('login.sendCodeSuccess'),
|
title: t('login.sendCodeSuccess'),
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
getCodeState()
|
getCodeState()
|
||||||
} catch (error) {
|
|
||||||
console.error('Send code error:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -264,7 +260,6 @@ const onSubmit = async () => {
|
|||||||
if (!isConfirmPasswordEmpty()) return
|
if (!isConfirmPasswordEmpty()) return
|
||||||
if (!isPasswordMatch()) return
|
if (!isPasswordMatch()) return
|
||||||
|
|
||||||
try {
|
|
||||||
await resetPassword(email.value, code.value, password.value)
|
await resetPassword(email.value, code.value, password.value)
|
||||||
|
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
@@ -275,9 +270,6 @@ const onSubmit = async () => {
|
|||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
|
||||||
console.error('Reset password error:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -285,13 +285,8 @@ const verifyCodeLogin = async () => {
|
|||||||
|
|
||||||
if (!isCodeEmpty()) return false
|
if (!isCodeEmpty()) return false
|
||||||
|
|
||||||
try {
|
|
||||||
const res = await loginWithCode(email.value, code.value)
|
const res = await loginWithCode(email.value, code.value)
|
||||||
return res
|
return res || null
|
||||||
} catch (error) {
|
|
||||||
console.error('验证码登录失败:', error)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 密码登录
|
// 密码登录
|
||||||
const passwordLogin = async () => {
|
const passwordLogin = async () => {
|
||||||
@@ -301,13 +296,8 @@ const passwordLogin = async () => {
|
|||||||
|
|
||||||
if (!isPasswordEmpty()) return false
|
if (!isPasswordEmpty()) return false
|
||||||
|
|
||||||
try {
|
|
||||||
const res = await loginWithPassword(phoneEmail.value, password.value)
|
const res = await loginWithPassword(phoneEmail.value, password.value)
|
||||||
return res
|
return res || null
|
||||||
} catch (error) {
|
|
||||||
console.error('密码登录失败:', error)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 提交登录
|
// 提交登录
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
|||||||
@@ -26,28 +26,8 @@
|
|||||||
<!-- 商品信息 -->
|
<!-- 商品信息 -->
|
||||||
<view class="goods-info">
|
<view class="goods-info">
|
||||||
<text class="goods-name">{{ item.productName }}</text>
|
<text class="goods-name">{{ item.productName }}</text>
|
||||||
|
<!-- 商品价格组件 -->
|
||||||
<!-- 价格信息 -->
|
<GoodsPrice :goods="item" />
|
||||||
<view class="price-info">
|
|
||||||
<!-- VIP优惠价 -->
|
|
||||||
<!-- <view v-if="item.isVipPrice === 1 && item.vipPrice" class="price-row">
|
|
||||||
<text class="vip-price">¥{{ item.vipPrice.toFixed(2) }}</text>
|
|
||||||
<text class="vip-label">{{ $t('order.vipPriceLabel') }}</text>
|
|
||||||
<text class="original-price">¥{{ item.price.toFixed(2) }}</text>
|
|
||||||
</view> -->
|
|
||||||
|
|
||||||
<!-- 活动价 -->
|
|
||||||
<!-- <view v-else-if="item.activityPrice && item.activityPrice > 0" class="price-row">
|
|
||||||
<text class="activity-price">¥{{ item.activityPrice.toFixed(2) }}</text>
|
|
||||||
<text class="activity-label">{{ $t('order.activityLabel') }}</text>
|
|
||||||
<text class="original-price">¥{{ item.price.toFixed(2) }}</text>
|
|
||||||
</view> -->
|
|
||||||
|
|
||||||
<!-- 普通价格 -->
|
|
||||||
<view class="price-row">
|
|
||||||
<text class="normal-price">{{ item.price.toFixed(2) }} 天医币</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 数量 -->
|
<!-- 数量 -->
|
||||||
<!-- <view class="quantity-row">
|
<!-- <view class="quantity-row">
|
||||||
@@ -69,26 +49,21 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { orderApi } from '@/api/modules/order'
|
import { orderApi } from '@/api/modules/order'
|
||||||
import Confirm from '@/components/order/Confirm.vue';
|
|
||||||
import type { IOrderGoods } from '@/types/order'
|
import type { IOrderGoods } from '@/types/order'
|
||||||
|
import Confirm from '@/components/order/Confirm.vue';
|
||||||
|
import GoodsPrice from '@/components/order/GoodsPrice.vue';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
*/
|
*/
|
||||||
const userInfo = ref(null)
|
const userInfo = ref({})
|
||||||
const getUserInfo = async () => {
|
const getUserInfo = async () => {
|
||||||
try {
|
|
||||||
const res = await orderApi.getUserInfo()
|
const res = await orderApi.getUserInfo()
|
||||||
if (res.code === 0) {
|
|
||||||
userInfo.value = res.result || {}
|
userInfo.value = res.result || {}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取用户信息失败:', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品列表
|
* 获取商品列表
|
||||||
@@ -96,16 +71,12 @@ const getUserInfo = async () => {
|
|||||||
const goodsIds = ref<string>('')
|
const goodsIds = ref<string>('')
|
||||||
const goodsList = ref<IOrderGoods[]>([])
|
const goodsList = ref<IOrderGoods[]>([])
|
||||||
const getGoodsList = async () => {
|
const getGoodsList = async () => {
|
||||||
try {
|
|
||||||
// 获取商品详情
|
// 获取商品详情
|
||||||
const res = await orderApi.getShopProductListByIds(goodsIds.value)
|
const res = await orderApi.getShopProductListByIds(goodsIds.value)
|
||||||
|
|
||||||
if (res.code === 0 && res.shopProductList?.length > 0) {
|
if (res.shopProductList?.length > 0) {
|
||||||
goodsList.value = res.shopProductList
|
goodsList.value = res.shopProductList
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取商品列表失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,43 +152,6 @@ onLoad(async (options: any) => {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.price-info {
|
|
||||||
.price-row {
|
|
||||||
display: flex;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: 10rpx;
|
|
||||||
|
|
||||||
.vip-price,
|
|
||||||
.activity-price {
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #e97512;
|
|
||||||
}
|
|
||||||
|
|
||||||
.normal-price {
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vip-label {
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #fa2d12;
|
|
||||||
}
|
|
||||||
|
|
||||||
.activity-label {
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #613804;
|
|
||||||
}
|
|
||||||
|
|
||||||
.original-price {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #999;
|
|
||||||
text-decoration: line-through;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.quantity-row {
|
.quantity-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
<view class="vip-card wallet_l">
|
<view class="vip-card wallet_l">
|
||||||
<view class="assets">
|
<view class="assets">
|
||||||
<view @click="goVirtualList">
|
<view @click="goVirtualList">
|
||||||
<view class="assets_row">天医币</view>
|
<view class="assets_row">{{ t('global.coin') }}</view>
|
||||||
<view>{{userInfo.peanutCoin ?? 1}}</view>
|
<view>{{userInfo.peanutCoin ?? 1}}</view>
|
||||||
</view>
|
</view>
|
||||||
<view @click="goPointsList">
|
<view @click="goPointsList">
|
||||||
@@ -162,10 +162,7 @@
|
|||||||
if (vipRes.vipInfo) {
|
if (vipRes.vipInfo) {
|
||||||
vipInfo.value = vipRes.vipInfo
|
vipInfo.value = vipRes.vipInfo
|
||||||
}
|
}
|
||||||
} catch (error) {
|
}}
|
||||||
console.error('获取数据失败:', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跳转到设置页面
|
* 跳转到设置页面
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
<ProductInfo v-if="order.orderType === 'abroadBook'" :data="order.bookEntity" :type="order.orderType" />
|
<ProductInfo v-if="order.orderType === 'abroadBook'" :data="order.bookEntity" :type="order.orderType" />
|
||||||
<ProductInfo v-if="order.orderType === 'vip'" :data="order.vipBuyConfigEntity" :type="order.orderType" />
|
<ProductInfo v-if="order.orderType === 'vip'" :data="order.vipBuyConfigEntity" :type="order.orderType" />
|
||||||
<!-- 三种订单类型商品信息 end -->
|
<!-- 三种订单类型商品信息 end -->
|
||||||
<view class="order-item-total-price">实付款:{{ order.orderMoney }} 天医币</view>
|
<view class="order-item-total-price">实付款:{{ order.orderMoney }} {{ t('global.coin') }}</view>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<view>
|
<view>
|
||||||
|
|||||||
@@ -199,15 +199,11 @@ const avatarUrl = ref('')
|
|||||||
*/
|
*/
|
||||||
const userInfo = ref<any>({}) // 用户信息
|
const userInfo = ref<any>({}) // 用户信息
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
try {
|
|
||||||
const res = await getUserInfo()
|
const res = await getUserInfo()
|
||||||
if (res.result) {
|
if (res.result) {
|
||||||
userStore.setUserInfo(res.result)
|
userStore.setUserInfo(res.result)
|
||||||
userInfo.value = res.result
|
userInfo.value = res.result
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('获取用户信息失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -324,16 +320,12 @@ const sendCode = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
await sendEmailCode(editForm.value.email)
|
await sendEmailCode(editForm.value.email)
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: t('user.sendCodeSuccess'),
|
title: t('user.sendCodeSuccess'),
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
startCountdown()
|
startCountdown()
|
||||||
} catch (error) {
|
|
||||||
console.error('发送验证码失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -398,7 +390,6 @@ const checkPasswordStrength = () => {
|
|||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
const key = currentField.value?.key
|
const key = currentField.value?.key
|
||||||
|
|
||||||
try {
|
|
||||||
// 构建更新数据对象
|
// 构建更新数据对象
|
||||||
let updateData: any = Object.assign({}, userInfo.value)
|
let updateData: any = Object.assign({}, userInfo.value)
|
||||||
|
|
||||||
@@ -481,9 +472,6 @@ const handleSubmit = async () => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getData()
|
getData()
|
||||||
}, 500)
|
}, 500)
|
||||||
} catch (error) {
|
|
||||||
console.error('更新失败:', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
0
pages/vip/course.vue
Normal file
0
pages/vip/course.vue
Normal file
8
types/order.d.ts
vendored
8
types/order.d.ts
vendored
@@ -13,6 +13,14 @@ export interface IGoods {
|
|||||||
delFlag?: number // 删除标记 -1-已下架
|
delFlag?: number // 删除标记 -1-已下架
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取优惠价格参数
|
||||||
|
**/
|
||||||
|
export interface IGoodsDiscountParams {
|
||||||
|
productId: number
|
||||||
|
quantity: number
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单接口
|
* 订单接口
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user