tanghaolin
3 天以前 5ab9267c972308b7d1b250071d3d48ff98f23254
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
<template>
    <div class="container mx-auto px-4 py-8 bg-white">
        <!-- 面包屑导航 -->
        <div class="mb-6 text-gray-500">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <!-- 我需要跳转到上一页 -->
                <el-breadcrumb-item @click="handleBack" style="cursor: pointer;">{{ product.modelType
                    }}</el-breadcrumb-item>
                <el-breadcrumb-item>产品详情</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
 
        <div class="flex gap-8">
            <!-- 左侧商品图片 -->
            <div class="product-img-div w-[400px] flex-shrink-0">
                <!-- <el-image :src="product.image" fit="contain" :preview-src-list="[product.image]"
                    class="w-full h-[400px] border rounded-lg" /> -->
                <vue-image-zoomer class=" w-full h-[400px] border rounded-lg" :img-width="400" :show-message="false"
                    :regular="product.image" :zoom="product.image"></vue-image-zoomer>
            </div>
 
            <!-- 右侧商品信息 -->
            <div class="flex flex-1 flex-col gap-[20px]">
                <h1 class="text-[30px] font-medium" style="margin-bottom: unset">{{ product.name }}</h1>
 
                <!-- 订货信息 -->
                <div class="bg-gray-50  rounded-lg ">
                    <div class="text-gray-500 text-[20px] mb-[20px]">订货编码:{{ product.applicationCode }}</div>
                    <div class="flex items-center gap-2">
                        <span class="text-gray-500 text-[20px]">能效等级:</span>
                        <div class="flex items-center relative">
                            <img :src="EecLevelEnum[productDataRef.eec]?.icon" class="h-8" />
                        </div>
                    </div>
                </div>
 
                <!-- 价格区域 -->
                <div class="">
                    <div class="flex items-baseline gap-2 text-[20px]">
                        <span class="text-gray-500">价格:</span>
                        <span class="text-2xl font-bold text-red-500">面议</span>
                    </div>
                </div>
                <!-- 购买按钮 -->
                <div class="flex gap-4">
                    <!-- <div class="flex  items-center">
                        <el-input-number class="!w-[100px]" v-model="product.quantity" :min="1" :max="99" size="large"
                            controls-position="right">
                            <template #decrease-icon>
                                <el-icon>
                                    <Minus />
                                </el-icon>
                            </template>
<template #increase-icon>
                                <el-icon>
                                    <Plus />
                                </el-icon>
                            </template>
