Merge branch 'master' of https://git.nuttyreading.com/zm/taimed-international-app
This commit is contained in:
@@ -11,6 +11,7 @@ import type {
|
|||||||
IComment,
|
IComment,
|
||||||
IReadProgress
|
IReadProgress
|
||||||
} from '@/types/book'
|
} from '@/types/book'
|
||||||
|
import type { IGoods } from '@/types/order'
|
||||||
|
|
||||||
const client = createRequestClient({ baseURL: SERVICE_MAP.MAIN })
|
const client = createRequestClient({ baseURL: SERVICE_MAP.MAIN })
|
||||||
|
|
||||||
@@ -212,5 +213,17 @@ export const bookApi = {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { chapterId }
|
data: { chapterId }
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取购买商品信息
|
||||||
|
* @param bookId 书籍ID
|
||||||
|
*/
|
||||||
|
getBookGoods(bookId: number) {
|
||||||
|
return client.request<IApiResponse<{ goodsList: IGoods[] }>>({
|
||||||
|
url: 'bookAbroad/home/getProductListForBook',
|
||||||
|
method: 'POST',
|
||||||
|
data: { bookId }
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,8 @@ import PayWay from '@/components/order/PayWay.vue'
|
|||||||
// 使用页面传参
|
// 使用页面传参
|
||||||
interface Props {
|
interface Props {
|
||||||
goodsList: IOrderGoods[],
|
goodsList: IOrderGoods[],
|
||||||
userInfo: object
|
userInfo: object,
|
||||||
|
allowPointPay: boolean,
|
||||||
}
|
}
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
goodsList: () => [],
|
goodsList: () => [],
|
||||||
@@ -320,7 +321,8 @@ const getAvailableCoupons = async () => {
|
|||||||
* 计算最终价格
|
* 计算最终价格
|
||||||
*/
|
*/
|
||||||
const calculateFinalPrice = () => {
|
const calculateFinalPrice = () => {
|
||||||
const couponAmount = selectedCoupon.value?.couponEntity.couponAmount || 0
|
// const couponAmount = selectedCoupon.value?.couponEntity.couponAmount || 0
|
||||||
|
const couponAmount = 0
|
||||||
|
|
||||||
// 计算最大可用积分
|
// 计算最大可用积分
|
||||||
const orderAmountAfterDiscount = totalPrice.value - districtAmount.value - vipPrice.value
|
const orderAmountAfterDiscount = totalPrice.value - districtAmount.value - vipPrice.value
|
||||||
|
|||||||
@@ -8,8 +8,12 @@
|
|||||||
<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">
|
||||||
<text class="name">{{ goods[selectedIndex].productName }}</text>
|
<view class="name">{{ goods[selectedIndex].productName }}</view>
|
||||||
<text v-if="selectedGoodsPrice" class="price">{{ selectedGoodsPrice }} 天医币</text>
|
<view class="price-info">
|
||||||
|
<text class="price">{{ selectedGoodsPrice.lowestPrice }} 天医币</text>
|
||||||
|
<text class="price-label">{{ selectedGoodsPrice.priceLabel }}</text>
|
||||||
|
<text v-if="selectedGoodsPrice.priceLabel" class="original-price">{{ goods[selectedIndex].price }} 天医币</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -28,23 +32,10 @@
|
|||||||
<view class="goods-info">
|
<view class="goods-info">
|
||||||
<text class="goods-name">{{ item.productName }}</text>
|
<text class="goods-name">{{ item.productName }}</text>
|
||||||
|
|
||||||
<!-- VIP优惠价 -->
|
<view class="price-info">
|
||||||
<view v-if="item.isVipPrice === 1 && item.vipPrice" class="price-info">
|
<text class="price">{{ calculatePrice(item).lowestPrice }} 天医币</text>
|
||||||
<text class="vip-price">{{ parseFloat(item.vipPrice).toFixed(2) }} 天医币</text>
|
<text class="price-label">{{ calculatePrice(item).priceLabel }}</text>
|
||||||
<text class="vip-label">VIP优惠价</text>
|
<text v-if="calculatePrice(item).priceLabel" class="original-price">{{ item.price }} 天医币</text>
|
||||||
<text class="original-price">{{ parseFloat(item.price).toFixed(2) }} 天医币</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 活动价 -->
|
|
||||||
<view v-else-if="item.activityPrice && item.activityPrice > 0" class="price-info">
|
|
||||||
<text class="activity-price">{{ parseFloat(item.activityPrice).toFixed(2) }} 天医币</text>
|
|
||||||
<text class="activity-label">活动价</text>
|
|
||||||
<text class="original-price">{{ parseFloat(item.price).toFixed(2) }} 天医币</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 普通价格 -->
|
|
||||||
<view v-else class="price-info">
|
|
||||||
<text class="normal-price">{{ parseFloat(item.price).toFixed(2) }} 天医币</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -61,9 +52,12 @@
|
|||||||
<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'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
const userStore = useUserStore()
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
show: boolean
|
show: boolean
|
||||||
@@ -86,17 +80,36 @@ 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(() => {
|
const selectedGoodsPrice = computed(() => {
|
||||||
if (selectedIndex.value === -1) return 0
|
if (selectedIndex.value === -1) return 0
|
||||||
const selectedGoods = props.goods[selectedIndex.value]
|
const selectedGoods = props.goods[selectedIndex.value]
|
||||||
if (selectedGoods.isVipPrice === 1 && selectedGoods.vipPrice) {
|
return calculatePrice(selectedGoods)
|
||||||
return parseFloat(selectedGoods.vipPrice).toFixed(2)
|
|
||||||
} else if (selectedGoods.activityPrice && selectedGoods.activityPrice > 0) {
|
|
||||||
return parseFloat(selectedGoods.activityPrice).toFixed(2)
|
|
||||||
}
|
|
||||||
return parseFloat(selectedGoods.price).toFixed(2)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,6 +175,30 @@ 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;
|
||||||
@@ -187,12 +224,12 @@ watch(() => props.show, (newVal: boolean) => {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.price {
|
.price-info {
|
||||||
display: block;
|
|
||||||
padding-top: 20rpx;
|
padding-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.price {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
color: #ff4703;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,38 +267,6 @@ watch(() => props.show, (newVal: boolean) => {
|
|||||||
color: #333;
|
color: #333;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.price-info {
|
|
||||||
display: flex;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: 10rpx;
|
|
||||||
|
|
||||||
.vip-price,
|
|
||||||
.activity-price,
|
|
||||||
.normal-price {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #e97512;
|
|
||||||
}
|
|
||||||
|
|
||||||
// .normal-price {}
|
|
||||||
|
|
||||||
.vip-label {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #fa2d12;
|
|
||||||
}
|
|
||||||
|
|
||||||
.activity-label {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #613804;
|
|
||||||
}
|
|
||||||
|
|
||||||
.original-price {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #8a8a8a;
|
|
||||||
text-decoration: line-through;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ onLoad((options: any) => {
|
|||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
loadBookInfo()
|
loadBookInfo()
|
||||||
|
loadGoodsInfo()
|
||||||
if (!isIOS.value) {
|
if (!isIOS.value) {
|
||||||
loadComments()
|
loadComments()
|
||||||
}
|
}
|
||||||
@@ -250,6 +251,18 @@ async function loadBookInfo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载购买商品信息
|
||||||
|
async function loadGoodsInfo() {
|
||||||
|
try {
|
||||||
|
const res = await bookApi.getBookGoods(bookId.value)
|
||||||
|
if (res.code === 0) {
|
||||||
|
goodsList.value = res.productList || []
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load goods info:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 加载统计数据
|
// 加载统计数据
|
||||||
async function loadBookCount() {
|
async function loadBookCount() {
|
||||||
try {
|
try {
|
||||||
@@ -305,9 +318,9 @@ function closePurchasePopup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 处理购买
|
// 处理购买
|
||||||
function handlePurchase() {
|
function handlePurchase(goods: IGoods) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/order/goodsConfirm?goods=${bookId.value}`
|
url: `/pages/order/goodsConfirm?goods=${goods.productId}`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.abroadPrice }} 天医币</text>
|
<text class="book-price">{{ item.minPrice }} 天医币</text>
|
||||||
<text v-if="formatStats(item)" class="book-flag">{{
|
<text v-if="formatStats(item)" class="book-flag">{{
|
||||||
formatStats(item)
|
formatStats(item)
|
||||||
}}</text>
|
}}</text>
|
||||||
|
|||||||
Reference in New Issue
Block a user