572 lines
17 KiB
Vue
Raw Normal View History

2025-04-14 10:59:16 +08:00
<template>
2025-05-20 13:05:37 +08:00
<div>
<common current-name="agricultural">
<template #main>
<div class="sure-order-warp">
<userHeader :title="'我的购物车 (' + total + ')'"></userHeader>
<div class="addr-list">
<div class="addr-list-top">
<div class="back">
<el-icon><ArrowLeftBold /></el-icon>
<span>确认收货地址</span>
2025-04-14 10:59:16 +08:00
</div>
2025-05-20 13:05:37 +08:00
<div class="addr-manage">管理地址</div>
2025-04-14 10:59:16 +08:00
</div>
2025-05-20 13:05:37 +08:00
<el-scrollbar>
<div class="scrollbar-flex-content">
<div
v-for="(item, index) in addrlist"
:key="item"
class="addr-item"
:class="currentAddr == item.id ? 'addr-item-act' : 'addr-item-normal'"
@click="selectAddr(item.id)"
@mouseover="hoverAddr(true, index)"
@mouseleave="hoverAddr(false, index)"
>
<div class="addr-item-icon">
<div class="icon-pos">
<div class="iconfont icon-location"></div>
</div>
</div>
<div class="addr-item-info">
<div class="region">{{ item.region || '--' }}</div>
<div class="addr">{{ item.addr || '--' }}</div>
<div class="link-name">
{{ item.linkName }} {{ item.phone }}
<span v-if="item.isEditBtn" class="bj" @click="editAddr(item)">编辑</span>
</div>
</div>
2025-04-14 10:59:16 +08:00
</div>
</div>
2025-05-20 13:05:37 +08:00
</el-scrollbar>
</div>
2025-04-14 10:59:16 +08:00
2025-05-20 13:05:37 +08:00
<div class="order-info">
<div class="order-info-top">确认订单信息</div>
<div class="order-info-list">
<div class="content-item-warp">
<div class="content-item-header">
<div class="header-th first">商品</div>
<div class="header-th other">规格</div>
<div class="header-th other">原价</div>
<div class="header-th other">数量</div>
<div class="header-th other">小计</div>
</div>
<div class="content-item-list">
<div v-for="(n, index) in datalist" :key="index" class="content-item">
<div class="shop-info">
<div class="shop-img">
<costomImg
:url="'images/ecommerce/' + 'pic.png'"
:preview-list="[getAssetsFile('images/ecommerce/' + 'pic.png')]"
:is-view="false"
></costomImg>
</div>
<span class="shop-name txt-ellipsis clamp2">{{ n.shop }}</span>
2025-04-14 10:59:16 +08:00
</div>
2025-05-20 13:05:37 +08:00
<div v-if="n.goodlist && n.goodlist.length > 0" class="good-list">
<div v-for="(g, indexg) in n.goodlist" :key="indexg" class="good-item">
<div class="good-img">
<costomImg
:url="'images/ecommerce/' + 'pic.png'"
:preview-list="[getAssetsFile('images/ecommerce/' + 'pic.png')]"
:is-view="false"
></costomImg>
</div>
<div class="good-info">
<div class="good-info-pos">
<div class="txt-ellipsis clamp2">{{ g.title || '--' }}</div>
</div>
</div>
<div class="good-price-num">
<div class="good-price-num-pos">
<div class="price">{{ g.price }} / {{ g.unit }}</div>
<div class="total">{{ g.price }}</div>
<div class="num">
<div class="right-item">
<el-input-number v-model="g.num" :min="1">
<template #suffix>
<span>{{ g.unit }}</span>
</template>
</el-input-number>
</div>
</div>
<div class="good-total">
{{ (g.price * g.num).toFixed(2) }}
</div>
</div>
2025-04-14 10:59:16 +08:00
</div>
</div>
</div>
</div>
</div>
2025-05-20 13:05:37 +08:00
<div class="content-item-bottom">
<div class="num-total">
<span class="num-val">{{ totalNum }}</span
>件商品
</div>
<div class="price-total">
<div class="amount cost-item">
<span>商品总价</span>
<span class="coat-val">{{ totalAmout.toFixed(2) }}</span>
</div>
<div class="freight cost-item">
<span>运费</span>
<span class="coat-val">{{ carriage.toFixed(2) }}</span>
</div>
</div>
</div>
</div>
2025-04-14 10:59:16 +08:00
</div>
2025-05-20 13:05:37 +08:00
<div class="order-bottom">
<div class="bottom-total">
<span class="tips">实付款</span>
<span class="total">{{ (totalAmout + carriage).toFixed(2) }}</span>
2025-04-14 10:59:16 +08:00
</div>
2025-05-20 13:05:37 +08:00
<div class="bottom-do">
<el-button type="primary" @click="toSureOrder">提交订单</el-button>
2025-04-14 10:59:16 +08:00
</div>
</div>
</div>
</div>
2025-05-20 13:05:37 +08:00
</template>
</common>
2025-04-14 10:59:16 +08:00
</div>
</template>
<script setup>
2025-05-20 13:05:37 +08:00
import common from './components/common.vue';
2025-04-14 10:59:16 +08:00
import { ref, reactive, computed } from 'vue';
import { isEmpty, getAssetsFile } from '@/utils';
import userHeader from './components/userHeader.vue';
import { useRoute, useRouter } from 'vue-router';
const route = useRoute();
const router = useRouter();
const addrlist = reactive([
2025-05-20 13:05:37 +08:00
{ id: '001', region: '云南省 昆明市 呈贡区 彩云南路', addr: '星光小区 一单元 1楼 101', linkName: '李先生', phone: '13813575526', isEditBtn: false },
{ id: '002', region: '云南省 昆明市 呈贡区 彩云南路', addr: '星光小区 一单元 1楼 102', linkName: '王先生', phone: '13813575528', isEditBtn: false },
{ id: '003', region: '云南省 昆明市 呈贡区 彩云北路', addr: '星光小区 一单元 1楼 101', linkName: '李女士', phone: '13813575527', isEditBtn: false },
{ id: '004', region: '云南省 昆明市 呈贡区 彩云南路', addr: '星光小区 一单元 1楼 102', linkName: '王女生', phone: '13813565525', isEditBtn: false },
{ id: '005', region: '云南省 昆明市 呈贡区 彩云南路', addr: '星光小区 一单元 1楼 105', linkName: '张女生', phone: '13813565526', isEditBtn: false },
2025-04-14 10:59:16 +08:00
]);
let currentAddr = ref('001');
2025-05-20 13:05:37 +08:00
let total = ref(99);
2025-04-14 10:59:16 +08:00
const selectAddr = (data) => {
currentAddr.value = data;
};
2025-05-20 13:05:37 +08:00
//鼠标移入移出事件
const hoverAddr = (data, index) => {
console.log('data', data, index);
addrlist.forEach((item, i) => {
if (index == i) {
item.isEditBtn = data;
}
});
};
//编辑地址
const editAddr = (data) => {
console.log('data', data);
};
2025-04-14 10:59:16 +08:00
let datalist = reactive([
{
id: '01',
shop: '银河生态农产品有限公司',
shopimg: '',
ischeck: false,
goodlist: [
{ id: '001', title: '耿马镇 原生态 有机 西红柿', price: 4.9, unit: '份', num: 2, ischeck: false },
{ id: '002', title: '耿马镇 原生态 有机 西蓝花', price: 2.6, unit: '份', num: 100, ischeck: false },
],
},
{
id: '02',
shop: '方立生态农产品有限公司',
shopimg: '',
ischeck: false,
goodlist: [{ id: '001', title: '勐撒镇 原生态 有机 大白菜', price: 4.9, unit: '份', num: 2, ischeck: false }],
},
]);
const toSureOrder = () => {
2025-05-20 13:05:37 +08:00
router.push('/sub-operation-service/orderSuccess');
2025-04-14 10:59:16 +08:00
};
let carriage = ref(98);
let totalAmout = computed(() => {
let num = 0;
let list = [];
if (datalist && datalist.length > 0) {
list = datalist
.map((m) => {
return m.goodlist;
})
.flat();
// console.info('totalAmout**************', list);
if (list && list.length > 0) {
num = list.reduce((acc, current) => {
return acc + current.price * current.num;
}, 0);
}
}
return num;
});
let totalNum = computed(() => {
let num = 0;
let list = [];
if (datalist && datalist.length > 0) {
list = datalist
.map((m) => {
return m.goodlist;
})
.flat();
if (list && list.length > 0) {
num = list.reduce((acc, current) => {
return acc + 1;
}, 0);
}
}
return num;
});
</script>
<style lang="scss" scoped>
.sure-order-warp {
width: 100%;
.addr-list {
overflow: hidden;
margin: 16px 0;
2025-05-20 13:05:37 +08:00
padding: 16px;
border-radius: 16px;
background: $color-fff;
2025-04-14 10:59:16 +08:00
.addr-list-top {
display: inline-flex;
justify-content: space-between;
margin-bottom: 16px;
2025-05-20 13:05:37 +08:00
width: 100%;
2025-04-14 10:59:16 +08:00
.back {
font-size: 20px;
.el-icon {
font-size: 30px;
}
.el-icon,
span {
display: inline-block;
vertical-align: middle;
}
}
.addr-manage {
font-size: 20px;
}
}
.scrollbar-flex-content {
display: flex;
width: fit-content;
gap: 16px;
}
.addr-item {
display: inline-flex;
justify-content: flex-start;
2025-05-20 13:05:37 +08:00
padding: 16px 8px;
width: 280px;
2025-04-14 10:59:16 +08:00
border-radius: 16px;
2025-05-20 13:05:37 +08:00
background: $color-fff;
cursor: pointer;
2025-04-14 10:59:16 +08:00
&.addr-item-act {
border: 1px solid $color-main;
.iconfont {
color: $color-main !important;
}
}
&.addr-item-normal {
border: 1px solid $color-da;
}
.addr-item-icon,
.addr-item-info {
display: inline-block;
vertical-align: middle;
2025-05-20 13:05:37 +08:00
text-align: left;
2025-04-14 10:59:16 +08:00
}
.addr-item-icon {
display: inline-flex;
justify-content: center;
flex-direction: column;
.iconfont {
font-size: 20px;
color: $color-666;
}
}
.addr-item-info {
padding-left: 8px;
2025-05-20 13:05:37 +08:00
font-size: 15px;
2025-04-14 10:59:16 +08:00
line-height: 24px;
.region,
.link-name {
color: $color-999;
2025-05-20 13:05:37 +08:00
position: relative;
.bj {
color: #25bf82;
position: absolute;
right: 0;
}
2025-04-14 10:59:16 +08:00
}
}
}
}
.order-info {
position: relative;
padding: 16px;
2025-05-20 13:05:37 +08:00
width: 100%;
height: calc(100vh - 340px);
border-radius: 16px;
background: $color-fff;
2025-04-14 10:59:16 +08:00
.order-info-top,
.order-bottom,
.order-info-list {
position: absolute;
left: 0;
z-index: 1;
padding: 16px;
2025-05-20 13:05:37 +08:00
width: 100%;
2025-04-14 10:59:16 +08:00
}
.order-info-top {
top: 0;
font-size: 20px;
}
.order-bottom {
bottom: 0;
display: inline-flex;
justify-content: space-between;
.bottom-total,
.bottom-do {
display: inline-block;
vertical-align: middle;
}
.bottom-total {
.tips,
.total {
display: inline-block;
vertical-align: middle;
}
.tips {
font-size: 30px;
}
.total {
2025-05-20 13:05:37 +08:00
padding-left: 16px;
2025-04-14 10:59:16 +08:00
font-size: 42px;
color: $color-main;
}
.total::before {
content: '¥';
}
}
.bottom-do {
display: inline-flex;
2025-05-20 13:05:37 +08:00
justify-content: center;
flex-direction: column;
2025-04-14 10:59:16 +08:00
::v-deep() {
.el-button {
2025-05-20 13:05:37 +08:00
display: inline-block !important;
2025-04-14 10:59:16 +08:00
padding: 0 40px !important;
height: 42px !important;
2025-05-20 13:05:37 +08:00
font-size: 18px !important;
line-height: 42px !important;
2025-04-14 10:59:16 +08:00
}
}
}
}
.order-info-list {
2025-05-20 13:05:37 +08:00
position: relative;
2025-04-14 10:59:16 +08:00
top: 60px;
left: 16px;
padding: 16px;
2025-05-20 13:05:37 +08:00
width: calc(100% - 32px);
height: calc(100% - 150px);
2025-04-14 10:59:16 +08:00
border-radius: 16px;
2025-05-20 13:05:37 +08:00
background: $color-f5;
2025-04-14 10:59:16 +08:00
.content-item-warp {
position: relative;
2025-05-20 13:05:37 +08:00
width: 100%;
height: 100%;
2025-04-14 10:59:16 +08:00
.content-item-header {
2025-05-20 13:05:37 +08:00
position: absolute;
top: 0;
left: 0;
2025-04-14 10:59:16 +08:00
display: inline-flex;
justify-content: flex-start;
2025-05-20 13:05:37 +08:00
width: 100%;
2025-04-14 10:59:16 +08:00
gap: 16px;
.header-th {
display: inline-block;
2025-05-20 13:05:37 +08:00
margin-bottom: 16px;
font-size: 20px;
color: $color-999;
2025-04-14 10:59:16 +08:00
vertical-align: middle;
line-height: 32px;
&.first {
width: 340px;
text-align: left;
}
&.other {
width: calc((100% - 340px) / 4);
text-align: center;
}
}
}
.content-item-list {
2025-05-20 13:05:37 +08:00
position: absolute;
2025-04-14 10:59:16 +08:00
top: 48px;
left: 0;
overflow-y: auto;
2025-05-20 13:05:37 +08:00
width: 100%;
2025-04-14 10:59:16 +08:00
height: calc(100% - 100px);
}
.content-item {
margin-bottom: 16px;
2025-05-20 13:05:37 +08:00
width: 100%;
2025-04-14 10:59:16 +08:00
cursor: pointer;
.shop-info {
display: inline-flex;
justify-content: flex-start;
2025-05-20 13:05:37 +08:00
width: 100%;
2025-04-14 10:59:16 +08:00
gap: 16px;
.shop-do,
.shop-img,
.shop-name {
display: inline-block;
vertical-align: middle;
}
.shop-img {
display: inline-flex;
justify-content: center;
2025-05-20 13:05:37 +08:00
width: 32px;
height: 32px;
2025-04-14 10:59:16 +08:00
border-radius: 4px;
2025-05-20 13:05:37 +08:00
flex-direction: column;
2025-04-14 10:59:16 +08:00
}
.shop-do {
display: inline-flex;
justify-content: center;
2025-05-20 13:05:37 +08:00
width: 30px;
flex-direction: column;
2025-04-14 10:59:16 +08:00
}
.shop-name {
width: calc(100% - 62px);
font-size: 18px;
}
}
.good-list {
width: 100%;
.good-item {
display: inline-flex;
justify-content: flex-start;
margin: 8px 0;
2025-05-20 13:05:37 +08:00
padding-left: 16px;
width: 100%;
gap: 16px;
2025-04-14 10:59:16 +08:00
}
.good-do,
.good-img,
.good-info,
.good-price-num {
display: inline-block;
vertical-align: middle;
}
.good-do {
display: inline-flex;
flex-direction: column;
justify-content: center;
.good-do-pos {
}
}
.good-img {
width: 120px;
height: 120px;
}
.good-info {
display: inline-flex;
justify-content: center;
2025-05-20 13:05:37 +08:00
width: 200px;
flex-direction: column;
2025-04-14 10:59:16 +08:00
.good-info-pos {
font-size: 18px;
color: $color-666;
}
}
.good-price-num {
display: inline-flex;
justify-content: center;
2025-05-20 13:05:37 +08:00
width: calc(100% - 340px);
2025-04-14 10:59:16 +08:00
flex-direction: column;
.good-price-num-pos {
display: inline-flex;
justify-content: space-around;
gap: 16px;
.price,
.total {
font-size: 20px;
}
.price {
font-weight: 400;
}
.total {
font-weight: 700;
2025-05-20 13:05:37 +08:00
color: $color-main;
2025-04-14 10:59:16 +08:00
}
.total::before {
content: '¥';
}
.good-total {
font-size: 16px;
2025-05-20 13:05:37 +08:00
color: $color-main;
2025-04-14 10:59:16 +08:00
}
}
}
}
}
.content-item-bottom {
position: absolute;
bottom: -8px;
2025-05-20 13:05:37 +08:00
left: 0;
2025-04-14 10:59:16 +08:00
z-index: 2;
display: inline-flex;
justify-content: space-between;
2025-05-20 13:05:37 +08:00
width: 100%;
line-height: 48px;
2025-04-14 10:59:16 +08:00
.num-total,
.price-total {
display: inline-block;
vertical-align: middle;
font-size: 20px;
.cost-item {
display: inline-block;
margin: 0 16px;
.coat-val::before {
content: '¥';
}
}
}
.num-total {
.num-val {
padding: 0 8px;
font-size: 24px;
font-weight: bold;
2025-05-20 13:05:37 +08:00
color: $color-main;
2025-04-14 10:59:16 +08:00
}
}
}
}
}
}
}
</style>