diff --git a/api/config.ts b/api/config.ts
index c30d150..f437afb 100644
--- a/api/config.ts
+++ b/api/config.ts
@@ -7,8 +7,8 @@ export const ENV = process.env.NODE_ENV || 'development';
*/
const BASE_URL_MAP = {
development: {
- MAIN: 'http://192.168.110.100:9300/pb/', // 张川川
- // MAIN: 'https://global.nuttyreading.com/', // 线上
+ // MAIN: 'http://192.168.110.100:9300/pb/', // 张川川
+ MAIN: 'https://global.nuttyreading.com/', // 线上
// PAYMENT: 'https://dev-pay.example.com', // 暂时用不到
// CDN: 'https://cdn-dev.example.com', // 暂时用不到
},
diff --git a/api/modules/order.ts b/api/modules/order.ts
index 85d3562..700c222 100644
--- a/api/modules/order.ts
+++ b/api/modules/order.ts
@@ -2,8 +2,7 @@
import { mainClient } from '@/api/clients/main'
import type { IApiResponse } from '@/api/types'
import type {
- ICreateOrderParams,
- IGooglePayVerifyParams,
+ ICreateOrderParams,
ICreateOrderResponse,
IOrderGoods,
ICoupon,
diff --git a/components/order/Confirm.vue b/components/order/Confirm.vue
index f27417f..cb2cb52 100644
--- a/components/order/Confirm.vue
+++ b/components/order/Confirm.vue
@@ -67,7 +67,7 @@
{{ $t('order.total') }}:
{{ finalAmount }} {{ t('global.coin') }}
-
+
{{ $t('order.submit') }}
@@ -128,6 +128,7 @@ import { getUserInfo } from '@/api/modules/user'
import { useUserStore } from '@/stores/user'
import { t } from '@/utils/i18n'
import type { IGoods, IGoodsDiscountParams } from '@/types/order'
+import type { IUserInfo } from '@/types/user'
import PayWay from '@/components/order/PayWay.vue'
const userStore = useUserStore()
@@ -135,14 +136,13 @@ const userStore = useUserStore()
// 使用页面传参
interface Props {
goodsList: IGoods[],
- userInfo: object,
+ userInfo: IUserInfo,
allowPointPay?: boolean,
orderType?: string,
backStep?: number // 购买完成后返回几层页面
}
const props = withDefaults(defineProps(), {
goodsList: () => [],
- userInfo: () => ({}),
allowPointPay: true,
orderType: 'order',
backStep: 1
@@ -270,13 +270,24 @@ const calculatePromotionDiscounted = async () => {
const handlePointsInput = (value: any) => {
let val = String(value.detail.value)
- // 只允许数字字符,去掉小数点
- val = val.replace(/[^0-9]/g, '')
+ // 允许数字字符和小数点
+ val = val.replace(/[^0-9.]/g, '')
- if (val === '0' || val === '') {
+ // 确保只有一个小数点
+ const dotIndex = val.indexOf('.')
+ if (dotIndex !== -1) {
+ // 限制小数点后最多两位
+ val = val.substring(0, dotIndex + 1) + val.substring(dotIndex + 1).replace(/\./g, '')
+ const decimalPart = val.substring(dotIndex + 1)
+ if (decimalPart.length > 2) {
+ val = val.substring(0, dotIndex + 1) + decimalPart.substring(0, 2)
+ }
+ }
+
+ if (val === '' || val === '.') {
pointsDiscounted.value = 0
} else {
- let numericValue = parseInt(val, 10)
+ let numericValue = parseFloat(val)
if (numericValue < 0 || isNaN(numericValue)) {
numericValue = 0
}
@@ -316,7 +327,7 @@ const calculateFinalPrice = () => {
const orderAmountAfterDiscount = totalAmount.value - promotionDiscounted.value - vipDiscounted.value - couponAmount
pointsUsableMax.value = Math.min(
props?.userInfo?.jf || 0,
- Math.floor(props.allowPointPay ? orderAmountAfterDiscount : 0)
+ props.allowPointPay ? orderAmountAfterDiscount : 0
)
pointsDiscounted.value = pointsUsableMax.value
@@ -362,28 +373,37 @@ const validateOrder = (): boolean => {
/**
* 提交订单
*/
-const handleSubmit = async () => {
+const submitLoading = ref(false)
+const handleSubmit = async () => {
// 验证订单
if (!validateOrder()) return
+ submitLoading.value = true
- // 创建订单 此app用天医币支付,创建订单成功即支付成功
- await createOrder()
+ try {
+ // 创建订单 此app用天医币支付,创建订单成功即支付成功
+ await createOrder()
- // 重新获取用户信息更新store和本地缓存
- const res = await getUserInfo()
- userStore.setUserInfo(res.result)
+ // 重新获取用户信息更新store和本地缓存
+ const res = await getUserInfo()
+ userStore.setUserInfo(res.result)
- uni.showToast({
- title: t('order.orderSuccess'),
- icon: 'success'
- })
-
- // 返回上一页
- setTimeout(() => {
- uni.navigateBack({
- delta: props.backStep
+ uni.showToast({
+ title: t('order.orderSuccess'),
+ icon: 'success'
})
- }, 500)
+
+ // 返回上一页
+ setTimeout(() => {
+ uni.navigateBack({
+ delta: props.backStep
+ })
+ }, 500)
+ } catch (error) {
+ console.error('提交订单失败:', error)
+ } finally {
+ // 无论成功还是失败,都要重置loading状态
+ submitLoading.value = false
+ }
}
/**
diff --git a/pages/book/index.vue b/pages/book/index.vue
index da7c061..b851df6 100644
--- a/pages/book/index.vue
+++ b/pages/book/index.vue
@@ -1,5 +1,11 @@
-
+
-
+
@@ -469,6 +501,7 @@ onShow(() => {
.content-wrapper {
padding-bottom: 40rpx;
+ height: calc(100vh - 240px);
}
.mine-block {
diff --git a/pages/course/index.vue b/pages/course/index.vue
index 94cca6e..a4bc821 100644
--- a/pages/course/index.vue
+++ b/pages/course/index.vue
@@ -1,5 +1,11 @@
-
+
-
+