697 lines
21 KiB
Vue
Raw Normal View History

2025-04-09 17:25:08 +08:00
<template>
<div class="agricultural-detail-warp">
<common current-name="agricultural">
<template #main>
<div class="agricultural-detail-info">
<div class="top-title">
<div class="father-title" @click="toBack(-1)">
2025-05-30 15:57:50 +08:00
<el-icon><ArrowLeftBold /></el-icon>商品信息
</div>
2025-04-09 17:25:08 +08:00
<div class="current-title">查看详情</div>
</div>
<div class="top-info">
<el-row :gutter="16">
<el-col :span="12">
2025-05-27 11:58:55 +08:00
<banner
v-if="currentGood.goodUrls.length > 0"
2025-05-27 11:58:55 +08:00
name="landdetail"
:imglist="currentGood.goodUrls"
:is-montage="false"
2025-05-27 11:58:55 +08:00
indicator-pos="none"
arrow="always"
height="340px"
:is-view="true"
>
</banner>
2025-04-09 17:25:08 +08:00
</el-col>
<el-col :span="12" class="top-info-txt">
<h1 class="title">{{ currentGood.goodName }}</h1>
2025-04-09 17:25:08 +08:00
<div class="price-sold">
<span class="price">{{ currentPrice }}</span>
<span class="sold">{{ currentGood.salesVolume }}</span>
2025-04-09 17:25:08 +08:00
</div>
<div class="tips-list">
<el-row :gutter="16">
<el-col :span="24">发货地址{{ currentGood.detailAddress }}</el-col>
<el-col :span="24"
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{
currentGood.safeguard ? currentGood.safeguard.options[0].text : ''
}}</el-col
>
2025-04-09 17:25:08 +08:00
</el-row>
</div>
<div class="spu-sku-list">
<div class="spu-title">规格</div>
<div class="spu-sku-warp">
2025-05-27 11:58:55 +08:00
<div
v-for="(item, index) in currentGood.netWeight"
:key="index"
2025-05-27 11:58:55 +08:00
class="spu-sku-item"
:class="[index === currentWeight ? 'act' : 'normal']"
@click="currentWeight = index"
2025-05-27 11:58:55 +08:00
>
2025-06-09 10:59:28 +08:00
{{ item.goodSpecs }}{{ item.unit }}
2025-05-27 11:58:55 +08:00
</div>
2025-04-09 17:25:08 +08:00
</div>
<div class="goods-num">
<div class="num-title">数量</div>
<div class="num-warp">
<el-input-number v-model="saveInfo.num" :min="1" :max="10" />
2025-06-09 10:59:28 +08:00
<span v-if="currentStock !== 0" class="is-have">有货: {{ currentStock }}</span>
<span v-else class="is-have">售罄</span>
2025-04-09 17:25:08 +08:00
</div>
</div>
</div>
<div class="top-btn">
<div class="item-btn sign">
<span>立即购买</span>
</div>
<div class="item-btn reservation">
<span>加入购物车</span>
</div>
</div>
</el-col>
</el-row>
<signProcess></signProcess>
</div>
<div class="agricultural-detail-content">
<div class="detail-content">
<div class="tab-top">
<el-radio-group v-model="tabVal">
<el-radio-button v-for="(t, indext) in tabList" :key="t.name" :value="t.value">{{ t.label }}</el-radio-button>
</el-radio-group>
</div>
<div class="tab-content">
<div v-if="tabVal === 'detail'" class="content-detail">
<div v-if="showDetail" style="display: flex; justify-content: center">
<el-descriptions class="detail-des" title=" " :column="2" size="large" border>
<el-descriptions-item v-for="item in currentGood.attribute" :key="item.key">
<template #label>
<div class="cell-item">{{ item.value.name }}</div>
</template>
<span>{{ item.value.value }}</span>
</el-descriptions-item>
</el-descriptions>
</div>
2025-05-27 11:58:55 +08:00
<div style="display: flex; justify-content: center; flex-wrap: wrap">
2025-06-09 10:59:28 +08:00
<el-image
v-for="(item, index) in currentGood.detailUrl"
:key="index"
:src="item"
style="width: 90%; margin: 5px 0"
fit="contain"
/>
2025-05-27 11:58:55 +08:00
</div>
2025-04-09 17:25:08 +08:00
</div>
<div v-if="tabVal == 'sourceCode'" class="content-source-code">
<div class="code-warp">
<div class="code-img">
<el-image :src="qrImg" fit="cover" />
</div>
<div class="code-down">
<el-icon><Download /></el-icon>
<a>下载溯源码</a>
</div>
<div class="code-copy">
<div class="code-txt">
<span class="txt-ellipsis clamp1" style="width: 100%">10.5488754215478XE254.10405488754215478XE254201</span>
</div>
<div class="do-copy">
<el-button type="primary" @click="toCopy">复制</el-button>
</div>
</div>
<div class="code-to-detail">
<el-button type="primary" @click="toCodeDetail">点击查看溯源详情</el-button>
</div>
</div>
</div>
<div v-if="tabVal == 'evaluate'" class="content-evaluate">
2025-06-09 10:59:28 +08:00
<evaluate :good-id="goodId" :good-url="currentGood.goodUrls[0]"></evaluate>
2025-04-09 17:25:08 +08:00
</div>
</div>
</div>
</div>
</div>
</template>
</common>
</div>
</template>
<script setup name="ecommerce">
import common from './components/common.vue';
import banner from './components/banner.vue';
import { onMounted, reactive, ref, computed } from 'vue';
2025-05-27 11:58:55 +08:00
import { getAssetsFile } from '@/utils';
2025-04-09 17:25:08 +08:00
import { qrImg } from '@/layouts/component/Header/base64img.js';
import evaluate from './components/evaluate.vue';
2025-04-11 17:32:55 +08:00
import { useRoute, useRouter } from 'vue-router';
import { getGoodDetail } from '@/apis/agricultural.js';
2025-05-27 11:58:55 +08:00
2025-04-11 17:32:55 +08:00
const route = useRoute();
const router = useRouter();
const goodId = route.query.id; // 获取参数
2025-05-27 11:58:55 +08:00
const pId = route.query.pid;
const currentWeight = ref(0);
2025-04-09 17:25:08 +08:00
let bannerList = reactive(['images/ecommerce/' + 'banner.png', 'images/ecommerce/' + 'banner.png']);
const tabList = reactive([
{ label: '详情介绍', value: 'detail' },
{ label: '溯源码', value: 'sourceCode' },
{ label: '评价', value: 'evaluate' },
]);
2025-05-27 11:58:55 +08:00
const currentIndex = ref(0);
const showDetail = ref(true);
2025-05-27 11:58:55 +08:00
const currentGood = ref({
showPic: false,
goodUrls: [],
attribute: [],
});
const currentPrice = computed(() => {
return currentGood.value?.netWeight?.[currentWeight.value]?.goodPrice ?? 0;
});
2025-06-09 10:59:28 +08:00
const currentStock = computed(() => {
return currentGood.value?.netWeight?.[currentWeight.value]?.goodStock ?? 0;
});
2025-05-27 11:58:55 +08:00
const mockData = [
{
goodName: '甜糯玉米种子',
2025-05-27 11:58:55 +08:00
sold: 1200,
price: 25,
sendAddress: '河南信阳',
safeguard: '七天保价',
2025-05-27 11:58:55 +08:00
weight: ['100g', '200g'],
goodUrl: ['images/mockPic/cornTop.png'],
detailUrl: ['cornBottom1.png', 'cornBottom2.png', 'cornBottom3.png', 'cornBottom4.png'],
2025-05-27 11:58:55 +08:00
},
{
goodName: '张塘王豇豆种子种籽',
2025-05-27 11:58:55 +08:00
sold: 1200,
price: 4.35,
sendAddress: '山东潍坊',
safeguard: '七天保价',
2025-05-27 11:58:55 +08:00
weight: ['100粒', '200粒'],
goodUrl: ['images/mockPic/beanTop.png'],
detailUrl: ['beanBottom1.png', 'beanBottom2.png', 'beanBottom3.png', 'beanBottom4.png'],
2025-05-27 11:58:55 +08:00
},
{
goodName: '茄子种子种籽',
2025-05-27 11:58:55 +08:00
sold: 1200,
price: 3.92,
sendAddress: '山东潍坊',
safeguard: '七天保价',
2025-05-27 11:58:55 +08:00
weight: ['100粒', '200粒'],
goodUrl: ['images/mockPic/eggplantTop.png'],
detailUrl: ['eggplantBottom1.png', 'eggplantBottom2.png', 'eggplantBottom3.png', 'eggplantBottom4.png'],
2025-05-27 11:58:55 +08:00
},
{
goodName: '正宗绿贝贝南瓜种籽',
2025-05-27 11:58:55 +08:00
sold: 1200,
price: 6.8,
sendAddress: '安徽马鞍山',
safeguard: '七天保价',
2025-05-27 11:58:55 +08:00
weight: ['10粒', '20粒'],
goodUrl: ['images/mockPic/pumpkinTop.png'],
detailUrl: ['pumpkinBottom1.png', 'pumpkinBottom2.png', 'pumpkinBottom3.png', 'pumpkinBottom4.png'],
2025-05-27 11:58:55 +08:00
},
{
goodName: '复合肥料18-5-7',
2025-05-27 11:58:55 +08:00
sold: 1200,
price: 154,
sendAddress: '浙江金华',
safeguard: '七天保价',
2025-05-27 11:58:55 +08:00
weight: ['25kg', '50kg'],
goodUrl: ['images/mockPic/fertilizerTop.png'],
detailUrl: ['fertilizerBottom1.png', 'fertilizerBottom2.png'],
2025-05-27 11:58:55 +08:00
},
{
goodName: '正宗硫酸钾 农用钾肥',
2025-05-27 11:58:55 +08:00
sold: 1200,
price: 13.5,
sendAddress: '内蒙古',
safeguard: '七天保价',
2025-05-27 11:58:55 +08:00
weight: ['5斤', '10斤'],
goodUrl: ['images/mockPic/KSO4Top.png'],
detailUrl: ['KSO4Bottom1.png', 'KSO4Bottom2.png', 'KSO4Bottom3.png', 'KSO4Bottom4.png'],
2025-05-27 11:58:55 +08:00
},
{
goodName: '噻虫嗪农药',
2025-05-27 11:58:55 +08:00
sold: 1200,
price: 8.6,
sendAddress: '内蒙古',
safeguard: '七天保价',
2025-05-27 11:58:55 +08:00
weight: ['500g'],
goodUrl: ['images/mockPic/pesticideTop.png'],
detailUrl: ['pesticideBottom1.png', 'pesticideBottom2.png', 'pesticideBottom3.png', 'pesticideBottom4.png', 'pesticideBottom5.png'],
2025-05-27 11:58:55 +08:00
},
{
goodName: '11.6%甲维氯笨氣虫苯甲铣胺酰胺笨甲先胺水稻钻心虫农药杀虫剂',
2025-05-27 11:58:55 +08:00
sold: 1200,
price: 35.6,
sendAddress: '山东烟台',
safeguard: '七天保价',
2025-05-27 11:58:55 +08:00
weight: ['500g', '1000g'],
goodUrl: ['images/mockPic/nyTop.png'],
detailUrl: ['nyBottom1.png', 'nyBottom2.png', 'nyBottom3.png', 'nyBottom4.png'],
2025-05-27 11:58:55 +08:00
},
{
goodName: '铁皮石斛种子',
sold: 13,
price: '80/g',
sendAddress: '耿马县',
safeguard: '七天保价',
weight: ['1g', '2g', '5g', '10g'],
goodUrl: ['images/mockPic/shihuTop.png'],
detailUrl: ['shihuBottom0.png', 'shihuBottom1.png', 'shihuBottom2.png', 'shihuBottom3.png'],
},
{
goodName: '黑皮甘蔗苗',
sold: 1400,
price: '0.7/株',
sendAddress: '耿马县',
safeguard: '七天保价',
weight: ['10株', '50株', '200株', '500株'],
goodUrl: ['images/mockPic/ganzheTop.png'],
detailUrl: ['ganzheBottom0.png', 'ganzheBottom1.png', 'ganzheBottom2.png', 'ganzheBottom3.png'],
},
{
goodName: '美人椒种子 -辣椒种子',
sold: 548,
price: '43/斤',
sendAddress: '耿马县',
safeguard: '七天保价',
weight: ['1斤', '2斤'],
goodUrl: ['images/mockPic/chiliTop.png'],
detailUrl: ['chiliBottom0.png', 'chiliBottom1.png', 'chiliBottom2.png', 'chiliBottom3.png'],
},
{
goodName: '四季青种子',
sold: 548,
price: '19.5/包',
sendAddress: '耿马县',
safeguard: '七天保价',
weight: ['1包500-2000粒', '2包', '4包'],
goodUrl: ['images/mockPic/leafyTop.png'],
detailUrl: ['leafyBottom0.png', 'leafyBottom1.png', 'leafyBottom2.png'],
},
{
goodName: '青花菜种子',
sold: 548,
price: '10/包',
sendAddress: '耿马县',
safeguard: '七天保价',
weight: ['1包300-800粒', '2包', '4包'],
goodUrl: ['images/mockPic/broccoliTop.png'],
detailUrl: ['broccoliBottom2.png', 'broccoliBottom1.png', 'broccoliBottom0.png'],
},
{
goodName: '黑叶小白菜种子',
sold: 82,
price: '60/公斤',
sendAddress: '耿马县',
safeguard: '七天保价',
weight: ['1公斤', '2公斤', '5公斤'],
goodUrl: ['images/mockPic/choyTop.png'],
detailUrl: ['choyBottom0.png', 'choyBottom1.png', 'choyBottom2.png', 'choyBottom3.png'],
},
2025-05-27 11:58:55 +08:00
];
2025-04-09 17:25:08 +08:00
let tabVal = ref('detail');
let saveInfo = reactive({
num: 0,
});
2025-05-27 11:58:55 +08:00
onMounted(() => {
showDetail.value = false;
// const num = Number(pId);
getGoodDetail(goodId).then(async (res) => {
currentGood.value = res.data;
// 数据转义
await formattedData(res.data);
showDetail.value = true;
});
// if (num === 55) {
// // 1. 获取前四个元素的索引0, 1, 2, 3
// const allIndices = [0, 1, 2, 3];
// // 2. 随机打乱索引顺序
// const shuffledIndices = [...allIndices].sort(() => Math.random() - 0.5);
// // 3. 选择第一个
// currentIndex.value = shuffledIndices.slice(0, 1)[0];
// } else if (num === 61) {
// // 1. 获取前四个元素的索引0, 1, 2, 3
// const allIndices = [4, 5];
// // 2. 随机打乱索引顺序
// const shuffledIndices = [...allIndices].sort(() => Math.random() - 0.5);
// // 3. 选择第一个
// currentIndex.value = shuffledIndices.slice(0, 1)[0];
// } else if (num === 65) {
// // 1. 获取前四个元素的索引0, 1, 2, 3
// const allIndices = [6, 7];
// // 2. 随机打乱索引顺序
// const shuffledIndices = [...allIndices].sort(() => Math.random() - 0.5);
// // 3. 选择第一个
// currentIndex.value = shuffledIndices.slice(0, 1)[0];
// }
// if (Number(goodId) === 2140012566 || Number(goodId) === 2140012569) {
// getGoodDetail(Number(goodId)).then(async (res) => {
// currentGood = res.data;
// // 数据转义
// await formattedData(res.data);
// showDetail.value = true;
// });
// currentIndex.value = 8;
// } else if (Number(goodId) === 2140012546 || Number(goodId) === 2140012547) {
// currentIndex.value = 9;
// } else if (Number(goodId) === 2140012562) {
// currentIndex.value = 2;
// } else if (Number(goodId) === 2140012563) {
// currentIndex.value = 10;
// } else if (Number(goodId) === 2140012586) {
// currentIndex.value = 11;
// } else if (Number(goodId) === 2140012587) {
// currentIndex.value = 12;
// } else if (Number(goodId) === 2140012588) {
// currentIndex.value = 13;
// }
2025-05-27 11:58:55 +08:00
});
2025-04-09 17:25:08 +08:00
// 转义数据格式
const formattedData = (data) => {
if (currentGood.value.attribute) {
currentGood.value.attribute = Object.entries(data.attribute).map(([key, value]) => ({ key, value }));
}
if (currentGood.value.detailUrl) {
currentGood.value.detailUrl = currentGood.value.detailUrl.replace(/'/g, '"');
currentGood.value.detailUrl = JSON.parse(currentGood.value.detailUrl);
}
currentGood.value.goodUrls = data.goodUrl.split(',');
console.log(currentGood.value);
};
2025-04-11 17:32:55 +08:00
const toCodeDetail = () => {
let id = '01';
router.push('/sub-operation-service/ecommerce-sourceCodeDetail?id=' + id);
};
const toBack = (level) => {
router.go(level);
};
2025-04-09 17:25:08 +08:00
const toCopy = () => {};
</script>
<style lang="scss" scoped>
.agricultural-detail-warp {
width: 100%;
.agricultural-detail-info {
overflow: hidden;
2025-05-20 13:05:37 +08:00
margin-bottom: 16px;
2025-04-09 17:25:08 +08:00
padding: 10px 24px;
2025-05-20 13:05:37 +08:00
width: 100%;
border-radius: 16px;
background: $color-fff;
2025-04-09 17:25:08 +08:00
.top-title {
width: 100%;
text-align: left;
.father-title,
.current-title {
display: inline-block;
vertical-align: middle;
font-weight: 700;
2025-04-11 17:32:55 +08:00
cursor: pointer;
2025-04-09 17:25:08 +08:00
}
.father-title {
font-size: 18px;
}
.current-title {
position: relative;
margin-left: 8px;
2025-05-20 13:05:37 +08:00
padding: 0 8px;
font-size: 16px;
color: $color-main;
2025-04-09 17:25:08 +08:00
}
.current-title::before {
position: absolute;
top: 30%;
2025-05-20 13:05:37 +08:00
left: 0;
content: '.';
2025-04-09 17:25:08 +08:00
transform: translateY(-50%);
}
}
.top-info {
margin: 16px 0;
text-align: left;
::v-deep() {
.ecommerce-banner {
position: relative;
2025-05-20 13:05:37 +08:00
padding: 0 48px !important;
2025-04-09 17:25:08 +08:00
}
.el-carousel {
position: unset !important;
}
.el-carousel__arrow--left {
left: 0 !important;
}
.el-carousel__arrow--right {
right: 0 !important;
}
}
}
.price-sold {
margin: 16px 0;
.price {
position: relative;
padding: 0 16px;
2025-05-20 13:05:37 +08:00
font-size: 32px;
color: $color-main;
2025-04-09 17:25:08 +08:00
}
.price::before {
position: absolute;
top: 50%;
2025-05-20 13:05:37 +08:00
left: 0;
font-size: 16px;
content: '¥';
2025-04-09 17:25:08 +08:00
transform: translateY(-50%);
}
.sold {
font-size: 16px;
color: $color-999;
}
.sold::before {
content: '已售';
}
}
.tag-list {
display: inline-flex;
justify-content: flex-start;
2025-05-20 13:05:37 +08:00
width: 100%;
color: $color-999;
2025-04-09 17:25:08 +08:00
gap: 10px;
.tag-item {
position: relative;
padding-left: 32px;
.iconfont {
position: absolute;
top: 50%;
2025-05-20 13:05:37 +08:00
left: 0;
2025-04-09 17:25:08 +08:00
transform: translateY(-50%);
&.icon-see {
font-size: 24px;
}
&.icon-ci {
font-size: 20px;
}
&.icon-time {
font-size: 24px;
}
}
2025-05-20 13:05:37 +08:00
2025-04-09 17:25:08 +08:00
font-size: 16px;
line-height: 32px;
}
}
.tips-list {
2025-05-20 13:05:37 +08:00
margin: 16px 0;
2025-04-09 17:25:08 +08:00
font-size: 16px;
line-height: 32px;
}
.spu-sku-list {
width: 100%;
.spu-title {
font-size: 16px;
}
.spu-sku-warp {
display: inline-flex;
2025-05-20 13:05:37 +08:00
justify-content: space-around;
margin-top: 16px;
2025-04-09 17:25:08 +08:00
width: 100%;
flex-wrap: wrap;
gap: 16px;
.spu-sku-item {
width: calc((100% - 16px) / 2);
font-size: 16px;
2025-05-20 13:05:37 +08:00
font-weight: 400;
2025-04-09 17:25:08 +08:00
border-radius: 8px;
2025-05-20 13:05:37 +08:00
text-align: center;
line-height: 40px;
2025-04-09 17:25:08 +08:00
cursor: pointer;
&.normal {
border: 1px solid $color-da;
2025-05-20 13:05:37 +08:00
color: $color-999;
2025-04-09 17:25:08 +08:00
}
&.act {
border: 1px solid $color-main;
2025-05-20 13:05:37 +08:00
color: $color-main;
2025-04-09 17:25:08 +08:00
}
}
}
.spu-sku-warp::after {
content: '';
flex: auto;
}
}
.goods-num {
margin: 16px 0;
.num-warp,
.num-title {
display: inline-block;
vertical-align: middle;
}
.num-title {
font-size: 16px;
}
.num-warp {
.is-have {
display: inline-block;
padding-left: 8px;
font-size: 12px;
2025-05-20 13:05:37 +08:00
color: $color-999;
2025-04-09 17:25:08 +08:00
}
}
}
.top-btn {
.item-btn {
display: inline-block;
2025-05-20 13:05:37 +08:00
margin: 8px 24px 8px 0;
margin-top: 16px;
2025-04-09 17:25:08 +08:00
padding: 0 24px;
font-size: 20px;
2025-05-20 13:05:37 +08:00
border-radius: 12px;
color: $color-fff;
line-height: 42px;
2025-04-09 17:25:08 +08:00
&.sign {
background: $color-main;
}
&.reservation {
background: $color-warning;
}
}
}
.agricultural-detail-content {
width: 100%;
text-align: left;
.detail-content {
.tab-top {
margin: 42px 0;
2025-05-20 13:05:37 +08:00
width: 100%;
2025-04-09 17:25:08 +08:00
text-align: center;
::v-deep() {
.el-radio-button:first-child .el-radio-button__inner {
border-radius: 16px 0 0 16px;
}
.el-radio-button:last-child .el-radio-button__inner {
border-radius: 0 16px 16px 0;
}
.el-radio-button__inner {
padding-right: 48px !important;
2025-05-20 13:05:37 +08:00
padding-left: 48px !important;
2025-04-09 17:25:08 +08:00
font-size: 20px;
line-height: 32px !important;
}
}
}
.tab-content {
margin: 24px 0;
2025-05-20 13:05:37 +08:00
width: 100%;
2025-04-09 17:25:08 +08:00
.content-detail,
.content-source-code,
.content-evaluate {
width: 100%;
}
.content-detail {
.detail-des {
margin-bottom: 24px;
2025-06-09 10:59:28 +08:00
width: 90%;
2025-04-09 17:25:08 +08:00
}
}
.content-source-code {
.code-warp {
width: 100%;
text-align: center;
.code-img {
2025-05-20 13:05:37 +08:00
margin: auto;
2025-04-09 17:25:08 +08:00
width: 230px;
height: 230px;
}
.code-down {
margin: 16px 0;
2025-05-20 13:05:37 +08:00
color: $color-main;
2025-04-09 17:25:08 +08:00
.el-icon,
a {
display: inline-block;
vertical-align: middle;
}
.el-icon {
font-size: 22px;
}
a {
font-size: 16px;
2025-05-20 13:05:37 +08:00
color: $color-main;
2025-04-09 17:25:08 +08:00
}
}
.code-copy {
.code-txt {
display: inline-block;
2025-05-20 13:05:37 +08:00
padding: 12px 8px;
2025-04-09 17:25:08 +08:00
width: 200px;
border-radius: 16px 0 0 16px;
2025-05-20 13:05:37 +08:00
background: $color-main-table-header;
vertical-align: middle;
2025-04-09 17:25:08 +08:00
}
.do-copy {
vertical-align: middle;
display: inline-block;
margin-left: -6px;
.el-button {
padding: 21px 16px;
font-size: 16px;
2025-05-20 13:05:37 +08:00
border-radius: 12px;
2025-04-09 17:25:08 +08:00
}
}
}
.code-to-detail {
margin: 24px 0;
.el-button {
padding: 16px 116px;
height: 48px;
font-size: 20px;
font-weight: 600;
2025-05-20 13:05:37 +08:00
border-radius: 24px;
line-height: 48px;
2025-04-09 17:25:08 +08:00
}
}
}
}
}
}
}
}
}
</style>