</el-input-number>
</div> -->
                    <el-button type="primary" size="large" color="#003a8f" @click="handleAddToCollect">加入收藏</el-button>
                </div>
            </div>
        </div>
 
        <!-- 商品详情 -->
        <div class="mt-8">
            <el-tabs v-model="activeTab" type="border-card" class="demo-tabs">
                <el-tab-pane label="商品介绍" name="intro">
                    <div class="p-6">
                        <h3 class="text-lg font-medium mb-4">【产品参数】</h3>
                        <el-descriptions :column="2" border>
                            <el-descriptions-item label="品牌">{{ product.brand }}</el-descriptions-item>
                            <el-descriptions-item label="型号">{{ product.model }}</el-descriptions-item>
                            <el-descriptions-item label="功率">{{ product.power }}</el-descriptions-item>
                            <el-descriptions-item label="电压">{{ product.voltage }}</el-descriptions-item>
                            <el-descriptions-item label="转速">{{ product.speed }}</el-descriptions-item>
                            <el-descriptions-item label="防护等级">{{ product.protection }}</el-descriptions-item>
                        </el-descriptions>
 
                        <div class="mt-8">
                            <h3 class="text-lg font-medium mb-4">【产品详情】</h3>
                            <div class="space-y-4">
                                <img v-for="(img, index) in product.detailImages" :key="index" :src="img" class="w-full"
                                    alt="产品详情图" />
                            </div>
                        </div>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="性能曲线" name="PerformanceCurve">
                    <div style="width: 1200px; height: 750px" v-show="isPumpDetail">
                        <LXBChart ref="lxbChartCtrl"></LXBChart>
                    </div>
                    <img width="1200" height="auto" :src="product.Chart" v-if="isFan" />
                    <el-empty description="暂无性能曲线信息" v-show="!isPumpDetail && !isFan" />
                </el-tab-pane>
                <el-tab-pane label="变速曲线" name="params">
                    <!-- <div style="width: 1200px; height: 750px"></div> -->
                    <div style="width: 1200px; height: 750px" v-show="isPumpDetail">
                        <MultiSpeedChart ref="multiSpeedChartCtrl"></MultiSpeedChart>
                    </div>
                    <el-empty description="暂无变速曲线信息" v-show="!isPumpDetail" />
                </el-tab-pane>
                <el-tab-pane label="切割曲线" name="CutCurve">
                    <el-empty description="暂无切割曲线信息" />
                </el-tab-pane>
                <el-tab-pane label="规格参数" name="SpecificParam">
                    <div class="p-6">
                        <prop ref="propCtrl" v-show="isPumpDetail"></prop>
                    </div>
                    <el-empty description="暂无变速曲线信息" v-show="!isPumpDetail" />
                </el-tab-pane>
                <el-tab-pane label="选型报告" name="SelectReport">
                    <img width="1200" height="auto" :src="product.SelectReport" v-if="isFan || isPumpDetail" />
                    <el-empty description="暂无报告" v-show="!isPumpDetail && !isFan" />
                </el-tab-pane>
                <el-tab-pane label="测试报告" name="certificate">
                    <div class="p-6 flex justify-center">
                        <img :src="product.certificatePath" alt="节能证书" class="max-w-full" />
                    </div>
                </el-tab-pane>
                <el-tab-pane label="包装售后" name="service">
                    <div class="p-6">
                        <h3 class="text-lg font-medium mb-4">包装清单</h3>
                        <p class="text-gray-600">{{ product.package }}</p>
 
                        <h3 class="text-lg font-medium mt-6 mb-4">售后服务</h3>
                        <div class="text-gray-600">
                            <p>1. 本产品全国联保,享受三包服务</p>
                            <p>2. 质保期:12个月</p>
                            <p>3. 对于质量问题,提供免费维修服务</p>
                        </div>
                    </div>
                </el-tab-pane>
            </el-tabs>
        </div>
    </div>
 
    <!-- 购买确认对话框 -->
    <el-dialog v-model="showAddCollectDialog" title="选择收藏组" width="500px" align-center>
        <template #header>
            <span class="purchase-title">选择收藏组</span>
        </template>
 
        <div class="">
            <div class="">
                <el-input v-model="collectGroupNameSerch" placeholder="">
                    <template #append><el-button color="#003a8f" :icon="Search">搜索</el-button></template>
                </el-input>
            </div>
            <div class="flex items-start flex-col max-h-[300px] min-h-[150px] py-[10px]"
                style="overflow-y: auto; box-sizing: border-box;">
                <!-- 收藏组 -->
                <div class="collect-grp-div px-[10px]" v-for="item in collcetGroup" :key="item.id"
                    @mouseover="item.isSelected = true" @mouseleave="item.isSelected = false">
                    <div class="font-medium">{{ item?.name || "" }}</div>
                    <div class="text-red-500">{{ item.collectList?.length }}</div>
                    <div class="sure-btn" @click="addGroupBtn(item.id)" v-show="item.isSelected">确定</div>
                </div>
            </div>
            <el-divider />
            <div class="flex w-full">
                <el-button v-show="!dispCreateInput" type="text" style="color: #003a8f;"
                    @click="dispCreateInput = true">+创建分组</el-button>
                <div class="create-div" v-show="dispCreateInput">
                    <el-input v-model="collectForm.name" placeholder=""></el-input>
                    <div class="create-right-div">
                        <a class="cancel-btn-div" @click="dispCreateInput = false">取消</a>
                        <a class="create-btn-div" @click="createCollectGroup">创建</a>
                    </div>
                </div>
            </div>
        </div>
    </el-dialog>
</template>
 
