-
Notifications
You must be signed in to change notification settings - Fork 84
/
productDetail.php
executable file
·636 lines (558 loc) · 28 KB
/
productDetail.php
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
<!DOCTYPE html>
<!--[if IE 9]>
<html lang="en" class="ie9"> <![endif]-->
<!--[if IE 8]>
<html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<title>杭州北望生物技术有限公司 | 首页</title>
<meta name="description" content="杭州北望生物技术有限公司网站">
<meta name="author" content=.phpcoder.me">
<!-- Mobile Meta -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Favicon -->
<link rel="shortcut icon" href="style/images/img/favicon.ico">
<!-- Web Fonts -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700,300&subset=latin,latin-ext'
rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=PT+Serif' rel='stylesheet' type='text/css'>
<!-- Bootstrap core CSS -->
<link href="style/css/bootstrap.css" rel="stylesheet">
<!-- Font Awesome CSS -->
<link href="style/css/font-awesome.css" rel="stylesheet">
<!-- Fontello CSS -->
<link href="style/css/fontello.css" rel="stylesheet">
<!-- Plugins -->
<link href="style/css/settings.css" media="screen" rel="stylesheet">
<link href="style/css/extralayers.css" media="screen" rel="stylesheet">
<link href="style/css/magnific-popup.css" rel="stylesheet">
<link href="style/css/animations.css" rel="stylesheet">
<link href="style/css/owl.carousel.css" rel="stylesheet">
<!-- iDea core CSS file -->
<link href="style/css/style.css" rel="stylesheet">
<!-- Style Switcher Styles (Remove these two lines) -->
<link href="#" data-style="styles" rel="stylesheet">
<link href="style/css/style-switcher.css" rel="stylesheet">
<link href="style/css/sweet-alert.css" rel="stylesheet">
<link href="style/css/sweetalert.css" rel="stylesheet">
<!-- Custom css -->
<link href="style/css/custom.css" rel="stylesheet">
<script src="http://cdn.bootcss.com/jquery/2.0.3/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
<!--.php5 shim and Respond.js for IE8 support of.php5 elements and media queries -->
<!--[if lt IE 9]>
<script src="style/js.php5shiv.min.js"></script>
<script src="style/js/respond.min.js"></script>
<![endif]-->
</head>
<!-- body classes:
"boxed": boxed layout mode e.g. <body class="boxed">
"pattern-1 ... pattern-9": background patterns for boxed layout mode e.g. <body class="boxed pattern-1">
-->
<body class="front no-trans">
<!-- scrollToTop -->
<!-- ================ -->
<div class="scrollToTop"><i class="icon-up-open-big"></i></div>
<!-- page wrapper start -->
<!-- ================ -->
<div class="page-wrapper">
<!-- header-top start (Add "dark" class to .header-top in order to enable dark header-top e.g <div class="header-top dark">) -->
<!-- ================ -->
<!-- header-top end -->
<!-- header start classes:
fixed: fixed navigation mode (sticky menu) e.g. <header class="header fixed clearfix">
dark: dark header version e.g. <header class="header dark clearfix">
================ -->
<?php
require_once "controller/Header.php";
$header = Header::getInstance();
$header->headerGenerate(3, 1);
?>
<!-- header end -->
<!-- page-intro start-->
<!-- ================ -->
<div class="page-intro">
<div class="container">
<div class="row">
<div class="col-md-12">
<ol class="breadcrumb">
<li><i class="fa fa-home pr-10"></i><a href="index.php">主页</a></li>
<li class="active">产品详情</li>
</ol>
</div>
</div>
</div>
</div>
<!-- page-intro end -->
<!-- main-container start -->
<!-- ================ -->
<section class="main-container">
<div class="container">
<div class="row">
<!-- main start -->
<!-- ================ -->
<div class="main col-md-12">
<!-- page-title start -->
<!-- ================ -->
<h1 class="page-title margin-top-clear" id="productName"></h1>
<!-- page-title end -->
<div class="row">
<div class="col-md-4">
<!-- Nav tabs -->
<ul class="nav nav-pills white space-top" role="tablist" id="resources">
<li class="active"><a href="#productImages" role="tab" data-toggle="tab" title="images"><i
class="fa fa-camera pr-5"></i> 图片</a></li>
<li><a href="#productVideo" role="tab" data-toggle="tab" title="video"><i
class="fa fa-video-camera pr-5"></i> 视频</a></li>
</ul>
<!-- Tab panes start-->
<div class="tab-content clear-style">
<div class="tab-pane active" id="productImages">
<div class="owl-carousel content-slider-with-controls-bottom" id="imageNode">
</div>
</div>
<div class="tab-pane" id="productVideo">
<div class="embed-responsive embed-responsive-16by9">
视频资源还没上传,敬请期待
</div>
</div>
</div>
<!-- Tab panes end-->
<hr>
<span class="price"><del id="originalPrice">¥0.00</del> ¥<label id="price">0.00</label></span>
<div class="elements-list pull-right clearfix">
<span id="productStars">
</span>
<a href="#" class="wishlist"><i class="fa fa-heart-o pr-5"></i>预购清单</a>
</div>
<div class="clearfix"></div>
<hr>
<div class="row">
<form role="form">
<div class="col-md-4">
<div class="form-group">
<label>数量</label>
<input type="number" class="form-control" value="1" id="productAmount" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>在线客服</label><br/>
<a href="tencent://message/?uin=2679943834&Site=杭州北望&Menu=yes"><i
class="fa fa-qq"></i> </a>
</div>
</div>
<div class="col-md-4">
</div>
<div class="col-md-12">
<a id="addToCart" class="btn btn-default">加入购物车</a>
</div>
</form>
</div>
</div>
<!-- product side start -->
<aside class="col-md-8">
<div class="sidebar">
<div class="side product-item vertical-divider-left">
<div class="tabs-style-2">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a href="#h2tab1" role="tab" data-toggle="tab"><i
class="fa fa-file-text-o pr-5"></i>产品介绍</a></li>
<li><a href="#h2tab2" role="tab" data-toggle="tab"><i
class="fa fa-files-o pr-5"></i>规格参数</a></li>
<li><a href="#h2tab3" role="tab" data-toggle="tab"><i
class="fa fa-star pr-5"></i>产品评价:共<span
id="commentCount"></span></a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content padding-top-clear padding-bottom-clear">
<div class="tab-pane fade in active" id="h2tab1">
<h4 class="title">单位</h4>
<p id="unit"></p>
<h4>商品简介</h4>
<p id="description"></p>
<h4> 适用范围:</h4>
<p id="availableScope"></p>
</div>
<div class="tab-pane fade" id="h2tab2">
<h4 class="space-top">参数</h4>
<hr>
<dl class="dl-horizontal">
<dt>性状:</dt>
<dd id="productFeature">冻干</dd>
<dt>使用方法:</dt>
<dd id="useage"></dd>
<dt>保存条件:</dt>
<dd id="condition"></dd>
<dt>有 效 期:</dt>
<dd id="expiration"></dd>
<dt>执行标准:</dt>
<dd id="operativenorm"></dd>
</dl>
<hr>
</div>
<div class="tab-pane fade" id="h2tab3">
<!-- comments start -->
<div class="comments margin-clear space-top" id="arguments">
</div>
<ul class="pagination">
</ul>
<!-- comments end -->
</div>
</div>
</div>
</div>
</div>
</aside>
<!-- product side end -->
</div>
</div>
<!-- main end -->
</div>
</div>
</section>
<!-- main-container end -->
<!-- section start -->
<!-- ================ -->
<div class="section gray-bg clearfix">
<div class="container">
<div class="call-to-action">
<div class="row">
<div class="col-md-8">
<h1 class="title text-center">不要再等待!</h1>
<p class="text-center">触碰指尖,轻松加入购物车. </p>
</div>
<div class="col-md-4">
<div class="text-center">
<a href="latest-product.php" class="btn btn-default btn-lg">立即购买</a>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- section end -->
<!-- section start -->
<!-- ================ -->
<div class="section clearfix">
<div class="container">
<div class="row">
<div class="col-md-12">
<h2>相关产品</h2>
<div class="separator-2"></div>
<div class="row grid-space-20" id="recommend">
</div>
</div>
</div>
</div>
</div>
<!-- section end -->
<!-- section start -->
<!-- ================ -->
<!-- section end -->
<!-- footer start (Add "light" class to #footer in order to enable light footer) -->
<!-- ================ -->
<?php
include_once "controller/Footer.php";
?>
<!-- footer end -->
</div>
<!-- page-wrapper end -->
<!-- JavaScript files placed at the end of the document so the pages load faster
================================================== -->
<!-- Jquery and Bootstap core js files -->
<script type="text/javascript" src="style/js/jquery.min.js"></script>
<!-- Owl carousel javascript -->
<script type="text/javascript" src="style/js/owl.carousel.js"></script>
<!-- Magnific Popup javascript -->
<script type="text/javascript" src="style/js/jquery.magnific-popup.min.js"></script>
<!-- Initialization of Plugins -->
<script type="text/javascript" src="style/js/template.js"></script>
<script src="style/js/sweetalert.min.js"></script>
<script>
//获取url参数
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null)
return decodeURIComponent(r[2]);
return null;
}
//render星级
function renderStarLevel(stars) {
var starHteml = "";
if (stars == "") {
return;
}
for (var i = 0; i < 5; i++) {
starHteml += '<i class="fa fa-star ' + (i < stars ? "text-default" : "") + '"></i>';
}
return starHteml;
}
var type = getQueryString("type");
var id = getQueryString("id");
var $commentTarget = $("#arguments");
var globalComments = [];
function updateUI($this, page) {
$(".pagination li").each(function () {
$(this).removeClass("active");
});
$($this).parent().addClass("active");
refreshComments(page);
}
function refreshComments(page) {
$commentTarget.empty();
for (var i = 0 + (page - 1) * 2; i < globalComments.length; i++) {
if (page != 1) {
$('<div class="comment clearfix">' +
'<div class="comment-avatar">' +
'<img src="style/images/avatar.jpg" alt="avatar">' +
'</div>' +
'<div class="comment-content">' +
'<h3>' + globalComments[i].username + '</h3>' +
'<div class="comment-meta">' +
renderStarLevel(globalComments[i].properLevel) +
'| ' + globalComments[i].time + '' +
'</div>' +
'<div class="comment-body clearfix">' +
'<p>' + globalComments[i].content + '</p>' +
'</div>' +
'</div>' +
'</div>').appendTo($commentTarget);
} else {
if (i < 2) {
$('<div class="comment clearfix">' +
'<div class="comment-avatar">' +
'<img src="style/images/avatar.jpg" alt="avatar">' +
'</div>' +
'<div class="comment-content">' +
'<h3>' + globalComments[i].username + '</h3>' +
'<div class="comment-meta">' +
renderStarLevel(globalComments[i].properLevel) +
'| ' + globalComments[i].time + '' +
'</div>' +
'<div class="comment-body clearfix">' +
'<p>' + globalComments[i].content + '</p>' +
'</div>' +
'</div>' +
'</div>').appendTo($commentTarget);
} else {
$pagetarget.empty();
var pages = Math.ceil(globalComments.length / 2);
for (var $i = 0; $i < pages + 2; $i++) {
if ($i == 0) {
$('<li><a>«</a></li>').appendTo($pagetarget);
} else if ($i == 1) {
$('<li class="active"><a onclick="updateUI(this,1);">1 <span class="sr-only">(current)</span></a></li>').appendTo($pagetarget);
} else if ($i == pages + 1) {
$('<li><a>»</a></li>').appendTo($pagetarget);
} else {
$('<li><a onclick="updateUI(this,' + $i + ');">' + $i + '</a></li>').appendTo($pagetarget);
}
}
break;
}
}
}
}
var product;
function uploadProduct() {
$.ajax({
dataType: "json",
type: "get",
url: "controller/productlist.php?type=" + type + "&id=" + id,
success: function (data) {
if (data.code == 200) {
product = data.data.product[0];
}
},
error: function (code, message, data) {
alert("发生错误:" + message);
}
});
}
function loadData() {
$("#imageNode").empty();
$.ajax({
dataType: "json",
type: "get",
url: "controller/productlist.php?type=" + type + "&id=" + id,
success: function (data) {
if (data.code == 200) {
product = data.data.product[0];
var comments = data.data.comments;
var recommend = data.data.recommend;
globalComments = comments;
var $recommendTarget = $("#recommend");
var $resourcesTarget = $("#resources");
$("#productName").text(product.productName);
$("#productStars").html(renderStarLevel(product.starLevel));
for (var i = 1; i < 6; i++) {
if (product["image" + i] != "") {
$('<div class="overlay-container">' +
'<img src="' + product["image" + i] + '" alt="">' +
'<a href="' + product["image" + i] + '" class="popup-img overlay" title="image title"><i class="fa fa-search-plus"></i></a>' +
'</div>').appendTo($("#imageNode"));
}
}
if ($('.owl-carousel').length>0) {
$(".owl-carousel.carousel").owlCarousel({
items: 4,
pagination: false,
navigation: true,
navigationText: false
});
$(".owl-carousel.carousel-autoplay").owlCarousel({
items: 4,
autoPlay: 5000,
pagination: false,
navigation: true,
navigationText: false
});
$(".owl-carousel.clients").owlCarousel({
items: 4,
autoPlay: true,
pagination: false,
itemsDesktopSmall: [992,5],
itemsTablet: [768,4],
itemsMobile: [479,3]
});
$(".owl-carousel.content-slider").owlCarousel({
singleItem: true,
autoPlay: 5000,
navigation: false,
navigationText: false,
pagination: false
});
$(".owl-carousel.content-slider-with-controls").owlCarousel({
singleItem: true,
autoPlay: false,
navigation: true,
navigationText: false,
pagination: true
});
$(".owl-carousel.content-slider-with-controls-autoplay").owlCarousel({
singleItem: true,
autoPlay: 5000,
navigation: true,
navigationText: false,
pagination: true
});
$(".owl-carousel.content-slider-with-controls-bottom").owlCarousel({
singleItem: true,
autoPlay: false,
navigation: true,
navigationText: false,
pagination: true
});
};
$("#imageNode").parent().css("opacity", "1");
$("#originalPrice").text("¥"+product.price);
$("#price").text(product.discountPrice);
$("#unit").text(product.unit);
$("#description").text(product.productDescription);
$("#availableScope").text(product.availableScope);
$("#productFeature").text(product.productFeature);
$("#useage").text(product.useage);
$("#condition").text(product.condition);
$("#expiration").text(product.expiration);
$("#operativenorm").text(product.operativenorm);
//评价
$("#commentCount").text(comments.length + "条");
var $pagetarget = $(".pagination");
for (var i = 0; i < comments.length; i++) {
if (i < 2) {
$('<div class="comment clearfix">' +
'<div class="comment-avatar">' +
'<img src="style/images/avatar.jpg" alt="avatar">' +
'</div>' +
'<div class="comment-content">' +
'<h3>' + comments[i].username + '</h3>' +
'<div class="comment-meta">' +
renderStarLevel(comments[i].properLevel) +
'| ' + comments[i].time + '' +
'</div>' +
'<div class="comment-body clearfix">' +
'<p>' + comments[i].content + '</p>' +
'</div>' +
'</div>' +
'</div>').appendTo($commentTarget);
} else {
$pagetarget.empty();
var pages = Math.ceil(comments.length / 2);
for (var $i = 0; $i < pages + 2; $i++) {
if ($i == 0) {
$('<li><a>«</a></li>').appendTo($pagetarget);
} else if ($i == 1) {
$('<li class="active"><a onclick="updateUI(this,1);">1 <span class="sr-only">(current)</span></a></li>').appendTo($pagetarget);
} else if ($i == pages + 1) {
$('<li><a>»</a></li>').appendTo($pagetarget);
} else {
$('<li><a onclick="updateUI(this,' + $i + ');">' + $i + '</a></li>').appendTo($pagetarget);
}
}
break;
}
}
//推荐产品
for (var i = 0; i < recommend.length; i++) {
$('<div class="col-md-3 col-sm-6 masonry-grid-item">' +
'<div class="listing-item">' +
'<div class="overlay-container">' +
'<img src="' + recommend[i].image1 + '" alt="">' +
'<a href="productDetail.php?id=' + recommend[i].id + '&type=' + type + '" class="overlay small">' +
'<i class="fa fa-plus"></i>' +
'<span>查看详情</span>' +
'</a>' +
'</div>' +
'<div class="listing-item-body clearfix">' +
'<h3 class="title"><a href="productDetail.php?id=' + recommend[i].id + '&type=' + type + '">' + recommend[i].productName + '</a></h3>' +
'<p>' + recommend[i].unit + '</p>' +
'<span class="price">¥' + recommend[i].price + '</span>' +
'<div class="elements-list pull-right">' +
'<a href="productDetail.php?id=' + recommend[i].id + '&type=' + type + '" class="wishlist" title="wishlist"><i class="fa fa-heart-o"></i></a>' +
'<a href="productDetail.php?id=' + recommend[i].id + '&type=' + type + '"><i class="fa fa-shopping-cart pr-10"></i>加入购物车</a>' +
'</div>' +
'</div>' +
'</div>' +
'</div>').appendTo($recommendTarget);
}
}
},
error: function (code, message, data) {
alert("发生错误:" + message);
}
});
}
loadData();
</script>
<script src="style/js/Helper/front/productDetail.js" ></script>
<script type="text/javascript" src="style/js/bootstrap.min.js"></script>
<!-- Modernizr javascript -->
<script type="text/javascript" src="style/js/modernizr.js"></script>
<!-- Isotope javascript -->
<script type="text/javascript" src="style/js/isotope.pkgd.min.js"></script>
<!-- Appear javascript -->
<script type="text/javascript" src="style/js/jquery.appear.js"></script>
<!-- Sharrre javascript -->
<script type="text/javascript" src="style/js/jquery.sharrre.js"></script>
<!-- Count To javascript -->
<script type="text/javascript" src="style/js/jquery.countTo.js"></script>
<!-- Parallax javascript -->
<script src="style/js/jquery.parallax-1.1.3.js"></script>
<!-- Contact form -->
<script src="style/js/jquery.validate.js"></script>
<!-- SmoothScroll javascript -->
<script type="text/javascript" src="style/js/jquery.browser.js"></script>
<script type="text/javascript" src="style/js/SmoothScroll.js"></script>
<!-- Custom Scripts -->
<script type="text/javascript" src="style/js/custom.js"></script>
<!-- Color Switcher (Remove these lines) -->
<script type="text/javascript" src="style/js/style-switcher.js"></script>
<!-- Color Switcher End -->
</body>
</html>