This commit is contained in:
2024-04-16 11:41:18 +08:00
parent 178e8ff5cb
commit 32aa0eb971
8 changed files with 105 additions and 29 deletions

View File

@@ -14,7 +14,13 @@
<view class='goods-info-view c-flex-column' style='margin-right: 10rpx'>
<view class='c-flex-row'>
<text class='goods-price accent-text-color'>{{ goodsBean?.price || 0 }}</text>
<text class='goods-price accent-text-color'>
¥{{ ((goodsBean?.price || 0) * ((userInfo.levelEntity?.discount || 100) / 100)).toFixed(2) }}
<text v-if='userInfo.levelEntity?.discount>0'
style='display:unset;text-decoration: line-through;font-size: 30rpx;color: #999999'>
¥{{ goodsBean?.price || 0 }}
</text>
</text>
<text>销量{{ goodsBean?.send_num || 0 }}</text>
</view>
@@ -49,8 +55,12 @@
:key='index'>
<view class='recommend-item c-flex-column'>
<image :src='item.images||defaultImage' />
<text>{{ item.goodsName||'未知' }}</text>
<text class='goods-price'>{{ item.price }}</text>
<text>{{ item.goodsName || '未知' }}</text>
<text class='goods-price'>{{ (item.price * ((userInfo.levelEntity.discount || 100) / 100)).toFixed(2) }}
<text v-if='userInfo.levelEntity.discount>0'
style='text-decoration: line-through;font-size: 25rpx;color: #999999'>{{ item.price }}
</text>
</text>
</view>
</view>
</scroll-view>
@@ -100,10 +110,14 @@ import { goPath, showToast } from '@/utils';
import { getGoodsDetail, getGoodsList } from '@/api/goods';
import { GoodsBean } from '@/api/goods/types';
import useShoppingCartStore from '@/store/modules/shoppingcart';
import { useUserStore } from '@/store';
const shoppingCartStore = useShoppingCartStore();
const { totalCount } = storeToRefs(shoppingCartStore);
const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);
const goodsBean = ref<GoodsBean>();
const recommendList = ref<GoodsBean[]>();
@@ -216,6 +230,9 @@ const placeOrder = () => {
padding: 20rpx 30rpx;
view:nth-of-type(1) {
display: flex;
flex-direction: row;
text:nth-of-type(1) {
display: flex;
font-size: 40rpx;
@@ -225,10 +242,10 @@ const placeOrder = () => {
}
.goods-price:before {
content: "¥";
font-size: 30rpx;
margin-bottom: 5rpx;
margin-right: 5rpx;
//content: "¥";
//font-size: 30rpx;
//margin-bottom: 5rpx;
//margin-right: 5rpx;
}
text:nth-of-type(2) {

View File

@@ -12,8 +12,12 @@
<view v-for='(item, index) in goodsList' :key='index' class='goods-item'
@click.stop='goPath(`/pages/mall/subs/goods/detail?goodsId=${item.goodsId}`)'>
<image class='goods-image' :src='item.images||defaultImage' />
<text class='goods-name'>{{ item.goodsName||'未知' }}</text>
<text class='goods-price'>¥{{ item.price }}</text>
<text class='goods-name'>{{ item.goodsName || '未知' }}</text>
<text class='goods-price'>¥{{ (item.price * ((userInfo.levelEntity?.discount || 100)/100)).toFixed(2) }}
<text v-if='userInfo.levelEntity?.discount>0'
style='text-decoration: line-through;color: #999999;font-size: 25rpx'>¥{{ item.price }}
</text>
</text>
<image class='add-image' :src='assetsUrl("ic_add_goods.png")' @click.stop='addShoppingCart(item)' />
</view>
</grid-view>
@@ -29,10 +33,14 @@ import { goPath } from '@/utils';
import { getGoodsList } from '@/api/goods';
import useShoppingCartStore from '@/store/modules/shoppingcart';
import { GoodsBean } from '@/api/goods/types';
import { useUserStore } from '@/store';
const skuDialogRef = ref();
const shoppingCartStore = useShoppingCartStore();
const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);
const goodsList = ref<GoodsBean[]>([]);
onLoad((e) => {

View File

@@ -12,7 +12,7 @@
<view class='c-flex-row'>
<image class='checkbox'
:src='assetsUrl(item.checked?"ic_checkbox_active_red.png":"ic_checkbox_normal.png")'
@click.stop='item.checked=!item.checked' />
@click.stop='handleCheck(item)' />
<image class='goods-image' :src='item.images||defaultImage' />
<view class='c-flex-column'>
<text>{{ item.name }}</text>
@@ -24,7 +24,12 @@
<image :src='assetsUrl("ic_arrow_down_gray.png")' />
</view>
</view>
<text style='margin-top: 50rpx'>¥{{ item.price }}</text>
<text style='margin-top: 50rpx'>
¥{{ (item?.price * ((userInfo.levelEntity?.discount || 100) / 100)).toFixed(2) }}
<text v-if='userInfo.levelEntity?.discount>0'
style='text-decoration: line-through;color: #999999;font-size: 25rpx'>¥{{ item?.price }}
</text>
</text>
<view class='count-change-view c-flex-row'>
<view class='count-image' @click.stop='countChange(index,false)'>
<image :src='assetsUrl("ic_reduce.png")' />
@@ -41,7 +46,7 @@
</view>
<view class='bottom-view c-flex-row'>
<view class='c-flex-row' @click.stop='checkedAll = !checkedAll'>
<view class='c-flex-row' @click.stop='handleAllCheck'>
<image :src='assetsUrl(checkedAll?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
<text>全选</text>
</view>
@@ -50,7 +55,7 @@
<text v-if='isEditMode' class='settlement' @click.stop='deleteShoppingCart'>删除</text>
<view v-else class='c-flex-row'>
<text>合计:
<text>¥{{ totalPayPrice }}</text>
<text>¥{{ totalPayPrice.toFixed(2) }}</text>
</text>
<text class='settlement' @click.stop='settlement'>结算</text>
</view>
@@ -67,6 +72,7 @@ import { goPath, showToast } from '@/utils';
import { GoodsBean, StockBean } from '@/api/goods/types';
import SkuDialog from '@/components/sku-dialog.vue';
import { ref } from 'vue';
import { useUserStore } from '@/store';
const isEditMode = ref(false);
const checkedAll = ref(false);
@@ -74,22 +80,37 @@ const checkedAll = ref(false);
const shoppingCartStore = useShoppingCartStore();
const { shoppingCartList, totalCount } = storeToRefs(shoppingCartStore);
const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);
const skuDialogRef = ref();
const temporaryGoodsBean = ref<GoodsBean>();
const temporaryStockBean = ref<StockBean>();
watch(checkedAll, (newValue) => {
shoppingCartList.value.forEach(res => {
res.checked = newValue;
});
const totalPayPrice = computed(() => {
return shoppingCartList.value.filter(res => res.checked).reduce((a, b) => a + b.consumePrice * b.checkedStock.count, 0) || 0;
});
const totalPayPrice = computed(() => {
return shoppingCartList.value.filter(res => res.checked).reduce((a, b) => a + b.consumePrice * b.checkedStock.count, 0);
});
const handleCheck = (item: any) => {
item.checked = !item.checked;
if(!item.checked) {
checkedAll.value = false;
} else {
checkedAll.value = shoppingCartList.value.every(res => res.checked);
}
};
const handleAllCheck = () => {
checkedAll.value = !checkedAll.value;
shoppingCartList.value.forEach(res => {
res.checked = checkedAll.value;
});
};
const deleteShoppingCart = () => {
shoppingCartStore.deleteIfChecked();
checkedAll.value = false;
isEditMode.value = false;
};
const showSkuDialog = (index: number) => {