<script setup lang="ts">
import EecLevel1 from '@/assets/icons/ecc1.svg';
import EecLevel2 from '@/assets/icons/ecc2.svg';
import EecLevel3 from '@/assets/icons/ecc3.svg';
import { SERVE_URL } from '@/constants';
import { ElMessage } from 'element-plus';
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import pumpDetailInfo from '@/views/mock/DetailsInfo';
import pumpDetailInfo_WQ from '@/views/mock/DetailsInfo_WQ';
import LXBChart from '@/components/Chart/LXBChart.vue';
import MultiSpeedChart from '@/components/Chart/MultiSpeedChart.vue';
import prop from '@/views/components/prop.vue';
import { useCollectStore } from '@/stores/useCollectStore';
import { VueImageZoomer } from 'vue-image-zoomer';
import 'vue-image-zoomer/dist/style.css';
 
const route = useRoute();
const router = useRouter();
 
const lxbChartCtrl = ref();
const multiSpeedChartCtrl = ref();
const propCtrl = ref();
const activeTab = ref('intro');
const showAddCollectDialog = ref(false);
const collectGroupNameSerch = ref('');
const dispCreateInput = ref(false);
 
const isPumpDetail = ref(false);
const isFan = ref(false);
const collectForm = ref({
    name: '',
});
 
// 从localStorage获取产品信息
const product = ref({
    id: '',
    name: '',
    applicationCode: '',
    quantity: 1,
    price: '',
    image: '',
    brand: '',
    model: '',
    power: '',
    voltage: '',
    speed: '',
    protection: '',
    eecLevelIcon: EecLevel1,
    package: '电机 × 1, 说明书 × 1, 合格证 × 1',
    certificatePath: '',
    specifications: {
        产品型号: '',
        额定功率: '',
        额定电压: '',
        防护等级: '',
        绝缘等级: 'F级',
        效率等级: '一级能效',
        重量: '约12kg',
    },
    detailImages: [],
});
 
const EecLevelEnum = {
    1: { name: '一级能效', icon: EecLevel1 },
    2: { name: '二级能效', icon: EecLevel2 },
    3: { name: '二级能效', icon: EecLevel3 },
};
const collcetGroup = ref([]);
const productDataRef = ref({});
onMounted(() => {
    // 从localStorage获取产品信息
    const savedProduct = localStorage.getItem('currentProduct');
    if (savedProduct) {
        const productData = JSON.parse(savedProduct);
        productDataRef.value = productData;
 
        // 合并默认值和保存的产品数据
        product.value = {
            ...product.value,
            id: productData.id,
            sid: productData.seriesID,
 
            name: productData.ModelType,
            applicationCode: productData.RecordNumber,
            price: productData.Price,
            image: `${SERVE_URL}${productData.PhysicalPicturePath}`,
            certificatePath: `${SERVE_URL}${productData.CertificatePath}`,
            brand: productData.CompanyName,
            model: productData.model,
            modelType: productData.ModelType,
 
            power: '详询厂家',
            voltage: '详询厂家',
            speed: '详询厂家',
            protection: '详询厂家',
            detailImages: [`${SERVE_URL}${productData.PhysicalPicturePath}`],
            specifications: {
                产品型号: productData.Model,
                生产企业: productData.CompanyName,
                备案编号: productData.RecordNumber,
                备案时间: productData.RecordTime,
                能效等级: `${productData.EnergyEfficiencyClass}级`,
            },
        };
        isPumpDetail.value = productData.type == 1 ? true : false;
        if (product.value.model.includes('DSWQ') && isPumpDetail.value) {
            product.value.SelectReport = 'static/EecProductData/image/1/DSWQ_SelectReport.png';
        }
        if (product.value.model.substring(0, 3).includes('DRL') && isPumpDetail.value) {
            product.value.SelectReport = 'static/EecProductData/image/1/DRL_SelectReport.png';
        }
 
        isFan.value = productData.Type == 7 ? true : false;
        if (isFan.value) {
            product.value.Chart = 'static/EecProductData/image/3/fan_chart.png';
            product.value.SelectReport = 'static/EecProductData/image/3/SelectReport.png';
        }
    }
    initDetailData();
    initCollectGroupData();
});
const initDetailData = () => {
    let m_userUnitSetting = {
        NPSH: 0,
        isAdjustCoordUnitByUserSetting: false,
    };
    let pumpInfoData = pumpDetailInfo;
    if (product.value.model.includes('DSWQ')) {
        pumpInfoData = pumpDetailInfo_WQ;
    }
    let pumpBaseInfo = {
        CorpID: 69,
        SeriesID: 'C69S4',
        PumpID: 8978,
        SubID: 0,
        ChartType: 3,
        PumpStyle: 0,
        PumpName4File: product.value.model,
        CorpName: product.value.CompanyName,
        PumpName: product.value.model,
 
        SeriesName: product.value.ModelType,
        CatalogName: '立式多级泵',
        EecStauts: 0,
        EecGrade: 0,
        DefaultMotorPower: 0,
        MaxD2: 75,
        WrkD2: 75,
        MinD2: 75,
        Ratedn: 2900,
        WrkSpeed: 2900,
        FirePumpType: 0,
        DriveType: 0,
        RatedParas: {
            H: '100.5',
            Q: '1',
            E: '41',
            P: '0.67',
            NPSHr: null,
        },
    };
    var cb_dict = {
        //设置曲线修改回调函数
        setChangeWrkCurveCb: (curve) => {
            multiSpeedChartCtrl.value.setWrkCurveInfo(curve);
        },
    };
    if (!isPumpDetail.value) return;
    lxbChartCtrl.value.initPumpInfoData(0, pumpInfoData, cb_dict, m_userUnitSetting);
    multiSpeedChartCtrl.value.initPumpInfoData(0, pumpInfoData, () => { }, m_userUnitSetting);
    //初始化属性控件
    propCtrl.value.initialData(0, pumpBaseInfo, pumpInfoData.PartFullInfo, pumpInfoData.SettingInfo);
};
// 初始化收藏分组数据
const initCollectGroupData = () => {
    const collectStore = useCollectStore();
    collcetGroup.value = collectStore.items.map(item => {
        return {
            ...item,
            isSelected: false
        }
    });
    console.log(collcetGroup.value, 356);
}
 
 
// 添加商品到购物车
const addItemToCart = () => {
    try {
        const collectStore = useCollectStore();
        const newCartItem = {
            sid: product.value.sid,
            addID: product.value.id,
            addTime: new Date().toLocaleString(),
            name: product.value.name,
            image: product.value.image,
            companyName: product.value.brand,
            model: product.value.model,
        };
        collectStore.addToCollect(newCartItem);
        ElMessage.success('已添加到收藏');
    } catch (error) {
        console.log(err)
    }
 
};
 
const handleAddToCollect = () => {
    showAddCollectDialog.value = true;
};
 
const handleViewCurve = () => {
    window.open('http://www.xpump.net/V4/#/CN/Target/DOOCH/Pump/Index/C69S4/8978', '_blank');
};
 
const handleBack = () => {
    router.go(-1);
}
 
// 创建收藏分组
const createCollectGroup = () => {
    let groupItem = {
        id: new Date().getTime(),
        name: collectForm.value.name,
        collectList: [],
    }
    collcetGroup.value.push(groupItem)
    dispCreateInput.value = false;
 
 
};
// 确定添加到分组
const addGroupBtn = (id: string) => {
    const collectStore = useCollectStore();
    const newCartItem = {
        sid: product.value.sid,
        addID: product.value.id,
        addTime: new Date().toLocaleString(),
        name: product.value.name,
        image: product.value.image,
        companyName: product.value.brand,
        model: product.value.model,
        flow: productDataRef.value.flow,
        head: productDataRef.value.head,
        speed: productDataRef.value.speed,
        eta: productDataRef.value.eta,
        eec: productDataRef.value.eec
    };
    for (let i = 0; i < collcetGroup.value.length; i++) {
        const item = collcetGroup.value[i];
        if (item.id === id) {
            const hasCollectItem = collectStore.isExistCollectItem(item)
            if (hasCollectItem) {
                ElMessage.warning('该商品已存在,请勿重复添加');
                return;
            }
            item.collectList.push(newCartItem)
        }
    }
    collectStore.setCollectItems(collcetGroup.value);
    showAddCollectDialog.value = false;
    ElMessage.success('添加到收藏分组成功');
 
}
</script>
 
