更新起批量, 修复价格bug
This commit is contained in:
parent
bb6210fd7a
commit
558b7a04ea
|
@ -1,153 +1,160 @@
|
||||||
<template>
|
<template>
|
||||||
<up-popup :show="show" closeable round="10" @close="close" :safeAreaInsetBottom="false">
|
<up-popup :show="show" closeable round="10" @close="close" :safeAreaInsetBottom="false">
|
||||||
<view class="good-popup">
|
<view class="good-popup">
|
||||||
<view class="head-title">
|
<view class="head-title">
|
||||||
{{datas.is_bulk ? '称重商品' : '计件商品'}}
|
{{datas.is_bulk ? '称重商品' : '计件商品'}}
|
||||||
</view>
|
</view>
|
||||||
<view class="row">
|
<view class="row">
|
||||||
<view>商品名称</view>
|
<view>商品名称</view>
|
||||||
<view>{{datas.name || datas.goods_name || datas.store_name}}</view>
|
<view>{{datas.name || datas.goods_name || datas.store_name}}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="row">
|
<view class="row">
|
||||||
<view>商品单位</view>
|
<view>商品单位</view>
|
||||||
<view>{{datas.unit_name}}</view>
|
<view>{{datas.unit_name}}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="row">
|
<view class="row">
|
||||||
<view>商品价格</view>
|
<view>商品价格</view>
|
||||||
<view>¥ {{datas.sell}}</view>
|
<view>¥ {{datas.price}}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="row">
|
<view class="row">
|
||||||
<view>小计</view>
|
<view>小计</view>
|
||||||
<view style="color: #F55726;">¥ {{subtotal}}</view>
|
<view style="color: #F55726;" v-if="+datas.cart_num<+datas.batch">
|
||||||
</view>
|
{{`${datas.batch}${datas.unit_name}起批`}}
|
||||||
<view v-if="datas.is_bulk" class="row">
|
</view>
|
||||||
<view>购买重量<text style="color: #F55726;">*</text></view>
|
<view style="color: #F55726;" v-else>¥ {{subtotal}}</view>
|
||||||
<view style="flex: 1;">
|
</view>
|
||||||
<up-input v-model="datas.cart_num" :cursorSpacing='120' type="number" border="none"
|
<view v-if="datas.is_bulk" class="row">
|
||||||
placeholder="请输入购买重量" inputAlign="right"></up-input>
|
<view>购买重量<text style="color: #F55726;">*</text></view>
|
||||||
</view>
|
<view style="flex: 1;">
|
||||||
</view>
|
<up-input v-model="datas.cart_num" :cursorSpacing='120' type="number" border="none"
|
||||||
<view v-else class="row">
|
placeholder="请输入购买重量" inputAlign="right"></up-input>
|
||||||
<view>购买数量<text style="color: #F55726;">*</text></view>
|
</view>
|
||||||
<view style="flex: 1;">
|
</view>
|
||||||
<up-input v-model="datas.cart_num" :cursorSpacing='120' type="number" border="none"
|
<view v-else class="row">
|
||||||
placeholder="请输入购买数量" inputAlign="right">
|
<view>购买数量<text style="color: #F55726;">*</text></view>
|
||||||
<template #suffix>
|
<view style="flex: 1;">
|
||||||
<span style="color: #20b128;">{{datas.unit_name}}</span>
|
<up-input v-model="datas.cart_num" :cursorSpacing='120' type="number" border="none"
|
||||||
</template>
|
placeholder="请输入购买数量" inputAlign="right">
|
||||||
</up-input>
|
<template #suffix>
|
||||||
</view>
|
<span style="color: #20b128;">{{datas.unit_name}}</span>
|
||||||
</view>
|
</template>
|
||||||
<view class="row" style="padding-top: 30px;padding-bottom: 30rpx;">
|
</up-input>
|
||||||
<view style="width: 30%;margin-right: 30rpx;">
|
</view>
|
||||||
<up-button @click="close" color="#f7f7f7"><text style="color: #333;">取消</text></up-button>
|
</view>
|
||||||
</view>
|
<view class="row" style="padding-top: 30px;padding-bottom: 30rpx;">
|
||||||
<view style="flex: 1;">
|
<view style="width: 30%;margin-right: 30rpx;">
|
||||||
<up-button @click="change" color="#20b128">确定</up-button>
|
<up-button @click="close" color="#f7f7f7"><text style="color: #333;">取消</text></up-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
<view style="flex: 1;">
|
||||||
</view>
|
<up-button @click="change" color="#20b128">确定</up-button>
|
||||||
</up-popup>
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</up-popup>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
computed,
|
computed,
|
||||||
ref
|
ref
|
||||||
} from "vue"
|
} from "vue"
|
||||||
import {
|
import {
|
||||||
toast
|
toast
|
||||||
} from "../uni_modules/uview-plus";
|
} from "../uni_modules/uview-plus";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
show: {
|
show: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const datas = ref({
|
const datas = ref({
|
||||||
cart_num: ''
|
cart_num: ''
|
||||||
});
|
});
|
||||||
const setData = (e) => {
|
const setData = (e) => {
|
||||||
console.log(e)
|
console.log(e);
|
||||||
datas.value = e;
|
datas.value = e;
|
||||||
}
|
if (e.batch) datas.value.cart_num = e.batch;
|
||||||
|
else datas.value.cart_num = '';
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['close', 'change']);
|
const emit = defineEmits(['close', 'change']);
|
||||||
const close = () => {
|
const close = () => {
|
||||||
emit('close');
|
emit('close');
|
||||||
}
|
}
|
||||||
|
|
||||||
const change = () => {
|
const change = () => {
|
||||||
if (subtotal.value <= 0) {
|
if (+datas.value.cart_num < +datas.value.batch) return uni.$u.toast(
|
||||||
uni.$u.toast('金额不可小于等于0');
|
`购买数量不能小于${datas.value.cart_num}${datas.value.unit_name}`);
|
||||||
datas.value.cart_num = '';
|
if (subtotal.value <= 0) {
|
||||||
return;
|
uni.$u.toast('金额不可小于等于0');
|
||||||
}
|
datas.value.cart_num = '';
|
||||||
emit('change', datas.value);
|
return;
|
||||||
}
|
}
|
||||||
|
emit('change', datas.value);
|
||||||
|
}
|
||||||
|
|
||||||
const subtotal = computed(() => {
|
const subtotal = computed(() => {
|
||||||
let num = +datas.value.cart_num || 0;
|
let num = +datas.value.cart_num || 0;
|
||||||
let sell = +datas.value.sell || datas.value.price;
|
let sell = +datas.value.sell || datas.value.price;
|
||||||
return Math.ceil(num * sell * 100) / 100
|
return Math.ceil(num * sell * 100) / 100
|
||||||
})
|
})
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
setData
|
setData
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.good-popup {
|
.good-popup {
|
||||||
padding: 30rpx;
|
padding: 30rpx;
|
||||||
|
|
||||||
.head-title {
|
.head-title {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding-bottom: 20rpx;
|
padding-bottom: 20rpx;
|
||||||
border-bottom: 1rpx solid #f6f6f6;
|
border-bottom: 1rpx solid #f6f6f6;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
.top {
|
.top {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
view {
|
view {
|
||||||
margin-right: 20rpx;
|
margin-right: 20rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.bottom {}
|
.bottom {}
|
||||||
}
|
}
|
||||||
|
|
||||||
image {
|
image {
|
||||||
width: 40rpx;
|
width: 40rpx;
|
||||||
height: 40rpx;
|
height: 40rpx;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes disappear {
|
@keyframes disappear {
|
||||||
to {
|
to {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
/* 渐隐 */
|
/* 渐隐 */
|
||||||
transform: scale(0);
|
transform: scale(0);
|
||||||
/* 缩小 */
|
/* 缩小 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue