【订单】 优化# 商品价格

dev1.0
kaeery 2025-03-12 21:18:59 +08:00
parent 8522757d3f
commit 28591c62da
9 changed files with 55 additions and 9 deletions

View File

@ -128,12 +128,23 @@ const handleTimeSlot = (timeSlot: TimeSlotObj[]) => {
const time = new Date() // const time = new Date() //
const min = time.getMinutes() const min = time.getMinutes()
const startTime = time.getHours() + '' + (min <= 9 ? '0' + min : min) // 1030 --> 1030 const startTime = time.getHours() + '' + (min <= 9 ? '0' + min : min) // 1030 --> 1030
// const time = new Date() //
// const min = time.getMinutes()
// const hour = time.getHours()
// const currentMinutes = hour * 60 + min
timeSlot.forEach(item => { timeSlot.forEach(item => {
const end = item.endTime.replace(':', '') const end = item.endTime.replace(':', '')
// //
item.disabled = Number(startTime) + 50 >= Number(end) item.disabled = Number(startTime) + 50 >= Number(end)
// console.log("startTime: " + startTime); // console.log("startTime: " + startTime);
// console.log("end: " + end); // console.log("end: " + end);
// const [endHour, endMin] = item.endTime.split(':').map(Number)
// //
// const endMinutes = endHour * 60 + endMin
// //
// item.disabled = currentMinutes + 30 >= endMinutes
}) })
return timeSlot return timeSlot
} }

View File

@ -70,7 +70,8 @@
</view> </view>
<view class="mt-[24rpx]"> <view class="mt-[24rpx]">
<price <price
:price="orderData.orderGoods?.goodsPrice" :goodsData="orderData.orderGoods"
:priceType="orderData.orderGoods.priceType"
:desc="orderData.orderGoods?.unitName" :desc="orderData.orderGoods?.unitName"
/> />
</view> </view>

View File

@ -1,6 +1,6 @@
<template> <template>
<view class="primary"> <view class="primary">
<text class="text-lg font-medium text">{{ price }}</text> <text class="text-lg font-medium text">{{ parsePrice }}</text>
<text class="text-xs text">{{ desc }}</text> <text class="text-xs text">{{ desc }}</text>
<text v-if="scribingPrice" class="text-xs line-through ml-2 text-muted"> <text v-if="scribingPrice" class="text-xs line-through ml-2 text-muted">
{{ scribingPrice }}{{ desc }} {{ scribingPrice }}{{ desc }}
@ -9,6 +9,9 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { PriceEnum } from '@/enums/appEnums'
import { GOODS } from '@/pages/goods/index.vue'
import { computed } from 'vue'
import { ref, withDefaults } from 'vue' import { ref, withDefaults } from 'vue'
/** Props Start **/ /** Props Start **/
@ -17,13 +20,23 @@ const props = withDefaults(
price?: string | number // price?: string | number //
desc?: string // desc?: string //
scribingPrice?: string | number // 线 scribingPrice?: string | number // 线
goodsData: Partial<GOODS>
priceType: PriceEnum
}>(), }>(),
{ {
price: '', price: '',
desc: '', desc: '',
scribingPrice: '' scribingPrice: '',
goodsData: {},
priceType: PriceEnum.CUSTOMER_PRICE
} }
) )
const parsePrice = computed(() => {
const { priceType, goodsData } = props
return priceType == PriceEnum.CUSTOMER_PRICE
? goodsData.price
: goodsData.minPrice + '-' + goodsData.maxPrice
})
/** Props End **/ /** Props End **/
/** Methods Start **/ /** Methods Start **/

View File

@ -146,3 +146,7 @@ export const WithdrawStatusMap: Recordable<number, string> = {
[WithdrawStatusEnum.SUCCESS]: '提现成功', [WithdrawStatusEnum.SUCCESS]: '提现成功',
[WithdrawStatusEnum.FAIL]: '提现失败' [WithdrawStatusEnum.FAIL]: '提现失败'
} }
export enum PriceEnum {
CUSTOMER_PRICE = 0, //固定价格
TEACHER_PRICE = 1 // 价格区间
}

View File

@ -33,7 +33,11 @@
></u-image> ></u-image>
<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="item4.price" :desc="item4.unit"></price> <price
:goodsData="item4"
:priceType="item4.priceType"
:desc="item4.unit"
></price>
</view> </view>
</view> </view>
</block> </block>

View File

@ -37,7 +37,8 @@
<view class="flex justify-between padding"> <view class="flex justify-between padding">
<view class="text-primary"> <view class="text-primary">
<price <price
:price="goodsData.price" :goodsData="goodsData"
:priceType="goodsData.priceType"
:desc="goodsData.unit" :desc="goodsData.unit"
:scribingPrice="goodsData.scribingPrice" :scribingPrice="goodsData.scribingPrice"
/> />
@ -257,6 +258,7 @@ import { FieldType } from '@/enums/appEnums'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useTabs } from '@/hooks/useCoupon' import { useTabs } from '@/hooks/useCoupon'
import { apiRecommendService } from '@/api/store' import { apiRecommendService } from '@/api/store'
import { PriceEnum } from '@/enums/appEnums'
interface Rule { interface Rule {
intervalTime: number intervalTime: number
@ -280,6 +282,9 @@ export type GOODS = {
goods_comment_total: number // goods_comment_total: number //
[index: string]: string | number | any [index: string]: string | number | any
rules: Rule[] rules: Rule[]
priceType: PriceEnum
maxPrice: number
minPrice: number
} }
type TIME = { type TIME = {
@ -304,7 +309,10 @@ const goodsData = reactive<GOODS>({
goods_comment: [], goods_comment: [],
staffList: [], staffList: [],
goods_comment_total: 0, goods_comment_total: 0,
rules: [] rules: [],
priceType: PriceEnum.CUSTOMER_PRICE,
maxPrice: 0,
minPrice: 0
}) })
const userStore = useUserStore() const userStore = useUserStore()
const appStore = useAppStore() const appStore = useAppStore()

View File

@ -14,7 +14,7 @@
></u-image> ></u-image>
<view class="ml-[20rpx] service-text"> <view class="ml-[20rpx] service-text">
<view class="service-text--name truncate"> <view class="service-text--name truncate">
{{ orderInfo.orderGoodsDetailVo.goodsName }} {{ orderInfo.orderGoodsDetailVo?.goodsName }}
</view> </view>
<view class="mt-[16rpx]"> <view class="mt-[16rpx]">
预约时间: {{ orderInfo.appointTime }} {{ orderInfo.weekDay }} 预约时间: {{ orderInfo.appointTime }} {{ orderInfo.weekDay }}

View File

@ -61,7 +61,11 @@
<text class="num">x{{ goodsForm.goods_num }}</text> <text class="num">x{{ goodsForm.goods_num }}</text>
</view> </view>
<view class="mt-[24rpx]"> <view class="mt-[24rpx]">
<price :price="orderData.goodsPrice" :desc="orderData.unitName"></price> <price
:goodsData="orderData"
:priceType="orderData.priceType"
:desc="orderData.unitName"
></price>
</view> </view>
</view> </view>
</view> </view>

View File

@ -70,7 +70,8 @@
</view> </view>
<view class="mt-[24rpx]"> <view class="mt-[24rpx]">
<price <price
:price="orderData.orderGoods?.goodsPrice" :goodsData="orderData.orderGoods"
:priceType="orderData.orderGoods.priceType"
:desc="orderData.orderGoods?.unitName" :desc="orderData.orderGoods?.unitName"
></price> ></price>
</view> </view>