<style scoped>
.demo-tabs {
    height: 100%;
    display: flex;
}
 
.purchase-title {
    font-size: 16px;
    color: #333;
    font-weight: 500;
    margin: 10px 0;
}
 
.create-div {
    border-radius: 8px;
    position: relative;
    width: 400px;
    height: 32px;
    padding: 0 4px;
    border: 1px solid var(--theme-color);
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    display: flex;
 
    :deep(.el-input__wrapper) {
        height: 32px;
        padding: 0 4px 0 8px;
        width: 200px;
        display: inline-block;
        vertical-align: top;
        border-radius: 4px;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        float: right;
        box-shadow: none;
        background-color: transparent;
    }
 
    .create-right-div {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-align: center;
        -ms-flex-align: center;
        align-items: center;
        -webkit-box-pack: justify;
        -ms-flex-pack: justify;
        justify-content: space-between;
        width: 190px;
        height: 100%;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
 
        .cancel-btn-div {
            line-height: 16px;
            padding: 4px 17px;
            font-size: 12px;
            display: inline-block;
            border: 1px solid var(--theme-color);
            border-radius: 4px;
            text-align: center;
            vertical-align: top;
            color: var(--theme-color);
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            cursor: pointer;
        }
 
        .create-btn-div {
            line-height: 16px;
            padding: 4px 17px;
            font-size: 12px;
            display: inline-block;
            border: 1px solid var(--theme-color);
            border-radius: 4px;
            text-align: center;
            vertical-align: top;
            color: var(--theme-color);
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            cursor: pointer;
            color: #fff;
            background: var(--theme-color);
        }
    }
}
 
.collect-grp-div {
    position: relative;
    width: 100%;
    height: 36px;
    line-height: 36px;
    font-size: 14px;
    color: #333;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
 
    .sure-btn {
        display: block;
        width: 80px;
        height: 30px;
        background: #003a8f;
        color: #fff;
        text-align: center;
        line-height: 30px;
        margin-top: 2px;
        border-radius: 4px;
        position: absolute;
        right: 10px;
        top: 0;
    }
 
    &:hover {
        border: 1px solid #003a8f;
        background: #00398f2c;
        color: #003a8f;
        border-radius: 8px;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
    }
}
 
 
 
:deep(.el-input-group__append) {
    background-color: var(--theme-color);
    color: #fff;
}
 
:deep(.el-tabs__nav-wrap::after) {
    height: 1px;
}
 
:deep(.el-descriptions__label) {
    width: 120px;
    font-weight: normal;
}
 
:deep(.el-tabs__content) {
    height: 100%;
}
 
:deep(.el-tabs--border-card>.el-tabs__header) {
    height: 64px;
    line-height: 64px;
    background-color: #f1f2f3;
    padding: 0 15px;
    /* border-bottom: unset; */
}
 
:deep(.el-tabs__nav-wrap) {
    height: 100%;
}
 
:deep(.el-tabs__nav-scroll) {
    height: 100%;
}
 
:deep(.el-tabs__nav) {
    transform: translateX(0px);
    height: 100%;
    justify-content: center;
    align-items: flex-end;
    gap: 8px;
}
 
:deep(.el-tabs--border-card>.el-tabs__header .el-tabs__item:first-child) {
    margin-left: -1px;
    border-radius: 10px 10px 0 0;
    color: var(--theme-color);
    background-color: #879eb7;
    font-size: 24px;
    font-family: SourceHanSans-Bold;
    justify-content: flex-end;
    gap: 8px;
}
 
:deep(.el-tabs--border-card>.el-tabs__header .el-tabs__item+.el-tabs__item) {
    border-radius: 10px 10px 0 0;
    color: var(--theme-color);
    background-color: #879eb7;
    font-size: 24px;
    font-family: SourceHanSans-Bold;
}
 
:deep(.el-tabs__header .el-tabs__item.is-active) {
    background-color: #fff !important;
    color: var(--theme-color);
    font-size: 24px;
    font-family: SourceHanSans-Bold;
    border-radius: 10px 10px 0 0;
}
</style>