598 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-06-06 13:28:38 +08:00
<div class="addr-manage" @click="goAddressList()">管理地址</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"
2025-06-06 13:28:38 +08:00
:key="item.id"
2025-05-20 13:05:37 +08:00
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">
2025-06-06 13:28:38 +08:00
<div class="region">{{ item.postArea || '--' }}</div>
<div class="addr">{{ item.postAddress || '--' }}</div>
2025-05-20 13:05:37 +08:00
<div class="link-name">
2025-06-06 13:28:38 +08:00
{{ item.receiverName }} {{ item.receiverPhone }} <text v-if="currentAddr == item.id" style="color: #25bf82">当前选中</text>
<!-- <span v-if="item.isEditBtn" class="bj" @click="editAddr(item)">编辑</span> -->
2025-05-20 13:05:37 +08:00
</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">
2025-06-10 13:54:50 +08:00
<!-- <div class="shop-img">
2025-05-20 13:05:37 +08:00
<costomImg
:url="'images/ecommerce/' + 'pic.png'"
:preview-list="[getAssetsFile('images/ecommerce/' + 'pic.png')]"
:is-view="false"
></costomImg>
2025-06-10 13:54:50 +08:00
</div> -->
2025-05-20 13:05:37 +08:00
<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
2025-06-06 13:28:38 +08:00
<div v-if="n.orderItemInfos && n.orderItemInfos.length > 0" class="good-list">
<div v-for="(g, indexg) in n.orderItemInfos" :key="indexg" class="good-item">
2025-05-20 13:05:37 +08:00
<div class="good-img">
2025-06-10 13:54:50 +08:00
<img class="good-img" :url="g.productImage" />
2025-05-20 13:05:37 +08:00
</div>
2025-06-10 13:54:50 +08:00
<!-- :preview-list="[getAssetsFile('images/ecommerce/' + 'pic.png')]" -->
2025-05-20 13:05:37 +08:00
<div class="good-info">
<div class="good-info-pos">
2025-06-06 13:28:38 +08:00
<div class="txt-ellipsis clamp2">{{ g.productName || '--' }}</div>
2025-05-20 13:05:37 +08:00
</div>
</div>
<div class="good-price-num">
<div class="good-price-num-pos">
2025-06-06 13:28:38 +08:00
<div class="price">{{ g.unitPrice }} / {{ g.unit }}</div>
<div class="total">{{ g.unitPrice }}</div>
2025-05-20 13:05:37 +08:00
<div class="num">
<div class="right-item">
2025-06-06 13:28:38 +08:00
<el-input-number v-model="g.quantity" :disabled="true" :min="1">
2025-05-20 13:05:37 +08:00
<template #suffix>
<span>{{ g.unit }}</span>
</template>
</el-input-number>
</div>
</div>
<div class="good-total">
2025-06-06 13:28:38 +08:00
{{ (g.unitPrice * g.quantity).toFixed(2) }}
2025-05-20 13:05:37 +08:00
</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-06-06 13:28:38 +08:00
import { userPostAddress, upOrderInfoList, confirmOrder } from '../../apis/user';
2025-05-20 13:05:37 +08:00
import common from './components/common.vue';
2025-06-06 13:28:38 +08:00
import { ref, reactive, computed, onMounted } from 'vue';
2025-04-14 10:59:16 +08:00
import { isEmpty, getAssetsFile } from '@/utils';
import userHeader from './components/userHeader.vue';
import { useRoute, useRouter } from 'vue-router';
const router = useRouter();
2025-06-06 13:28:38 +08:00
const route = useRoute();
let addrlist = ref([]);
let currentAddr = ref(0);
let total = ref(99);
let orderList = ref([]);
2025-04-14 10:59:16 +08:00
2025-06-06 13:28:38 +08:00
onMounted(() => {
getAddressList();
getOrderInfo();
});
let datalist = ref([
// {
// id: '01',
// shop: '银河生态农产品有限公司',
// shopimg: '',
// ischeck: false,
// orderItemInfos: [
// { 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,
// orderItemInfos: [{ id: '001', title: '勐撒镇 原生态 有机 大白菜', price: 4.9, unit: '份', num: 2, ischeck: false }],
// },
2025-04-14 10:59:16 +08:00
]);
2025-06-06 13:28:38 +08:00
const getAddressList = () => {
userPostAddress().then((res) => {
addrlist.value = res.data.records;
currentAddr.value = addrlist.value[0].id;
console.log(addrlist);
addrlist.value.forEach((item) => {
if (item.isDefault == '1') {
currentAddr.value = item.id;
}
});
});
};
2025-04-14 10:59:16 +08:00
2025-06-06 13:28:38 +08:00
const getOrderInfo = () => {
upOrderInfoList({ id: route.query.id }).then((res) => {
datalist.value = res.data.records;
});
};
const goAddressList = () => {
router.push('/sub-operation-service/addressList');
};
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);
2025-06-06 13:28:38 +08:00
addrlist.value.forEach((item, i) => {
2025-05-20 13:05:37 +08:00
if (index == i) {
item.isEditBtn = data;
}
});
};
//编辑地址
const editAddr = (data) => {
console.log('data', data);
};
2025-04-14 10:59:16 +08:00
const toSureOrder = () => {
2025-06-06 13:28:38 +08:00
confirmOrder({ id: route.query.id, userChooseAddressId: currentAddr.value }).then((res) => {
// router.push('/sub-operation-service/orderSuccess');
router.push({
path: '/sub-operation-service/orderSuccess',
query: { id: route.query.id },
});
// useRouter().push({ path: '/sub-operation-service/orderSuccess' });
});
2025-04-14 10:59:16 +08:00
};
2025-06-06 13:28:38 +08:00
let carriage = ref(0);
2025-04-14 10:59:16 +08:00
let totalAmout = computed(() => {
let num = 0;
let list = [];
2025-06-06 13:28:38 +08:00
if (datalist.value && datalist.value.length > 0) {
list = datalist.value
2025-04-14 10:59:16 +08:00
.map((m) => {
2025-06-06 13:28:38 +08:00
return m.orderItemInfos;
2025-04-14 10:59:16 +08:00
})
.flat();
// console.info('totalAmout**************', list);
if (list && list.length > 0) {
num = list.reduce((acc, current) => {
2025-06-06 13:28:38 +08:00
return acc + current.unitPrice * current.quantity;
2025-04-14 10:59:16 +08:00
}, 0);
}
}
return num;
});
let totalNum = computed(() => {
let num = 0;
let list = [];
2025-06-06 13:28:38 +08:00
if (datalist && datalist.value.length > 0) {
list = datalist.value
2025-04-14 10:59:16 +08:00
.map((m) => {
2025-06-06 13:28:38 +08:00
return m.orderItemInfos;
2025-04-14 10:59:16 +08:00
})
.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;
2025-06-06 13:28:38 +08:00
cursor: pointer;
2025-04-14 10:59:16 +08:00
}
}
.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>