purchase-let/components/goodPopup.vue

141 lines
3.3 KiB
Vue
Raw Normal View History

2024-04-29 18:14:58 +08:00
<template>
2024-05-07 17:27:36 +08:00
<up-popup :show="show" closeable round="10" @close="close" :safeAreaInsetBottom="false">
2024-04-29 18:14:58 +08:00
<view class="good-popup">
2024-04-30 16:24:55 +08:00
<view class="head-title">
{{datas.is_bulk ? '称重商品' : '计件商品'}}
</view>
2024-04-29 18:14:58 +08:00
<view class="row">
<view>商品名称</view>
<view>{{datas.name || datas.goods_name}}</view>
</view>
<view class="row">
<view>商品单位</view>
<view>{{datas.unit_name}}</view>
</view>
<view class="row">
<view>商品价格</view>
<view>¥ {{datas.sell}}</view>
</view>
<view class="row">
<view>小计</view>
<view style="color: #F55726;">¥ {{subtotal}}</view>
</view>
2024-05-07 17:27:36 +08:00
<view v-if="datas.is_bulk" class="row">
2024-05-07 19:02:43 +08:00
<view>购买重量<text style="color: #F55726;">*</text></view>
2024-05-07 17:27:36 +08:00
<view style="flex: 1;">
2024-05-07 19:02:43 +08:00
<up-input v-model="datas.cart_num" type="number" border="none" placeholder="请输入购买重量" inputAlign="right"></up-input>
2024-05-07 17:27:36 +08:00
</view>
2024-04-29 18:14:58 +08:00
</view>
2024-05-07 17:27:36 +08:00
<view v-else class="row">
2024-05-07 19:02:43 +08:00
<view>购买数量<text style="color: #F55726;">*</text></view>
2024-05-07 17:27:36 +08:00
<view style="flex: 1;">
2024-05-07 19:02:43 +08:00
<up-input v-model="datas.cart_num" type="number" border="none" placeholder="请输入购买数量" inputAlign="right"></up-input>
2024-05-07 17:27:36 +08:00
</view>
2024-04-29 18:14:58 +08:00
</view>
2024-05-07 17:27:36 +08:00
<view class="row" style="padding-top: 30px;padding-bottom: 30rpx;">
2024-04-29 18:14:58 +08:00
<view style="width: 30%;margin-right: 30rpx;">
2024-05-07 17:27:36 +08:00
<up-button @click="close" color="#f7f7f7"><text style="color: #333;">取消</text></up-button>
2024-04-29 18:14:58 +08:00
</view>
<view style="flex: 1;">
2024-05-07 17:27:36 +08:00
<up-button @click="change" color="#20b128">确定</up-button>
2024-04-29 18:14:58 +08:00
</view>
</view>
</view>
</up-popup>
</template>
<script setup>
import { computed, ref } from "vue"
2024-05-07 19:02:43 +08:00
import { toast } from "../uni_modules/uview-plus";
2024-04-29 18:14:58 +08:00
const props = defineProps({
show: {
type: Boolean,
default: false
},
})
const datas = ref({
cart_num: ''
});
const setData = (e)=>{
datas.value = e;
}
const emit = defineEmits(['close', 'change']);
const close = () => {
emit('close');
}
const change = () => {
2024-05-07 19:02:43 +08:00
if(subtotal.value<=0) {
uni.$u.toast('金额不可小于等于0');
datas.value.cart_num = '';
return ;
}
2024-04-29 18:14:58 +08:00
emit('change', datas.value);
}
const subtotal = computed(()=>{
let num = +datas.value.cart_num || 0;
let sell = +datas.value.sell;
return Math.ceil(num * sell * 100) / 100
})
defineExpose({
setData
})
</script>
<style scoped lang="scss">
.good-popup {
padding: 30rpx;
.head-title {
font-weight: bold;
text-align: center;
margin-bottom: 20rpx;
}
.row {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #f6f6f6;
margin-bottom: 20rpx;
&:last-child {
border-bottom: none;
margin-bottom: 0;
}
.content {
.top {
display: flex;
view {
margin-right: 20rpx;
}
}
.bottom {}
}
image {
width: 40rpx;
height: 40rpx;
flex-shrink: 0;
}
}
}
@keyframes disappear {
to {
opacity: 0;
/* 渐隐 */
transform: scale(0);
/* 缩小 */
}
}
</style>