【分类】 修复# 服务金额显示错误的问题

dev1.0
kaeery 2025-03-13 11:19:22 +08:00
parent 28591c62da
commit ed75ec4008
9 changed files with 112 additions and 14 deletions

View File

@ -21,6 +21,10 @@
{{ orderInfo.appointTimeStart }} - {{ orderInfo.appointTimeEnd }} {{ orderInfo.appointTimeStart }} - {{ orderInfo.appointTimeEnd }}
</view> </view>
<view class="appointTitle mt-[16rpx]"></view> <view class="appointTitle mt-[16rpx]"></view>
<view class="mt-[16rpx]">
服务金额:
<text class="text-[#f36161] text-base pl-1.5">¥{{ servicePrice }}</text>
</view>
<!-- <view class="mt-[16rpx]"> <!-- <view class="mt-[16rpx]">
实付金额: 实付金额:
<text class="text-[#f36161] text-base pl-1.5"> <text class="text-[#f36161] text-base pl-1.5">
@ -54,8 +58,10 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, watchEffect } from 'vue' import { computed, ref, watchEffect } from 'vue'
import { apiOrderClose } from '@/api/order' import { apiOrderClose } from '@/api/order'
import { PriceEnum } from '@/enums/appEnums'
import { formatString } from '@/utils/util'
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@ -65,6 +71,10 @@ const props = withDefaults(
orderInfo: {} orderInfo: {}
} }
) )
const servicePrice = computed(() => {
const { priceType, goodsPrice, priceRange } = props.orderInfo
return priceType == PriceEnum.CUSTOMER_PRICE ? goodsPrice : formatString(priceRange)
})
const timeStamp = ref<number | null>(0) const timeStamp = ref<number | null>(0)
watchEffect(() => { watchEffect(() => {

View File

@ -70,8 +70,8 @@
</view> </view>
<view class="mt-[24rpx]"> <view class="mt-[24rpx]">
<price <price
:goodsData="orderData.orderGoods" :goodsData="orderData"
:priceType="orderData.orderGoods.priceType" :priceType="orderData.priceType"
:desc="orderData.orderGoods?.unitName" :desc="orderData.orderGoods?.unitName"
/> />
</view> </view>
@ -83,7 +83,8 @@
<view class="card normal text-base"> <view class="card normal text-base">
<view class="flex justify-between"> <view class="flex justify-between">
<view>服务金额</view> <view>服务金额</view>
<view>¥{{ orderData.orderAmount }}</view> <!-- <view>¥{{ orderData.orderAmount }}</view> -->
<view>¥{{ servicePrice }}</view>
</view> </view>
<!-- <view class="mt-[30rpx] flex justify-between" v-if="isUseCoupon"> <!-- <view class="mt-[30rpx] flex justify-between" v-if="isUseCoupon">
<view>抵扣金额</view> <view>抵扣金额</view>
@ -172,6 +173,8 @@
import { apiStaffOrderDetail } from '@/api/order' import { apiStaffOrderDetail } from '@/api/order'
import OrderFooter from '@/components/order-footer/index.vue' import OrderFooter from '@/components/order-footer/index.vue'
import Price from '@/components/price/index.vue' import Price from '@/components/price/index.vue'
import { PriceEnum } from '@/enums/appEnums'
import { formatString } from '@/utils/util'
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import { computed, ref, unref } from 'vue' import { computed, ref, unref } from 'vue'
@ -192,6 +195,10 @@ const initOrderDetail = async (): Promise<void> => {
} }
/** Methods End **/ /** Methods End **/
const isUseCoupon = computed(() => unref(orderData.value.couponDetailVo)) const isUseCoupon = computed(() => unref(orderData.value.couponDetailVo))
const servicePrice = computed(() => {
const { priceType, goodsPrice, priceRange } = orderData.value
return priceType == PriceEnum.CUSTOMER_PRICE ? goodsPrice : formatString(priceRange)
})
/** Life Cycle Start **/ /** Life Cycle Start **/
onLoad(options => { onLoad(options => {

View File

@ -11,6 +11,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { PriceEnum } from '@/enums/appEnums' import { PriceEnum } from '@/enums/appEnums'
import { GOODS } from '@/pages/goods/index.vue' import { GOODS } from '@/pages/goods/index.vue'
import { formatString } from '@/utils/util'
import { computed } from 'vue' import { computed } from 'vue'
import { ref, withDefaults } from 'vue' import { ref, withDefaults } from 'vue'
@ -34,8 +35,8 @@ const props = withDefaults(
const parsePrice = computed(() => { const parsePrice = computed(() => {
const { priceType, goodsData } = props const { priceType, goodsData } = props
return priceType == PriceEnum.CUSTOMER_PRICE return priceType == PriceEnum.CUSTOMER_PRICE
? goodsData.price ? goodsData.goodsPrice
: goodsData.minPrice + '-' + goodsData.maxPrice : formatString(goodsData.priceRange)
}) })
/** Props End **/ /** Props End **/

View File

@ -34,7 +34,7 @@
<view class="mt-[20rpx] truncate">{{ item4.name }}</view> <view class="mt-[20rpx] truncate">{{ item4.name }}</view>
<view class="text-primary mt-[10rpx]"> <view class="text-primary mt-[10rpx]">
<price <price
:goodsData="item4" :goodsData="converItem(item4)"
:priceType="item4.priceType" :priceType="item4.priceType"
:desc="item4.unit" :desc="item4.unit"
></price> ></price>
@ -57,6 +57,7 @@ import { ref, reactive, watchEffect } from 'vue'
import { apiGoodsLists } from '@/api/store' import { apiGoodsLists } from '@/api/store'
import Price from '@/components/price/index.vue' import Price from '@/components/price/index.vue'
import { useAppStore } from '@/stores/app' import { useAppStore } from '@/stores/app'
import { computed } from 'vue'
const { getImageUrl } = useAppStore() const { getImageUrl } = useAppStore()
/** Interface Start **/ /** Interface Start **/
@ -88,6 +89,14 @@ const props = withDefaults(
/** Data Start **/ /** Data Start **/
const goodsData = ref<Array<GoodsDataObj> | null | any>([]) const goodsData = ref<Array<GoodsDataObj> | null | any>([])
const converItem = computed(() => item => {
const { price, minPrice, maxPrice } = item
return {
...item,
goodsPrice: price,
priceRange: `${minPrice}-${maxPrice}`
}
})
/** Data End **/ /** Data End **/
/** Methods Start **/ /** Methods Start **/

View File

@ -37,7 +37,7 @@
<view class="flex justify-between padding"> <view class="flex justify-between padding">
<view class="text-primary"> <view class="text-primary">
<price <price
:goodsData="goodsData" :goodsData="converItem(goodsData)"
:priceType="goodsData.priceType" :priceType="goodsData.priceType"
:desc="goodsData.unit" :desc="goodsData.unit"
:scribingPrice="goodsData.scribingPrice" :scribingPrice="goodsData.scribingPrice"
@ -332,7 +332,14 @@ const goodsNum = ref(1)
const footerHeight = ref(0) const footerHeight = ref(0)
const paging = shallowRef() const paging = shallowRef()
const serviceList = ref<any>([]) const serviceList = ref<any>([])
const converItem = computed(() => item => {
const { price, minPrice, maxPrice } = item
return {
...item,
goodsPrice: price,
priceRange: `${minPrice}-${maxPrice}`
}
})
// //
const initGoodaDetail = async (cityId?: number): Promise<void> => { const initGoodaDetail = async (cityId?: number): Promise<void> => {
if (cityId || appStore.cityInfo.city_id) { if (cityId || appStore.cityInfo.city_id) {

View File

@ -19,6 +19,10 @@
<view class="mt-[16rpx]"> <view class="mt-[16rpx]">
预约时间: {{ orderInfo.appointTime }} {{ orderInfo.weekDay }} 预约时间: {{ orderInfo.appointTime }} {{ orderInfo.weekDay }}
</view> </view>
<view class="mt-[16rpx]">
服务金额:
<text class="text-[#f36161] text-base pl-1.5">¥{{ servicePrice }}</text>
</view>
<!-- <view class="mt-[16rpx]" v-if="orderInfo.orderStatus == 0"> <!-- <view class="mt-[16rpx]" v-if="orderInfo.orderStatus == 0">
待付金额: 待付金额:
<text class="text-[#f36161] text-base pl-1.5"> <text class="text-[#f36161] text-base pl-1.5">
@ -77,8 +81,10 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { inject, onUnmounted, ref, watch } from 'vue' import { computed, inject, onUnmounted, ref, watch } from 'vue'
import { apiOrderClose } from '@/api/order' import { apiOrderClose } from '@/api/order'
import { PriceEnum } from '@/enums/appEnums'
import { formatString } from '@/utils/util'
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@ -89,6 +95,11 @@ const props = withDefaults(
} }
) )
const emit = defineEmits(['refresh']) const emit = defineEmits(['refresh'])
const servicePrice = computed(() => {
const { priceType, goodsPrice, priceRange } = props.orderInfo
return priceType == PriceEnum.CUSTOMER_PRICE ? goodsPrice : formatString(priceRange)
})
const timeStamp = ref<number | null>(0) const timeStamp = ref<number | null>(0)
let timeoutId: Timeout | null = null let timeoutId: Timeout | null = null
// //

View File

@ -62,7 +62,7 @@
</view> </view>
<view class="mt-[24rpx]"> <view class="mt-[24rpx]">
<price <price
:goodsData="orderData" :goodsData="converItem(orderData)"
:priceType="orderData.priceType" :priceType="orderData.priceType"
:desc="orderData.unitName" :desc="orderData.unitName"
></price> ></price>
@ -234,6 +234,14 @@ const appoint = computed(() => {
else else
return `${appointTime.value.date} ${appointTime.value.start_time}-${appointTime.value.end_time}` return `${appointTime.value.date} ${appointTime.value.start_time}-${appointTime.value.end_time}`
}) })
const converItem = computed(() => item => {
const { price, minPrice, maxPrice } = item
return {
...item,
goodsPrice: price,
priceRange: `${minPrice}-${maxPrice}`
}
})
/**点击优惠券跳转 */ /**点击优惠券跳转 */
const handleNavigateUseCoupon = () => { const handleNavigateUseCoupon = () => {

View File

@ -70,8 +70,8 @@
</view> </view>
<view class="mt-[24rpx]"> <view class="mt-[24rpx]">
<price <price
:goodsData="orderData.orderGoods" :goodsData="orderData"
:priceType="orderData.orderGoods.priceType" :priceType="orderData.priceType"
:desc="orderData.orderGoods?.unitName" :desc="orderData.orderGoods?.unitName"
></price> ></price>
</view> </view>
@ -114,7 +114,8 @@
<view class="card normal text-base"> <view class="card normal text-base">
<view class="flex justify-between"> <view class="flex justify-between">
<view>服务金额</view> <view>服务金额</view>
<view>¥{{ orderData.totalAmount }}</view> <!-- <view>¥{{ orderData.totalAmount }}</view> -->
<view>¥{{ servicePrice }}</view>
</view> </view>
<!-- <view class="mt-[30rpx] flex justify-between" v-if="orderData.orderStatus == 0"> <!-- <view class="mt-[30rpx] flex justify-between" v-if="orderData.orderStatus == 0">
<view>待付金额</view> <view>待付金额</view>
@ -244,6 +245,8 @@ import OrderFooter from '@/components/order-footer/index.vue'
import Price from '@/components/price/index.vue' import Price from '@/components/price/index.vue'
import qrcode from '@/components/qrcode/index.vue' import qrcode from '@/components/qrcode/index.vue'
import ContactModal from '@/components/widgets/my-service/components/customer-service.vue' import ContactModal from '@/components/widgets/my-service/components/customer-service.vue'
import { PriceEnum } from '@/enums/appEnums'
import { formatString } from '@/utils/util'
import { onHide, onLoad, onShow, onUnload } from '@dcloudio/uni-app' import { onHide, onLoad, onShow, onUnload } from '@dcloudio/uni-app'
import { computed, reactive, ref, unref } from 'vue' import { computed, reactive, ref, unref } from 'vue'
@ -277,6 +280,10 @@ const setRefuseReasonStyle = computed(() => () => {
} }
return classNameMap return classNameMap
}) })
const servicePrice = computed(() => {
const { priceType, goodsPrice, priceRange } = orderData.value
return priceType == PriceEnum.CUSTOMER_PRICE ? goodsPrice : formatString(priceRange)
})
// //
const initOrderDetail = async (): Promise<void> => { const initOrderDetail = async (): Promise<void> => {

View File

@ -240,3 +240,41 @@ export function formatDate(datetime: string | any) {
sec = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() sec = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
return year + '-' + month + '-' + day + ' ' + hour + ':' + min + ':' + sec return year + '-' + month + '-' + day + ' ' + hour + ':' + min + ':' + sec
} }
export function formatString(input) {
const processNumber = numStr => {
if (!numStr.includes('.')) return numStr
// 分割整数和小数部分(处理 .00 和 20. 等情况)
const parts = numStr.split('.', 2)
let [intPart, decPart] = parts
// 处理类似 ".00" 的情况
intPart = intPart || '0'
// 处理小数部分全零或无小数部分的情况
if (!decPart || decPart.trimEnd().replace(/^0+$/, '') === '') {
return intPart
}
// 去除末尾零并处理格式问题
const strippedDec = decPart.trimEnd().replace(/^0+$/, '')
const result = `${intPart}.${strippedDec}`
// 处理特殊情况
if (strippedDec === '') return intPart // 123.000 → 123
if (result.endsWith('.')) return intPart // 123. → 123
if (result.startsWith('.') && strippedDec) return `0${result}` // .55 → 0.55
return result
}
if (!input) return
const parts = input.split('-', 2)
if (parts.length !== 2) return input
const left = processNumber(parts[0])
const right = processNumber(parts[1])
return `${left}-${right}`
}