cashier_app/pagesCreateOrder/index/components/list-goods-item.vue

177 lines
3.4 KiB
Vue

<template>
<view class="u-relative u-flex item">
<up-image :src="data.coverImg" mode="aspectFill" :width="img.width" :height="img.height"></up-image>
<view class="info u-flex u-row-between u-col-top u-flex-col">
<view>
<view>
<text class="u-line-2">{{data.name}}</text>
</view>
<view class="u-font-32 font-bold u-m-t-16">
{{data.lowPrice}}
</view>
<template v-if="data.type=='weight'">
<view class="btnweigh">称重</view>
</template>
</view>
<view class="u-flex">
<template v-if="!isSellout">
<template v-if="data.type == 'sku'||data.groupType==1">
<button class="btn" hover-class="btn-hover-class" @tap="emitEvent('chooseGuige')">选规格</button>
</template>
<template v-else>
<view class="u-flex icon-btn">
<view class="u-flex" @tap.stop="emitEvent(data.type=='weight'?'tapweigh':'add')">
<image src="/pagesCreateOrder/static/images/icon-add.svg" class="icon" mode=""></image>
</view>
<template v-if="data.chooseNumber">
<view class="u-font-32">
{{(data.chooseNumber).toFixed(2)}}
</view>
<view class="u-flex" @tap.stop="emitEvent('reduce')">
<image src="/pagesCreateOrder/static/images/icon-reduce.svg" class="icon" mode="">
</image>
</view>
</template>
</view>
</template>
</template>
<template v-else>
<view class=" u-m-t-16">
已售罄
</view>
</template>
</view>
</view>
</view>
</template>
<script setup>
import {
computed,
toRef,
toRefs,
watch
} from 'vue';
import util from '../util.js';
const props = defineProps({
img: {
type: Object,
default: {
width: '250rpx',
height: '272rpx'
}
},
index: {
type: [Number, String],
},
isSeatFee: {
//是否为餐位费
type: Boolean,
default: false
},
data: {
type: Object,
default: () => {
return {
chooseNumber: 0
}
}
}
})
/**
* 判断是否是菜品
*/
function isGoods() {
return props.data.hasOwnProperty('id')
}
/**
* 判断商品是否售尽
*/
const isSellout = computed(() => {
const item = props.data
if (!isGoods()) {
return false
}
return (
item.isPauseSale || (item.type !== "sku" && item.isStock == 1 && item.stockNumber <= 0)
);
})
const emits = defineEmits(['add', 'reduce', 'chooseGuige','tapweigh'])
function emitEvent(emitName) {
if (isGoods()) {
emits(emitName, props.index)
}
}
</script>
<style lang="scss" scoped>
.icon {
width: 48rpx;
height: 48rpx;
}
.icon-btn {
gap: 14rpx;
}
.btn {
background: #EB4F4F;
border-radius: 100rpx;
font-size: 28rpx;
height: 56rpx;
line-height: 56rpx;
color: #fff;
}
.btnweigh {
margin: 5rpx 0;
width: 100rpx;
background: linear-gradient(124deg, #73c969 6%, #27921b 93%);
border-radius: 10rpx;
font-size: 24rpx;
padding: 6rpx 0;
text-align: center;
}
.btn-hover-class {
opacity: .6;
}
image {
will-change: transform
}
.item {
// width: 250rpx;
// height: 272rpx;
background: #F9B798;
border-radius: 8rpx 8rpx 8rpx 8rpx;
overflow: hidden;
.img {
width: 250rpx;
height: 272rpx;
}
.info {
position: absolute;
left: 0;
right: 0;
bottom: 0;
color: #fff;
padding: 32rpx 24rpx 24rpx 24rpx;
top: 0;
background: rgba(37, 22, 15, 0.5);
border-radius: 8rpx 8rpx 8rpx 8rpx;
overflow: hidden;
}
}
</style>