Showing
14 changed files
with
950 additions
and
0 deletions
apps/product/views/action/detail/detail.hbs
0 → 100644
1 | +{{# result}} | ||
2 | +<div class="good-detail-page yoho-page"> | ||
3 | + <div class="banner-container"> | ||
4 | + <div class="tag-container"> | ||
5 | + {{# tags}} | ||
6 | + {{# is_new}} | ||
7 | + <p class="good-tag new-tag">NEW</p> | ||
8 | + {{/ is_new}} | ||
9 | + {{# is_advance}} | ||
10 | + <p class="good-tag renew-tag">再到着</p> | ||
11 | + {{/ is_advance}} | ||
12 | + {{# is_discount}} | ||
13 | + <p class="good-tag sale-tag">SALE</p> | ||
14 | + {{/ is_discount}} | ||
15 | + {{# is_yohood}} | ||
16 | + <div class="good-tag running-man-tag">跑男同款</div> | ||
17 | + {{/ is_yohood}} | ||
18 | + {{# is_limited}} | ||
19 | + <p class="good-tag limit-tag">限量商品</p> | ||
20 | + {{/ is_limited}} | ||
21 | + {{# is_soon_sold_out}} | ||
22 | + <p class="good-tag soon-sold-out-tag">即将售罄</p> | ||
23 | + {{/ is_soon_sold_out}} | ||
24 | + {{/ tags}} | ||
25 | + </div> | ||
26 | + {{# bannerTop}} | ||
27 | + {{> product/banner-swiper-arrow}} | ||
28 | + {{/ bannerTop}} | ||
29 | + </div> | ||
30 | + {{# goodsName}} | ||
31 | + <h2 class="goods-name"><span>{{.}}</span></h2> | ||
32 | + {{/ goodsName}} | ||
33 | + | ||
34 | + {{# goodsSubtitle}} | ||
35 | + <h1 class="goods-subtitle"><span>{{.}}</span></h1> | ||
36 | + {{/ goodsSubtitle}} | ||
37 | + | ||
38 | + <div class="price-date"> | ||
39 | + {{# goodsPrice}} | ||
40 | + <div class="goods-price"> | ||
41 | + <h1 class="current-price">{{currentPrice}}</h1> | ||
42 | + <h1 class="previous-price">{{previousPrice}}</h1> | ||
43 | + </div> | ||
44 | + {{/ goodsPrice}} | ||
45 | + | ||
46 | + {{^ noLimitGoodsBtn}} | ||
47 | + {{#if canGetLimitCode}} | ||
48 | + <button class="limit-sale" id='limit-sale'>获取限购码</button> | ||
49 | + {{/if}} | ||
50 | + | ||
51 | + {{#if codeEmpty}} | ||
52 | + <button class="got-limit-sale">限购码已被抢光</button> | ||
53 | + {{/if}} | ||
54 | + | ||
55 | + {{#if gotCode}} | ||
56 | + <button class="got-limit-sale">已获取限购码</button> | ||
57 | + {{/if}} | ||
58 | + {{/noLimitGoodsBtn}} | ||
59 | + | ||
60 | + {{#if periodOfMarket}} | ||
61 | + <div class="period-of-market"> | ||
62 | + <h1>上市期:</h1> | ||
63 | + <h1 >{{periodOfMarket}}</h1> | ||
64 | + </div> | ||
65 | + {{/if}} | ||
66 | + </div> | ||
67 | + | ||
68 | + {{# vipLevel}} | ||
69 | + <ul class="vip-level clearfix"> | ||
70 | + {{# list}} | ||
71 | + <li class="icons-item {{#if currentLevel}}current-level{{/if}}"> | ||
72 | + <span class="vip-img " style="background-size:contain;"> | ||
73 | + </span> | ||
74 | + <span class="vip-price ">{{text}}</span> | ||
75 | + </li> | ||
76 | + {{/ list}} | ||
77 | + </ul> | ||
78 | + {{/vipLevel}} | ||
79 | + | ||
80 | + {{# goodsDiscount}} | ||
81 | + <div class="goods-discount" id="goodsDiscount"> | ||
82 | + {{# list}} | ||
83 | + {{#if @first}} | ||
84 | + {{#if text}} | ||
85 | + <h1 class="first-item short-text tap-hightlight">{{text}}<span class="icon-down iconfont dropdown"></span></h1> | ||
86 | + {{/if}} | ||
87 | + {{/if}} | ||
88 | + {{/ list}} | ||
89 | + <div class="discount-folder"> | ||
90 | + {{# list}} | ||
91 | + {{#if @first}} | ||
92 | + {{else}} | ||
93 | + {{#if text}} | ||
94 | + <h1 class="folder-item tap-hightlight">{{text}}</h1> | ||
95 | + {{/if}} | ||
96 | + {{/if}} | ||
97 | + {{/list}} | ||
98 | + </div> | ||
99 | + </div> | ||
100 | + {{/ goodsDiscount}} | ||
101 | + | ||
102 | + {{# feedbacks}} | ||
103 | + <div class="feedback-list "> | ||
104 | + {{#if commentsNum}} | ||
105 | + {{> product/feedback-tab}} | ||
106 | + {{else}} | ||
107 | + {{#if consultsNum}} | ||
108 | + {{> product/feedback-tab}} | ||
109 | + {{else}} | ||
110 | + <div class="nodata tap-hightlight" id="goto-consult"> | ||
111 | + <span>暂无商品评价和咨询</span> | ||
112 | + <a href="{{consultsUrl}}" class="go-consult">我要咨询<span class="iconfont"></span></a> | ||
113 | + </div> | ||
114 | + {{/if}} | ||
115 | + {{/if}} | ||
116 | + </div> | ||
117 | + {{/ feedbacks}} | ||
118 | + | ||
119 | + {{# enterStore}} | ||
120 | + <div id="enter-store" class="enter-store page-block tap-hightlight"> | ||
121 | + <a class="store-logo" href="{{url}}" style=""> | ||
122 | + <img class="lazy" data-original="{{img}}" alt="{{storeName}}"> | ||
123 | + </a> | ||
124 | + <a class="store-name" href="{{url}}">{{storeName}}</a> | ||
125 | + <a class="store-link" href="{{url}}">进入店铺<span class="iconfont"></span></a> | ||
126 | + </div> | ||
127 | + {{/ enterStore}} | ||
128 | + | ||
129 | + <div id="productDesc"> </div> | ||
130 | + {{> product/recommend-for-you}} | ||
131 | + {{> cart/chose-panel}} | ||
132 | + | ||
133 | + {{#cartInfo}} | ||
134 | + <div class="cart-bar"> | ||
135 | + <a href="{{cartUrl}}" class="num-incart iconfont"><span class="num-tag hide"></span></a> | ||
136 | + | ||
137 | + {{#if addToCartUrl}} | ||
138 | + <!-- <a id="addtoCart" href="{{addToCartUrl}}" class="addto-cart">加入购物车</a> --> | ||
139 | + <a id="addtoCart" href="javascript:;" class="addto-cart">加入购物车</a> | ||
140 | + {{/if}} | ||
141 | + | ||
142 | + {{#if soldOut}} | ||
143 | + <a href="javascript:;" class="sold-out">已售罄</a> | ||
144 | + {{/if}} | ||
145 | + | ||
146 | + {{#if notForSale}} | ||
147 | + <a href="javascript:;" class="sold-out">非卖品</a> | ||
148 | + {{/if}} | ||
149 | + | ||
150 | + {{#if limitNotForSale}} | ||
151 | + <a href="javascript:;" class="sold-out limit">即将发售</a> | ||
152 | + {{/if}} | ||
153 | + | ||
154 | + {{#if canBuyLimit}} | ||
155 | + <a href="javascript:;" id="addtoCart" class="addto-cart">立即购买</a> | ||
156 | + {{/if}} | ||
157 | + | ||
158 | + {{#if noLimitCode}} | ||
159 | + <a href="javascript:;" class="sold-out limit">立即购买</a> | ||
160 | + {{/if}} | ||
161 | + <input type="hidden" id="limitCodeUrl" name="limitCodeUrl" value="{{limitCodeUrl}}"> | ||
162 | + <input type="hidden" id="limitProductPay" name="limitProductPay" value="{{limitProductPay}}"> | ||
163 | + {{#limitProductCode}} | ||
164 | + <input type="hidden" id="limitProductCode" name="limitProductCode" value="{{.}}"> | ||
165 | + {{/limitProductCode}} | ||
166 | + | ||
167 | + <a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}"></a> | ||
168 | + </div> | ||
169 | + {{/cartInfo}} | ||
170 | + {{#if introUrl}} | ||
171 | + <input id="introUrl" type="hidden" value="{{introUrl}}"> | ||
172 | + {{/if}} | ||
173 | + {{#if id}} | ||
174 | + <input id="productId" type="hidden" value="{{id}}"> | ||
175 | + {{/if}} | ||
176 | + {{#if preferenceUrl}} | ||
177 | + <input id="preferenceUrl" type="hidden" value="{{preferenceUrl}}"> | ||
178 | + {{/if}} | ||
179 | + | ||
180 | + <input id="productSkn" type="hidden" value="{{productSkn}}"> | ||
181 | + | ||
182 | + {{#loginUrl}} | ||
183 | + <input type="hidden" name="loginUrl" id="loginUrl" value="{{.}}"> | ||
184 | + {{/loginUrl}} | ||
185 | + | ||
186 | +</div> | ||
187 | +{{/ result}} |
apps/product/views/action/detail/intro.hbs
0 → 100644
1 | +{{> product/recommend-content}} |
1 | +<ul id="nav-tab" class="nav-tab clearfix"> | ||
2 | + <li class="comment-nav tap-hightlight">商品评价(<span class="comments-num">{{commentsNum}}</span>)</li> | ||
3 | + <li class="consult-nav tap-hightlight">购买咨询(<span class="consults-num">{{consultsNum}}</span>)</li> | ||
4 | +</ul> | ||
5 | +<div id="feedback-content" > | ||
6 | + <div class="comment-content content "> | ||
7 | + {{#if commentsNum}} | ||
8 | + <div class="comment-content-main content-main"> | ||
9 | + {{# comments}} | ||
10 | + <span class="user-name"> | ||
11 | + {{userName}} | ||
12 | + </span> | ||
13 | + <span class="goods-spec"> | ||
14 | + 购买了{{desc}} | ||
15 | + </span> | ||
16 | + <p class="detail-content"> | ||
17 | + {{content}} | ||
18 | + </p> | ||
19 | + <span class="comment-time"> | ||
20 | + {{time}} | ||
21 | + </span> | ||
22 | + {{/ comments}} | ||
23 | + </div> | ||
24 | + <a class="comment-content-footer tap-hightlight" href="{{commentsUrl}}"> | ||
25 | + 查看更多 | ||
26 | + <span class="iconfont"></span> | ||
27 | + </a> | ||
28 | + {{^}} | ||
29 | + <div class="comment-content-main content-main no-item"> | ||
30 | + <span class="iconfont"></span>暂无评论 | ||
31 | + </div> | ||
32 | + {{/if}} | ||
33 | + </div> | ||
34 | + | ||
35 | + <div class="consult-content content hide "> | ||
36 | + {{#if consultsNum}} | ||
37 | + <div class="consult-content-main content-main"> | ||
38 | + {{# consults}} | ||
39 | + <div class="question"> | ||
40 | + <span class="iconfont"></span> | ||
41 | + <p> | ||
42 | + {{question}}<br> | ||
43 | + <span class="time">{{time}}</span> | ||
44 | + </p> | ||
45 | + </div> | ||
46 | + | ||
47 | + <div class="answer"> | ||
48 | + <span class="iconfont"></span> | ||
49 | + <p>{{answer}}</p> | ||
50 | + </div> | ||
51 | + {{/ consults}} | ||
52 | + </div> | ||
53 | + <a class="consult-content-footer tap-hightlight" href="{{consultsUrl}}"> | ||
54 | + 查看更多 | ||
55 | + <span class="iconfont"></span> | ||
56 | + </a> | ||
57 | + {{else}} | ||
58 | + <div class="consult-content-main content-main no-item"> | ||
59 | + <span class="iconfont"></span>暂无咨询 | ||
60 | + </div> | ||
61 | + | ||
62 | + <div class="consult-content-footer tap-hightlight"> | ||
63 | + <a href="{{consultsUrl}}"> | ||
64 | + 我要咨询 | ||
65 | + <span class="iconfont"></span></a> | ||
66 | + </div> | ||
67 | + {{/if}} | ||
68 | + </div> | ||
69 | +</div> |
1 | +{{#goodsDescription}} | ||
2 | +<div class="goods-desc page-block"> | ||
3 | + <div class="service"></div> | ||
4 | + <h1 class="title"> | ||
5 | + {{title}} | ||
6 | + <span class="en-title">{{enTitle}}</span> | ||
7 | + </h1> | ||
8 | + {{#detail}} | ||
9 | + <div class="detail table"> | ||
10 | + {{#list}} | ||
11 | + <div class="column">{{param}}</div> | ||
12 | + {{/list}} | ||
13 | + </div> | ||
14 | + {{/detail}} | ||
15 | + {{#if desc}} | ||
16 | + <div class="desc-text">{{desc}}</div> | ||
17 | + {{/if}} | ||
18 | +</div> | ||
19 | + | ||
20 | +{{/goodsDescription}} | ||
21 | + | ||
22 | +{{#sizeInfo}} | ||
23 | +<div class="size-info page-block"> | ||
24 | +<h1 class="title"> | ||
25 | + {{title}} | ||
26 | + <span class="en-title">{{enTitle}}</span> | ||
27 | +</h1> | ||
28 | +{{#detail}} | ||
29 | +<div class="detail"> | ||
30 | + <div class="swiper-container detail-swiper" id="size-swiper-container"> | ||
31 | + <div class="swiper-wrapper"> | ||
32 | + {{#list}} | ||
33 | + <div class="swiper-slide " > | ||
34 | + {{#params}} | ||
35 | + <div class="cell">{{param}}</div> | ||
36 | + {{/params}} | ||
37 | + </div> | ||
38 | + {{/list}} | ||
39 | + </div> | ||
40 | + </div> | ||
41 | + <p class="tips">提示:左滑查看完整表格信息</p> | ||
42 | +</div> | ||
43 | +{{/detail}} | ||
44 | +</div> | ||
45 | +{{/sizeInfo}} | ||
46 | + | ||
47 | +{{#measurementMethod}} | ||
48 | +<div class="measurement-method page-block"> | ||
49 | +<h1 class="title"> | ||
50 | + {{title}} | ||
51 | + <span class="en-title">{{enTitle}}</span> | ||
52 | +</h1> | ||
53 | +<div class="detail" style="width:100%"> | ||
54 | + <img class="lazy" data-original="{{img}}" alt=""> | ||
55 | +</div> | ||
56 | +</div> | ||
57 | +{{/measurementMethod}} | ||
58 | + | ||
59 | +{{#reference}} | ||
60 | +<div class="size-info page-block"> | ||
61 | + <h1 class="title"> | ||
62 | + {{title}} | ||
63 | + <span class="en-title">{{enTitle}}</span> | ||
64 | + </h1> | ||
65 | + {{#detail}} | ||
66 | + <div class="detail"> | ||
67 | + <div class="swiper-container detail-swiper" id="reference-swiper-container"> | ||
68 | + <div class="swiper-wrapper"> | ||
69 | + {{#list}} | ||
70 | + {{#if @first}} | ||
71 | + <div class="swiper-slide first-group" > | ||
72 | + {{#params}} | ||
73 | + {{#if @first}} | ||
74 | + {{else}} | ||
75 | + <div> | ||
76 | + <img class="avatar lazy" data-original="{{param}}" alt=""> | ||
77 | + </div> | ||
78 | + {{/if}} | ||
79 | + {{/params}} | ||
80 | + </div> | ||
81 | + {{else}} | ||
82 | + <div class="swiper-slide" > | ||
83 | + {{#params}} | ||
84 | + <div class=" cell">{{param}}</div> | ||
85 | + {{/params}} | ||
86 | + </div> | ||
87 | + {{/if}} | ||
88 | + {{/list}} | ||
89 | + </div> | ||
90 | + </div> | ||
91 | + <p class="tips">提示:左滑查看完整表格信息</p> | ||
92 | + </div> | ||
93 | + {{/detail}} | ||
94 | +</div> | ||
95 | +{{/reference}} | ||
96 | + | ||
97 | +{{#materials}} | ||
98 | +<div class="materials page-block"> | ||
99 | + <h1 class="title"> | ||
100 | + {{title}} | ||
101 | + <span class="en-title">{{enTitle}}</span> | ||
102 | + </h1> | ||
103 | + <div class="detail"> | ||
104 | + {{#list}} | ||
105 | + <div class="material-item"> | ||
106 | + <!-- <img class="lazy" data-original="{{img}}" alt=""> | ||
107 | + <p class="material-desc"> | ||
108 | + {{desc}} | ||
109 | + </p>--> | ||
110 | + <div class="material-image"> | ||
111 | + <img src="{{img}}" alt="材质图"> | ||
112 | + </div> | ||
113 | + <div class="material-desc"> | ||
114 | + {{desc}} | ||
115 | + </div> | ||
116 | + </div> | ||
117 | + {{/list}} | ||
118 | + </div> | ||
119 | +</div> | ||
120 | +{{/materials}} | ||
121 | + | ||
122 | +{{#washTips}} | ||
123 | +<div class="wash-tips page-block"> | ||
124 | + <div class="detail table clearfix"> | ||
125 | + {{#list}} | ||
126 | + <div class="tip"> | ||
127 | + <img src="{{img}}" alt=""> | ||
128 | + <span class="caption">{{caption}}</span> | ||
129 | + </div> | ||
130 | + {{/list}} | ||
131 | + </div> | ||
132 | +</div> | ||
133 | +{{/washTips}} | ||
134 | + | ||
135 | +{{#productDetail}} | ||
136 | +<div class="product-detail page-block"> | ||
137 | + <h1 class="title"> | ||
138 | + {{{title}}} | ||
139 | + <span class="en-title">{{{enTitle}}}</span> | ||
140 | + </h1> | ||
141 | + <div class="pro-detail"> | ||
142 | + <p>{{{desc}}}</p> | ||
143 | + {{#list}} | ||
144 | + <img class="lazy" data-original="{{img}}" alt=""> | ||
145 | + {{/list}} | ||
146 | + </div> | ||
147 | +</div> | ||
148 | +{{/productDetail}} |
1 | +<div class="title">为您优选新品</div> | ||
2 | +<div id="swiper-recommend" class="swiper-container"> | ||
3 | + <div class="swiper-wrapper swiper-wrapper-recommend"> | ||
4 | + {{#recommendList}} | ||
5 | + <a class="swiper-slide" href="{{url}}"> | ||
6 | + <img class="swiper-lazy img-box" data-src="{{thumb}}"> | ||
7 | + <div class="sale-name"> | ||
8 | + {{name}} | ||
9 | + </div> | ||
10 | + <div class="price"> | ||
11 | + <span class="sale-price {{^price}}no-price{{/price}}">¥{{salePrice}}</span> | ||
12 | + {{#price}}<span class="old-price">¥{{.}}</span>{{/price}} | ||
13 | + </div> | ||
14 | + <div class="swiper-lazy-preloader"></div> | ||
15 | + </a> | ||
16 | + {{/recommendList}} | ||
17 | + </div> | ||
18 | +</div> |
@@ -7,6 +7,7 @@ var $ = require('yoho-jquery'), | @@ -7,6 +7,7 @@ var $ = require('yoho-jquery'), | ||
7 | Swiper = require('yoho-swiper'), | 7 | Swiper = require('yoho-swiper'), |
8 | Hammer = require('yoho-hammer'), | 8 | Hammer = require('yoho-hammer'), |
9 | lazyLoad = require('yoho-jquery-lazyload'); | 9 | lazyLoad = require('yoho-jquery-lazyload'); |
10 | + | ||
10 | // commonJS = require('../common'); | 11 | // commonJS = require('../common'); |
11 | 12 | ||
12 | var $discountFolder = $('.goodsDiscount .discount-folder'), | 13 | var $discountFolder = $('.goodsDiscount .discount-folder'), |
1 | +/** | ||
2 | + * 商品详情 --评论和咨询tab | ||
3 | + * @author: Lynnic | ||
4 | + * @date: 2015/11/18 | ||
5 | + */ | ||
6 | +var $ = require('yoho-jquery'), | ||
7 | + tip = require('../../plugin/tip'), | ||
8 | + Hammer = require('yoho-hammer'); | ||
9 | + | ||
10 | +var commentsNum, consultsNum; | ||
11 | + | ||
12 | +var navtabEle = document.getElementById('nav-tab'), | ||
13 | + navtabHammer = navtabEle && new Hammer(navtabEle), | ||
14 | + | ||
15 | + gotoConsultEle = document.getElementById('goto-consult'), | ||
16 | + gotoConsultHammer = gotoConsultEle && new Hammer(gotoConsultEle), | ||
17 | + | ||
18 | + readmore = document.getElementById('readmore'), | ||
19 | + readmoreHammer = readmore && new Hammer(readmore); | ||
20 | + | ||
21 | + | ||
22 | + | ||
23 | +(function() { | ||
24 | + consultsNum = $('#nav-tab .consults-num').html() - 0; | ||
25 | + | ||
26 | + commentsNum = $('#nav-tab .comments-num').html() - 0; | ||
27 | + | ||
28 | + $('#nav-tab li').each(function() { | ||
29 | + $(this).removeClass('focus'); | ||
30 | + }); | ||
31 | + | ||
32 | + $('#feedback-content .content').each(function() { | ||
33 | + $(this).addClass('hide'); | ||
34 | + }); | ||
35 | + if (commentsNum !== 0) { | ||
36 | + $('#nav-tab .comment-nav').addClass('focus'); | ||
37 | + $('#feedback-content .comment-content').removeClass('hide'); | ||
38 | + | ||
39 | + } else if (consultsNum !== 0) { | ||
40 | + $('#nav-tab .consult-nav').addClass('focus'); | ||
41 | + $('#feedback-content .consult-content').removeClass('hide'); | ||
42 | + } | ||
43 | + | ||
44 | +}()); | ||
45 | + | ||
46 | +if (navtabHammer) { | ||
47 | + navtabHammer.on('tap', function(e) { | ||
48 | + var $this = $(e.target).closest('li'); | ||
49 | + var index = $this.index(); | ||
50 | + | ||
51 | + if ($this.hasClass('comment-nav') && commentsNum === 0) { | ||
52 | + tip.show('暂无商品评价'); | ||
53 | + } else { | ||
54 | + if (!$this.hasClass('focus')) { | ||
55 | + | ||
56 | + $('#nav-tab li').each(function() { | ||
57 | + $(this).removeClass('focus'); | ||
58 | + }); | ||
59 | + $('#feedback-content .content').each(function() { | ||
60 | + $(this).addClass('hide'); | ||
61 | + }); | ||
62 | + | ||
63 | + $this.addClass('focus'); | ||
64 | + $('#feedback-content .content:eq(' + index + ')').removeClass('hide'); | ||
65 | + } | ||
66 | + } | ||
67 | + }); | ||
68 | +} | ||
69 | + | ||
70 | +// if (consultFooterHammer) { | ||
71 | +// consultFooterHammer.on('tap', function() { | ||
72 | +// location.href = $(consultFooterEle).data('href'); | ||
73 | +// }); | ||
74 | +// } | ||
75 | + | ||
76 | +if (gotoConsultHammer) { | ||
77 | + gotoConsultHammer.on('tap', function() { | ||
78 | + location.href = $(gotoConsultEle).find('a').attr('href'); | ||
79 | + }); | ||
80 | +} | ||
81 | + | ||
82 | +// 咨询页面固定header | ||
83 | +if ($('.goods-consults-page').length > 0) { | ||
84 | + $('#yoho-header').css('position', 'fixed').css('top', '0'); | ||
85 | +} | ||
86 | + | ||
87 | +if ($('.goods-consults-page').length > 0) { | ||
88 | + $('#yoho-footer').css('border-top', '1px solid #e0e0e0'); | ||
89 | +} | ||
90 | + | ||
91 | +if (readmoreHammer) { | ||
92 | + readmoreHammer.on('tap', function() { | ||
93 | + $('.readmore').hide(); | ||
94 | + $('.goods-consults.customer-consults').removeClass('customer-consults'); | ||
95 | + | ||
96 | + return false; | ||
97 | + }); | ||
98 | +} | ||
99 | + | ||
100 | +require('./fav'); |
public/js/product/detail/consultform.js
0 → 100644
1 | +/** | ||
2 | + * 我要咨询提交页面 | ||
3 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
4 | + * @date: 2015/12/01 | ||
5 | + */ | ||
6 | +var $ = require('yoho-jquery'), | ||
7 | + tip = require('../../plugin/tip'), | ||
8 | + loading = require('../../plugin/loading'); | ||
9 | + | ||
10 | +var $consultForm = $('.consult-form'), | ||
11 | + $submit = $('#submit'), | ||
12 | + $content = $('#content'), | ||
13 | + productId = $('#product_id').val(), | ||
14 | + isSubmiting; | ||
15 | + | ||
16 | +$submit.on('touchend', function() { | ||
17 | + $content.blur(); | ||
18 | + $consultForm.submit(); | ||
19 | + return false; | ||
20 | +}).on('touchstart', function() { | ||
21 | + $(this).addClass('highlight'); | ||
22 | +}).on('touchend touchcancel', function() { | ||
23 | + $(this).removeClass('highlight'); | ||
24 | +}); | ||
25 | + | ||
26 | +$content.on('focus', function() { | ||
27 | + if ($content.val() === '请输入咨询内容') { | ||
28 | + $content.val(''); | ||
29 | + } | ||
30 | +}).on('blur', function() { | ||
31 | + if ($content.val() === '') { | ||
32 | + $content.val('请输入咨询内容'); | ||
33 | + } | ||
34 | +}); | ||
35 | + | ||
36 | +// 提交表单请求 | ||
37 | +$consultForm.on('submit', function() { | ||
38 | + var content; | ||
39 | + | ||
40 | + if (isSubmiting) { | ||
41 | + return false; | ||
42 | + } | ||
43 | + | ||
44 | + // 简单的表单校验 | ||
45 | + content = $content.val(); | ||
46 | + if (!content || content === '请输入咨询内容') { | ||
47 | + tip.show('咨询内容不能为空'); | ||
48 | + return false; | ||
49 | + } | ||
50 | + | ||
51 | + isSubmiting = true; | ||
52 | + loading.showLoadingMask(); | ||
53 | + $.ajax({ | ||
54 | + method: 'POST', | ||
55 | + url: '/product/detail/consultsubmit', | ||
56 | + data: { | ||
57 | + product_id: productId, | ||
58 | + content: content | ||
59 | + } | ||
60 | + }).then(function(res) { | ||
61 | + if ($.type(res) !== 'object') { | ||
62 | + res = {}; | ||
63 | + } | ||
64 | + if (res.code !== 200) { | ||
65 | + tip.show(res.message || '网络出了点问题~'); | ||
66 | + isSubmiting = false; | ||
67 | + loading.hideLoadingMask(); | ||
68 | + } else { | ||
69 | + tip.show('提交成功~'); | ||
70 | + setTimeout(function() { | ||
71 | + window.history.go(-1); | ||
72 | + }, 3000); | ||
73 | + } | ||
74 | + }).fail(function() { | ||
75 | + tip.show('网络出了点问题~'); | ||
76 | + isSubmiting = false; | ||
77 | + }); | ||
78 | + return false; | ||
79 | +}); |
public/js/product/detail/desc.js
0 → 100644
1 | +/** | ||
2 | + * 商品详情 --异步加载页面下半部分 | ||
3 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
4 | + * @date: 2015/11/18 | ||
5 | + */ | ||
6 | +var $ = require('yoho-jquery'), | ||
7 | + lazyLoad = require('yoho-jquery-lazyload'), | ||
8 | + Swiper = require('yoho-swiper'), | ||
9 | + loading = require('../../plugin/loading'), | ||
10 | + tip = require('../../plugin/tip'); | ||
11 | + | ||
12 | +var introUrl = $('#introUrl').val(), | ||
13 | + winH = $(window).height(), | ||
14 | + $productDesc, | ||
15 | + searching = false, | ||
16 | + end = false; | ||
17 | + | ||
18 | +// 判断是否要显示向左滑动提示 | ||
19 | +function hiddenTips($ele) { | ||
20 | + var offsetContainer, | ||
21 | + offsetLastColumn; | ||
22 | + | ||
23 | + if ($ele.length > 0) { | ||
24 | + offsetContainer = $ele[0].getBoundingClientRect().right; | ||
25 | + offsetLastColumn = $ele.find('.swiper-slide:last-child')[0].getBoundingClientRect().right; | ||
26 | + | ||
27 | + | ||
28 | + if (offsetLastColumn - offsetContainer < 0) { | ||
29 | + $ele.next('.tips').css('display', 'none'); | ||
30 | + } else { | ||
31 | + $ele.next('.tips').css('display', 'block'); | ||
32 | + } | ||
33 | + } | ||
34 | +} | ||
35 | + | ||
36 | +// function isFlexSupport() { | ||
37 | +// var flex = document.createElement('p').style.flex, | ||
38 | +// webkitFlex = document.createElement('p').style.webkitFlex, | ||
39 | +// flexWrap = document.createElement('p').style.flexWrap; | ||
40 | +// | ||
41 | +// if ((flex === '' || webkitFlex === '') && flexWrap === '') { | ||
42 | +// return true; | ||
43 | +// } else { | ||
44 | +// return false; | ||
45 | +// } | ||
46 | +// } | ||
47 | + | ||
48 | +function wrapElements(selector, count) { | ||
49 | + var elArr = null; | ||
50 | + | ||
51 | + $(selector).each(function(idx) { | ||
52 | + elArr = $(selector).slice(idx, idx + count); | ||
53 | + | ||
54 | + if (elArr.length === count && idx % count === 0) { | ||
55 | + $(elArr).wrapAll($('<div class="js-wraper"></div>')); | ||
56 | + } | ||
57 | + }); | ||
58 | +} | ||
59 | + | ||
60 | + | ||
61 | + | ||
62 | +function search() { | ||
63 | + if (searching || end) { | ||
64 | + return; | ||
65 | + } | ||
66 | + searching = true; | ||
67 | + | ||
68 | + // alert($('#reference-swiper-container .swiper-wrapper').width()); | ||
69 | + | ||
70 | + loading.showLoadingMask(); | ||
71 | + | ||
72 | + $.ajax({ | ||
73 | + type: 'GET', | ||
74 | + url: introUrl, | ||
75 | + success: function(data) { | ||
76 | + $productDesc = $('#productDesc'); | ||
77 | + $productDesc.append(data); | ||
78 | + | ||
79 | + window.rePosFooter(); | ||
80 | + | ||
81 | + lazyLoad($productDesc.find('img.lazy')); | ||
82 | + | ||
83 | + // 尺码信息左右滑动 | ||
84 | + new Swiper('#size-swiper-container', { | ||
85 | + slidesPerView: 'auto' | ||
86 | + }); | ||
87 | + | ||
88 | + // 模特试穿左右滑动 | ||
89 | + new Swiper('#reference-swiper-container', { | ||
90 | + slidesPerView: 'auto' | ||
91 | + }); | ||
92 | + | ||
93 | + hiddenTips($('#size-swiper-container')); | ||
94 | + hiddenTips($('#reference-swiper-container')); | ||
95 | + | ||
96 | + // if (!isFlexSupport()) { | ||
97 | + // $('.detail .column').removeClass('column').addClass('oldbox'); | ||
98 | + // } | ||
99 | + wrapElements('.detail .column', 2); | ||
100 | + searching = false; | ||
101 | + end = true; | ||
102 | + loading.hideLoadingMask(); | ||
103 | + }, | ||
104 | + error: function() { | ||
105 | + tip.show('网络断开连接了~'); | ||
106 | + searching = false; | ||
107 | + loading.hideLoadingMask(); | ||
108 | + } | ||
109 | + }); | ||
110 | +} | ||
111 | + | ||
112 | +function scrollHandler() { | ||
113 | + if (!end || $(window).scrollTop() + winH >= $(document).height() - 200) { | ||
114 | + search(); | ||
115 | + } | ||
116 | +} | ||
117 | + | ||
118 | +// srcoll to load more | ||
119 | +$(window).scroll(function() { | ||
120 | + window.requestAnimationFrame(scrollHandler); | ||
121 | +}); | ||
122 | + |
public/js/product/detail/fav.js
0 → 100755
1 | +/** | ||
2 | + * 商品详情咨询页 --点赞和帮助功能 | ||
3 | + * @author: Lynnic | ||
4 | + * @date: 2015/12/09 | ||
5 | + */ | ||
6 | + | ||
7 | + var $ = require('yoho-jquery'), | ||
8 | + Hammer = require('yoho-hammer'), | ||
9 | + tip = require('../../plugin/tip'); | ||
10 | + | ||
11 | + var goodsConsultsEle = $('#goods-consults')[0], | ||
12 | + goodsConsultsHammer = goodsConsultsEle && new Hammer(goodsConsultsEle); | ||
13 | + | ||
14 | + var productId, | ||
15 | + total; | ||
16 | + | ||
17 | + function showCountPlus($el) { | ||
18 | + var $count = $el.find('.animate-count'); | ||
19 | + | ||
20 | + $count.css('display', 'inline'); | ||
21 | + $count.animate({ | ||
22 | + opacity: 0.25, | ||
23 | + fontSize: '0.7rem', | ||
24 | + right: '-=5' | ||
25 | + }, 300, function() { | ||
26 | + $count.css('display', 'none'); | ||
27 | + }); | ||
28 | + } | ||
29 | + | ||
30 | + (function() { | ||
31 | + var queryStr = window.location.search.substring(1); | ||
32 | + | ||
33 | + productId = queryStr.split('&')[0].split('=')[1]; | ||
34 | + total = queryStr.split('&')[1] ? queryStr.split('&')[1].split('=')[1] : undefined; | ||
35 | + }()); | ||
36 | + | ||
37 | + if (goodsConsultsHammer) { | ||
38 | + | ||
39 | + goodsConsultsHammer.on('tap', function(e) { | ||
40 | + | ||
41 | + var $this = $(e.target).closest('li'), | ||
42 | + id = $this.closest('.consult-item').data('id'), | ||
43 | + count = $this.find('.count').html() - 0, | ||
44 | + url; | ||
45 | + | ||
46 | + if (!$this.hasClass('highlight')) { | ||
47 | + | ||
48 | + if ($this.hasClass('fav')) { | ||
49 | + url = '/product/detail/consultupvote'; | ||
50 | + } else if ($this.hasClass('useful')) { | ||
51 | + url = '/product/detail/consultuseful'; | ||
52 | + } | ||
53 | + | ||
54 | + $.ajax({ | ||
55 | + method: 'post', | ||
56 | + url: url, | ||
57 | + data: { | ||
58 | + id: id, | ||
59 | + productId: productId, | ||
60 | + total: total | ||
61 | + } | ||
62 | + }).done(function(data) { | ||
63 | + if (data.code === 200) { | ||
64 | + showCountPlus($this); | ||
65 | + $this.addClass('highlight'); | ||
66 | + $this.find('.count').html(count + 1); | ||
67 | + } else if (data.code === 401) { | ||
68 | + location.href = data.data;// 未登录跳转登录页 | ||
69 | + } | ||
70 | + }).fail(function() { | ||
71 | + tip.show('网络断开连接了~'); | ||
72 | + }); | ||
73 | + | ||
74 | + } | ||
75 | + }); | ||
76 | + } |
public/js/product/detail/like.js
0 → 100644
1 | +/** | ||
2 | + * 商品详情 --添加收藏 | ||
3 | + * @author: Lynnic | ||
4 | + * @date: 2015/11/24 | ||
5 | + */ | ||
6 | + | ||
7 | + | ||
8 | +var $ = require('yoho-jquery'), | ||
9 | + tip = require('../../plugin/tip'), | ||
10 | + chosePanel = require('../../cart/chose-panel'); | ||
11 | + | ||
12 | +var productId = $('#productId').val(); | ||
13 | + | ||
14 | +var skn = $('#productSkn').val(), | ||
15 | + productCode = $('#limitProductCode').val(); | ||
16 | + | ||
17 | +$('#likeBtn').on('touchstart', function() { | ||
18 | + var opt, | ||
19 | + favorite; | ||
20 | + | ||
21 | + var $this = $(this); | ||
22 | + | ||
23 | + if ($this.hasClass('liked')) { | ||
24 | + opt = 'cancel'; | ||
25 | + favorite = 0; | ||
26 | + } else { | ||
27 | + opt = 'ok'; | ||
28 | + favorite = 1; | ||
29 | + } | ||
30 | + | ||
31 | + $.ajax({ | ||
32 | + type: 'POST', | ||
33 | + url: '/product/opt/favoriteProduct', | ||
34 | + data: { | ||
35 | + id: productId, | ||
36 | + opt: opt | ||
37 | + }, | ||
38 | + success: function(data) { | ||
39 | + if (data.code === 200) { | ||
40 | + $this.toggleClass('liked'); | ||
41 | + | ||
42 | + if (opt === 'cancel') { | ||
43 | + tip.show('取消收藏成功'); | ||
44 | + } else if (opt === 'ok') { | ||
45 | + tip.show('收藏成功'); | ||
46 | + } | ||
47 | + } else if (data.code === 400) { | ||
48 | + location.href = data.data;// 未登录跳转登录页 | ||
49 | + } else { | ||
50 | + tip.show(data.message); | ||
51 | + } | ||
52 | + }, | ||
53 | + error: function() { | ||
54 | + tip.show('网络断开连接了~'); | ||
55 | + } | ||
56 | + }); | ||
57 | + | ||
58 | + // 统计代码:用于统计用户加入或取消商品收藏的动作 | ||
59 | + if (window._yas) { | ||
60 | + window._yas.sendCustomInfo({ | ||
61 | + pd: productId, | ||
62 | + fa: favorite | ||
63 | + }, true); | ||
64 | + } | ||
65 | + | ||
66 | + return false; | ||
67 | +}); | ||
68 | + | ||
69 | +$('#addtoCart').on('touchstart', function() { | ||
70 | + $('.cart-bar').hide(); | ||
71 | + productCode && chosePanel.setLimitGoodModeWithSknId(productCode, skn); | ||
72 | + chosePanel.show(); | ||
73 | + | ||
74 | + // 统计代码:用于统计用户加入购物车的动作 | ||
75 | + if (window._yas) { | ||
76 | + window._yas.sendCustomInfo({ | ||
77 | + pd: productId, | ||
78 | + by: 1 | ||
79 | + }, true); | ||
80 | + } | ||
81 | + | ||
82 | + return false; | ||
83 | +}); |
1 | +/** | ||
2 | + * 为您优选 | ||
3 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
4 | + * @date: 2015/11/16 | ||
5 | + */ | ||
6 | + | ||
7 | + | ||
8 | +var Swiper = require('yoho-swiper'), | ||
9 | + $ = require('yoho-jquery'); | ||
10 | + | ||
11 | +var $recommendForYou = $('.recommend-for-you'), | ||
12 | + preferenceUrl = $('#preferenceUrl').val(), | ||
13 | + winH = $(window).height(), | ||
14 | + end = false, | ||
15 | + requesting = false; | ||
16 | + | ||
17 | + | ||
18 | +function request() { | ||
19 | + if (requesting || end) { | ||
20 | + return; | ||
21 | + } | ||
22 | + | ||
23 | + requesting = true; | ||
24 | + | ||
25 | + if (preferenceUrl) { | ||
26 | + $.get(preferenceUrl).then(function(html) { | ||
27 | + if (html.length < 5) { | ||
28 | + $recommendForYou.css('display', 'none'); | ||
29 | + } else { | ||
30 | + $recommendForYou.html(html).show(); | ||
31 | + if ($('#swiper-recommend').length) { | ||
32 | + new Swiper('#swiper-recommend', { | ||
33 | + slidesPerView: 'auto', | ||
34 | + grabCursor: true, | ||
35 | + slideElement: 'a', | ||
36 | + lazyLoading: true, | ||
37 | + watchSlidesVisibility: true | ||
38 | + }); | ||
39 | + } | ||
40 | + } | ||
41 | + | ||
42 | + requesting = false; | ||
43 | + end = true; | ||
44 | + | ||
45 | + window.rePosFooter(); | ||
46 | + | ||
47 | + }).fail(function() { | ||
48 | + $recommendForYou.hide(); | ||
49 | + }); | ||
50 | + } | ||
51 | +} | ||
52 | + | ||
53 | +function scrollHandler() { | ||
54 | + if (!end || $(window).scrollTop() + winH >= $(document).height() - 200) { | ||
55 | + request(); | ||
56 | + } | ||
57 | +} | ||
58 | + | ||
59 | +$(window).scroll(function() { | ||
60 | + window.requestAnimationFrame(scrollHandler); | ||
61 | +}); |
-
Please register or login to post a comment