Compare commits

...

4 Commits

6 changed files with 65 additions and 55 deletions

View File

@ -6,50 +6,35 @@
</view>
<view class="row">
<view>商品名称</view>
<view>{{ datas.name || datas.goods_name || datas.store_name }}</view>
</view>
<view class="row" v-if="datas.store_info">
<view>商品规格</view>
<view>{{ datas.store_info}}</view>
</view>
<view class="row">
<view>商品单位</view>
<view >{{ datas.unit_name }}
</view>
</view>
<view class="row">
<view>商品价格</view>
<view>¥ {{priceKey.off_activity==1? datas[priceKey.price]: datas[priceKey.op_price] }} /
{{ datas.unit_name }}
</view>
</view>
<view class="row" v-if="datas.batch > 0">
<view>起批量</view>
<view>{{ datas.batch }}{{ datas.unit_name }}起批 </view>
<view>{{ datas.sku_name}}</view>
</view>
<view class="row">
<view>小计</view>
<view style="color: #F55726;" v-if="+datas.cart_num < +datas.batch">
{{ `${datas.batch}${datas.unit_name}起批` }}
</view>
<view style="color: #F55726;" v-else>¥ {{ subtotal }}</view>
<view style="border-bottom: 1rpx solid #f6f6f6;margin-bottom: 0.625rem;padding-bottom: 0.625rem;">
<view class="u-page__tag-item" v-for="(item, index) in attr_value" :key="index">
<up-tag :text="item.sku_name" :plain="checkedProduct!=index" type="success" :name="index"
@click="radioClick" size="large">
</up-tag>
</view>
</view>
<!-- <view class="row">
<view>商品价格</view>
<view>¥ {{price}}/
</view>
</view> -->
<!-- <view class="row" v-if="datas.batch > 0">
<view>起批量</view>
<view>{{ datas.batch }}{{ datas.unit_name }}起批 </view>
</view> -->
<view v-if="datas.is_bulk" class="row" style="height: 100rpx;">
<view>购买重量<text style="color: #F55726;">*</text></view>
<view style="justify-content: end;">
<up-input
type="digit"
placeholder="请输入重量"
border="surround"
v-model="datas.cart_num"
@change="valChange"
style="width: 100rpx;"
>
<template #suffix>
<span>{{ datas.unit_name }}</span>
</template>
</up-input>
<up-input type="digit" placeholder="请输入重量" border="surround" v-model="datas.cart_num"
@change="valChange" style="width: 100rpx;">
<!-- <template #suffix>
<span>{{ datas.unit_name }}</span>
</template> -->
</up-input>
<!-- <up-number-box :min="0.1" :step="0.1" v-model="datas.cart_num" @change="valChange"></up-number-box> -->
</view>
</view>
@ -59,6 +44,13 @@
<up-number-box :min="0" v-model="datas.cart_num" @change="valChange"></up-number-box>
</view>
</view>
<view class="row">
<view>小计</view>
<view style="color: #F55726;" v-if="+datas.cart_num < +datas.batch">
{{ `${datas.batch}${datas.unit_name}起批` }}
</view>
<view style="color: #F55726;" v-else>¥ {{ subtotal }}</view>
</view>
<view class="row" style="padding-top: 30px;padding-bottom: 30rpx;">
<view style="width: 30%;margin-right: 30rpx;">
<up-button @click="close" color="#f7f7f7"><text style="color: #333;">取消</text></up-button>
@ -79,6 +71,8 @@
} from "vue"
const foucs1 = ref(null)
const checkedProduct = ref(0)
const price = ref(0)
const props = defineProps({
show: {
type: Boolean,
@ -98,10 +92,12 @@
const datas = ref({
cart_num: ''
});
const attr_value = ref({});
const setData = (e) => {
datas.value = e;
if (Number(e.batch) > 0) {
datas.value.cart_num = e.batch;
datas.value = e.attr_value[0]
attr_value.value = e.attr_value
if (Number(e.attr_value[0].batch) > 0) {
datas.value.cart_num = e.attr_value[0].batch;
} else {
datas.value.cart_num = 1;
}
@ -112,7 +108,15 @@
const close = () => {
emit('close');
}
const radioClick = (key) => {
checkedProduct.value = key
datas.value = attr_value.value[key]
if (Number(datas.value.batch) > 0) {
datas.value.cart_num = datas.value.batch;
} else {
datas.value.cart_num = 1;
}
};
const change = () => {
if (+datas.value.cart_num < +datas.value.batch) return uni.$u.toast(
`购买数量不能小于${datas.value.batch}${datas.value.unit_name}`);
@ -195,4 +199,9 @@
/* 缩小 */
}
}
.u-page__tag-item {
display: inline-block;
margin-right: 10rpx;
}
</style>

View File

@ -33,7 +33,7 @@
<view class="shop-content">
<view class="title">
<view class="name u-line-2">{{item.goods_name}}</view>
<view class="tip u-line-1">{{item.unit_name}}</view>
<view class="tip u-line-1">{{item.sku_name}}</view>
<view v-if="priceKey.off_activity==1" class="tip u-line-1">原价<text
style="text-decoration: line-through;">{{item[priceKey.op_price]}}</text>
</view>
@ -41,7 +41,7 @@
<view class="price-btn">
<view class="price">{{item[priceKey.price]}}</view>
<view class="btn">
<view class="num">{{item.cart_num}}</view>
<view class="num">{{item.cart_num}}/{{item.unit_name}}</view>
<u--icon name="plus-circle-fill" size="20" color="#20b128"></u--icon>
</view>
</view>

View File

@ -447,7 +447,7 @@
getGoodList();
}
const addCart = (product_id, cart_num) => { //
const addCart = (product_id, cart_num,attr_value_id) => { //
console.log("触发了加入购物车")
cartCreateApi({
@ -456,7 +456,8 @@
is_new: 0, // 01
// goods_id: id,
store_id: STORE_INFO.id,
product_id: product_id
product_id: product_id,
attr_value_id:attr_value_id
}).then(res => {
getCartList();
}).catch(err => {
@ -688,7 +689,7 @@
});
console.log('data', data)
addCart(data.product_id, data.cart_num);
addCart(data.product_id, data.cart_num,data.id);
}

View File

@ -97,7 +97,7 @@
<view>¥{{item.price}}</view>
</view>
<view class="tips">
<view>{{}}</view>
<view>{{item.sku_name}}</view>
<view>x{{item.nums}}{{item.unit_name}}</view>
</view>
</view>

View File

@ -19,19 +19,19 @@
<image class="image" :src="item.image"></image>
<view style="width: 520rpx;">
<view class="" style="display: flex;justify-content: space-between;">
<view>
<view style="color: black;font-size: 30rpx;">
{{item.store_name}}
</view>
<view style="font-size: 32rpx;">
<view style="font-size: 24rpx;">
{{item.price}}
</view>
</view>
<view class="" style="display: flex;justify-content: space-between;">
<view>
{{item.unit_name}}
{{item.sku_name}}
</view>
<view style="font-size: 32rpx;">
x{{item.cart_num}}
<view style="font-size: 24rpx;">
x{{item.cart_num}}/{{item.unit_name}}
</view>
</view>
</view>

View File

@ -43,8 +43,8 @@
<view>¥{{ item.price }}</view>
</view>
<view class="tips">
<view>{{ item.unit_name }}</view>
<view>x{{ item.cart_num }}</view>
<view>{{ item.sku_name }}</view>
<view>x{{ item.cart_num }}/{{ item.unit_name }}</view>
</view>
</view>
<view class="time">