Showing
1 changed file
with
1 additions
and
1255 deletions
1 | -(function ($) { | ||
2 | -'use strict'; | ||
3 | - | ||
4 | -function __$styleInject(css, returnValue) { | ||
5 | - if (typeof document === 'undefined') { | ||
6 | - return returnValue; | ||
7 | - } | ||
8 | - css = css || ''; | ||
9 | - var head = document.head || document.getElementsByTagName('head')[0]; | ||
10 | - var style = document.createElement('style'); | ||
11 | - style.type = 'text/css'; | ||
12 | - head.appendChild(style); | ||
13 | - | ||
14 | - if (style.styleSheet){ | ||
15 | - style.styleSheet.cssText = css; | ||
16 | - } else { | ||
17 | - style.appendChild(document.createTextNode(css)); | ||
18 | - } | ||
19 | - return returnValue; | ||
20 | -} | ||
21 | - | ||
22 | -$ = 'default' in $ ? $['default'] : $; | ||
23 | - | ||
24 | -/* eslint-disable */ | ||
25 | -// Noop | ||
26 | -function noop() {} | ||
27 | - | ||
28 | -// Generic callback | ||
29 | -function genericCallback(data) { | ||
30 | - lastValue = [data]; | ||
31 | -} | ||
32 | - | ||
33 | -// Call if defined | ||
34 | -function callIfDefined(method, object, parameters) { | ||
35 | - return method && method.apply && method.apply(object.context || object, parameters); | ||
36 | -} | ||
37 | - | ||
38 | -// Give joining character given url | ||
39 | -function qMarkOrAmp(url) { | ||
40 | - return (/\?/.test(url) ? "&" : "?" | ||
41 | - ); | ||
42 | -} | ||
43 | - | ||
44 | -var STR_ASYNC = "async"; | ||
45 | -var STR_CHARSET = "charset"; | ||
46 | -var STR_EMPTY = ""; | ||
47 | -var STR_ERROR = "error"; | ||
48 | -var STR_INSERT_BEFORE = "insertBefore"; | ||
49 | -var STR_JQUERY_JSONP = "_jqjsp"; | ||
50 | -var STR_ON = "on"; | ||
51 | -var STR_ON_CLICK = STR_ON + "click"; | ||
52 | -var STR_ON_ERROR = STR_ON + STR_ERROR; | ||
53 | -var STR_ON_LOAD = STR_ON + "load"; | ||
54 | -var STR_ON_READY_STATE_CHANGE = STR_ON + "readystatechange"; | ||
55 | -var STR_READY_STATE = "readyState"; | ||
56 | -var STR_REMOVE_CHILD = "removeChild"; | ||
57 | -var STR_SCRIPT_TAG = "<script>"; | ||
58 | -var STR_SUCCESS = "success"; | ||
59 | -var STR_TIMEOUT = "timeout"; | ||
60 | -var win = window; | ||
61 | -var Deferred = $.Deferred; | ||
62 | -var head = $("head")[0] || document.documentElement; | ||
63 | -var pageCache = {}; | ||
64 | -var count = 0; | ||
65 | -var lastValue; | ||
66 | -var xOptionsDefaults = { | ||
67 | - //beforeSend: undefined, | ||
68 | - //cache: false, | ||
69 | - callback: STR_JQUERY_JSONP, | ||
70 | - //callbackParameter: undefined, | ||
71 | - //charset: undefined, | ||
72 | - //complete: undefined, | ||
73 | - //context: undefined, | ||
74 | - //data: "", | ||
75 | - //dataFilter: undefined, | ||
76 | - //error: undefined, | ||
77 | - //pageCache: false, | ||
78 | - //success: undefined, | ||
79 | - //timeout: 0, | ||
80 | - //traditional: false, | ||
81 | - url: location.href | ||
82 | -}; | ||
83 | -var opera = win.opera; | ||
84 | -var oldIE = !!$("<div>").html("<!--[if IE]><i><![endif]-->").find("i").length; | ||
85 | - | ||
86 | -// ###################### MAIN FUNCTION ## | ||
87 | -function jsonp(xOptions) { | ||
88 | - | ||
89 | - // Build data with default | ||
90 | - xOptions = $.extend({}, xOptionsDefaults, xOptions); | ||
91 | - | ||
92 | - // References to xOptions members (for better minification) | ||
93 | - var successCallback = xOptions.success, | ||
94 | - errorCallback = xOptions.error, | ||
95 | - completeCallback = xOptions.complete, | ||
96 | - dataFilter = xOptions.dataFilter, | ||
97 | - callbackParameter = xOptions.callbackParameter, | ||
98 | - successCallbackName = xOptions.callback, | ||
99 | - cacheFlag = xOptions.cache, | ||
100 | - pageCacheFlag = xOptions.pageCache, | ||
101 | - charset = xOptions.charset, | ||
102 | - url = xOptions.url, | ||
103 | - data = xOptions.data, | ||
104 | - timeout = xOptions.timeout, | ||
105 | - pageCached, | ||
106 | - | ||
107 | - | ||
108 | - // Abort/done flag | ||
109 | - done = 0, | ||
110 | - | ||
111 | - | ||
112 | - // Life-cycle functions | ||
113 | - cleanUp = noop, | ||
114 | - | ||
115 | - | ||
116 | - // Support vars | ||
117 | - supportOnload, | ||
118 | - supportOnreadystatechange, | ||
119 | - | ||
120 | - | ||
121 | - // Request execution vars | ||
122 | - firstChild, | ||
123 | - script, | ||
124 | - scriptAfter, | ||
125 | - timeoutTimer; | ||
126 | - | ||
127 | - // If we have Deferreds: | ||
128 | - // - substitute callbacks | ||
129 | - // - promote xOptions to a promise | ||
130 | - Deferred && Deferred(function (defer) { | ||
131 | - defer.done(successCallback).fail(errorCallback); | ||
132 | - successCallback = defer.resolve; | ||
133 | - errorCallback = defer.reject; | ||
134 | - }).promise(xOptions); | ||
135 | - | ||
136 | - // Create the abort method | ||
137 | - xOptions.abort = function () { | ||
138 | - !done++ && cleanUp(); | ||
139 | - }; | ||
140 | - | ||
141 | - // Call beforeSend if provided (early abort if false returned) | ||
142 | - if (callIfDefined(xOptions.beforeSend, xOptions, [xOptions]) === !1 || done) { | ||
143 | - return xOptions; | ||
144 | - } | ||
145 | - | ||
146 | - // Control entries | ||
147 | - url = url || STR_EMPTY; | ||
148 | - data = data ? typeof data == "string" ? data : $.param(data, xOptions.traditional) : STR_EMPTY; | ||
149 | - | ||
150 | - // Build final url | ||
151 | - url += data ? qMarkOrAmp(url) + data : STR_EMPTY; | ||
152 | - | ||
153 | - // Add callback parameter if provided as option | ||
154 | - callbackParameter && (url += qMarkOrAmp(url) + encodeURIComponent(callbackParameter) + "=?"); | ||
155 | - | ||
156 | - // Add anticache parameter if needed | ||
157 | - !cacheFlag && !pageCacheFlag && (url += qMarkOrAmp(url) + "_" + new Date().getTime() + "="); | ||
158 | - | ||
159 | - // Replace last ? by callback parameter | ||
160 | - url = url.replace(/=\?(&|$)/, "=" + successCallbackName + "$1"); | ||
161 | - | ||
162 | - // Success notifier | ||
163 | - function notifySuccess(json) { | ||
164 | - | ||
165 | - if (!done++) { | ||
166 | - | ||
167 | - cleanUp(); | ||
168 | - // Pagecache if needed | ||
169 | - pageCacheFlag && (pageCache[url] = { s: [json] }); | ||
170 | - // Apply the data filter if provided | ||
171 | - dataFilter && (json = dataFilter.apply(xOptions, [json])); | ||
172 | - // Call success then complete | ||
173 | - callIfDefined(successCallback, xOptions, [json, STR_SUCCESS, xOptions]); | ||
174 | - callIfDefined(completeCallback, xOptions, [xOptions, STR_SUCCESS]); | ||
175 | - } | ||
176 | - } | ||
177 | - | ||
178 | - // Error notifier | ||
179 | - function notifyError(type) { | ||
180 | - | ||
181 | - if (!done++) { | ||
182 | - | ||
183 | - // Clean up | ||
184 | - cleanUp(); | ||
185 | - // If pure error (not timeout), cache if needed | ||
186 | - pageCacheFlag && type != STR_TIMEOUT && (pageCache[url] = type); | ||
187 | - // Call error then complete | ||
188 | - callIfDefined(errorCallback, xOptions, [xOptions, type]); | ||
189 | - callIfDefined(completeCallback, xOptions, [xOptions, type]); | ||
190 | - } | ||
191 | - } | ||
192 | - | ||
193 | - // Check page cache | ||
194 | - if (pageCacheFlag && (pageCached = pageCache[url])) { | ||
195 | - | ||
196 | - pageCached.s ? notifySuccess(pageCached.s[0]) : notifyError(pageCached); | ||
197 | - } else { | ||
198 | - | ||
199 | - // Install the generic callback | ||
200 | - // (BEWARE: global namespace pollution ahoy) | ||
201 | - win[successCallbackName] = genericCallback; | ||
202 | - | ||
203 | - // Create the script tag | ||
204 | - script = $(STR_SCRIPT_TAG)[0]; | ||
205 | - script.id = STR_JQUERY_JSONP + count++; | ||
206 | - | ||
207 | - // Set charset if provided | ||
208 | - if (charset) { | ||
209 | - script[STR_CHARSET] = charset; | ||
210 | - } | ||
211 | - | ||
212 | - opera && opera.version() < 11.60 ? | ||
213 | - // onerror is not supported: do not set as async and assume in-order execution. | ||
214 | - // Add a trailing script to emulate the event | ||
215 | - (scriptAfter = $(STR_SCRIPT_TAG)[0]).text = "document.getElementById('" + script.id + "')." + STR_ON_ERROR + "()" : | ||
216 | - // onerror is supported: set the script as async to avoid requests blocking each others | ||
217 | - script[STR_ASYNC] = STR_ASYNC; | ||
218 | - | ||
219 | - // Internet Explorer: event/htmlFor trick | ||
220 | - if (oldIE) { | ||
221 | - script.htmlFor = script.id; | ||
222 | - script.event = STR_ON_CLICK; | ||
223 | - } | ||
224 | - | ||
225 | - // Attached event handlers | ||
226 | - script[STR_ON_LOAD] = script[STR_ON_ERROR] = script[STR_ON_READY_STATE_CHANGE] = function (result) { | ||
227 | - | ||
228 | - // Test readyState if it exists | ||
229 | - if (!script[STR_READY_STATE] || !/i/.test(script[STR_READY_STATE])) { | ||
230 | - | ||
231 | - try { | ||
232 | - | ||
233 | - script[STR_ON_CLICK] && script[STR_ON_CLICK](); | ||
234 | - } catch (_) {} | ||
235 | - | ||
236 | - result = lastValue; | ||
237 | - lastValue = 0; | ||
238 | - result ? notifySuccess(result[0]) : notifyError(STR_ERROR); | ||
239 | - } | ||
240 | - }; | ||
241 | - | ||
242 | - // Set source | ||
243 | - script.src = url; | ||
244 | - | ||
245 | - // Re-declare cleanUp function | ||
246 | - cleanUp = function cleanUp(i) { | ||
247 | - timeoutTimer && clearTimeout(timeoutTimer); | ||
248 | - script[STR_ON_READY_STATE_CHANGE] = script[STR_ON_LOAD] = script[STR_ON_ERROR] = null; | ||
249 | - head[STR_REMOVE_CHILD](script); | ||
250 | - scriptAfter && head[STR_REMOVE_CHILD](scriptAfter); | ||
251 | - }; | ||
252 | - | ||
253 | - // Append main script | ||
254 | - head[STR_INSERT_BEFORE](script, firstChild = head.firstChild); | ||
255 | - | ||
256 | - // Append trailing script if needed | ||
257 | - scriptAfter && head[STR_INSERT_BEFORE](scriptAfter, firstChild); | ||
258 | - | ||
259 | - // If a timeout is needed, install it | ||
260 | - timeoutTimer = timeout > 0 && setTimeout(function () { | ||
261 | - notifyError(STR_TIMEOUT); | ||
262 | - }, timeout); | ||
263 | - } | ||
264 | - | ||
265 | - return xOptions; | ||
266 | -} | ||
267 | - | ||
268 | -// ###################### SETUP FUNCTION ## | ||
269 | -jsonp.setup = function (xOptions) { | ||
270 | - $.extend(xOptionsDefaults, xOptions); | ||
271 | -}; | ||
272 | - | ||
273 | -// ###################### INSTALL in jQuery ## | ||
274 | -$.jsonp = jsonp; | ||
275 | - | ||
276 | - | ||
277 | -/* eslint-disable */ | ||
278 | - | ||
279 | -__$styleInject(".featuretip.tip-wrap{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1000;background:rgba(0,0,0,.5)}.featuretip .tip{position:fixed;left:50%;top:50%;margin-left:-140px;margin-top:-140px;width:280px;background:#fff;border-top:40px solid #000;text-align:center;line-height:1.25}.featuretip .tip .title{margin:20px auto;font-size:24px;font-weight:700;text-align:center}.featuretip .tip .highlight{font-size:18px}.featuretip .tip .content{font-size:16px;color:#444;text-align:center}.featuretip .tip .button{display:block;margin:20px auto;width:150px;height:30px;font-size:14px;line-height:30px;text-align:center;color:#fff;background:#000;text-decoration:none}", undefined); | ||
280 | - | ||
281 | -__$styleInject(".feature-coin.tip-wrap{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1000;background:rgba(0,0,0,.5)}.feature-coin .tip{position:fixed;left:50%;top:50%;margin-left:-140px;margin-top:-140px;width:280px;background:#fff;text-align:center;line-height:1.25;background-repeat:no-repeat}.feature-coin .tip .tip-close{position:absolute;right:0;top:0;width:25px;height:25px;line-height:25px;text-align:center;font-size:16px;color:#fff;background:#000;cursor:pointer}.feature-coin .tip .title{margin:21px auto;font-size:22px;font-weight:700;text-align:center}.feature-coin .tip .highlight{font-size:18px}.feature-coin .tip .content{padding:4px;font-size:16px;color:#444;text-align:center;height:48px;overflow:hidden}.feature-coin .bottom-button{text-align:center}.feature-coin .tip .button,.feature-coin .tip .coin{display:inline-block;margin:20px auto;width:116px;height:26px;font-size:14px;line-height:26px;text-align:center;color:#fff;background:#000;text-decoration:none;border:2px solid #000}.feature-coin .tip .coin{color:#000;background:#fff}", undefined); | ||
282 | - | ||
283 | -var isMobile = { | ||
284 | - Android: function Android() { | ||
285 | - return navigator.userAgent.match(/Android/i) ? true : false; | ||
286 | - }, | ||
287 | - BlackBerry: function BlackBerry() { | ||
288 | - return navigator.userAgent.match(/BlackBerry/i) ? true : false; | ||
289 | - }, | ||
290 | - iOS: function iOS() { | ||
291 | - return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false; | ||
292 | - }, | ||
293 | - Windows: function Windows() { | ||
294 | - return navigator.userAgent.match(/IEMobile/i) ? true : false; | ||
295 | - }, | ||
296 | - any: function any() { | ||
297 | - return isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows(); | ||
298 | - } | ||
299 | -}; | ||
300 | -var mycurrency = isMobile.any() ? '//m.yohobuy.com/home/mycurrency' : '//www.yohobuy.com/home/currency'; | ||
301 | -var $tipTmpl = $('<div class="featuretip tip-wrap"><div class="tip"><div class="title"></div><div class="content"></div><a class="button" href="">返回</a></div></div>'); // eslint-disable-line | ||
302 | -var $cointipTmpl = $('<div class="feature-coin tip-wrap"><div class="tip"><div class="tip-close">×</div><div class="title"></div><div class="content"></div><div class="bottom-button"><a class="button" href="">去逛逛</a><a class="coin" href=\'' + mycurrency + '?openby:yohobuy={"action":"go.mine"}\'>查看有货币</a></div></div></div>'); // eslint-disable-line | ||
303 | - | ||
304 | -var _queryString = function _queryString() { | ||
305 | - if (!window._jssdkQS) { | ||
306 | - var vars = {}, | ||
307 | - hash = void 0, | ||
308 | - i = void 0, | ||
309 | - hashes = window.location.search.slice(1).split('&'); | ||
310 | - | ||
311 | - for (i = 0; i < hashes.length; i++) { | ||
312 | - hash = hashes[i].split('='); | ||
313 | - vars[hash[0]] = hash[1]; | ||
314 | - } | ||
315 | - | ||
316 | - window._jssdkQS = vars; | ||
317 | - } | ||
318 | - | ||
319 | - return $.extend({}, window._jssdkQS); | ||
320 | -}; | ||
321 | - | ||
322 | -var _sParamByIframe = function _sParamByIframe() { | ||
323 | - var paramsObj = _queryString(); | ||
324 | - var queryArray = []; | ||
325 | - var queryString = '?'; | ||
326 | - | ||
327 | - delete paramsObj['uid']; | ||
328 | - delete paramsObj['app_version']; | ||
329 | - delete paramsObj['client_type']; | ||
330 | - delete paramsObj['session_key']; | ||
331 | - delete paramsObj['client_secret']; | ||
332 | - | ||
333 | - for (var i in paramsObj) { | ||
334 | - queryArray.push(i + '=' + paramsObj[i]); | ||
335 | - } | ||
336 | - | ||
337 | - if (!paramsObj['expires']) { | ||
338 | - queryArray.push('expires=' + 7 * 24 * 60 * 60 * 1000); | ||
339 | - } | ||
340 | - | ||
341 | - queryArray.push('callback=jQueryMktCode'); | ||
342 | - queryString += queryArray.join('&'); | ||
343 | - $.getScript('//m.yohobuy.com/activity/wechat/1111' + queryString, function () {}); | ||
344 | - // $('<iframe style="display:none;" src="//m.yohobuy.com/activity/wechat/1111' + queryString + '"></iframe>').prependTo('body'); | ||
345 | -}; | ||
346 | - | ||
347 | -var _bindEvent = function _bindEvent() { | ||
348 | - var $body = $('body'); | ||
349 | - $body.on('click', '.feature-coin .close,.feature-coin .tip-close', function (e) { | ||
350 | - $cointipTmpl.fadeOut(); | ||
351 | - e.preventDefault(); | ||
352 | - }); | ||
353 | - $body.on('click', '.feature-coin.tip-wrap', function (e) { | ||
354 | - if ('feature-coin tip-wrap' === e.target.className) { | ||
355 | - $cointipTmpl.fadeOut(); | ||
356 | - e.preventDefault(); | ||
357 | - } | ||
358 | - }); | ||
359 | - $body.on('click', '.featuretip .close', function (e) { | ||
360 | - $tipTmpl.fadeOut(); | ||
361 | - e.preventDefault(); | ||
362 | - }); | ||
363 | - $body.on('click', '.featuretip .refresh', function () { | ||
364 | - location.reload(); | ||
365 | - }); | ||
366 | - $body.on('click', '.featuretip.tip-wrap', function (e) { | ||
367 | - if ('featuretip tip-wrap' === e.target.className) { | ||
368 | - $tipTmpl.fadeOut(); | ||
369 | - e.preventDefault(); | ||
370 | - } | ||
371 | - }); | ||
372 | -}; | ||
373 | - | ||
374 | -var utils = { | ||
375 | - queryString: _queryString, | ||
376 | - init: function init() { | ||
377 | - //发送活动页参数 | ||
378 | - _sParamByIframe(); | ||
379 | - | ||
380 | - // 绑定事件 | ||
381 | - _bindEvent(); | ||
382 | - }, | ||
383 | - isApp: function isApp() { | ||
384 | - var qs = _queryString(); | ||
385 | - var isApp = !!qs.app_version || qs.openrefer === 'app' && qs.uid; | ||
386 | - | ||
387 | - return !!isApp; | ||
388 | - }, | ||
389 | - image: function image(url, width, height, mode, quality) { | ||
390 | - mode = !isNaN(Number(mode)) ? mode : 2; | ||
391 | - url = url || ''; | ||
392 | - url = url.replace(/{width}/g, width).replace(/{height}/g, height).replace(/{mode}/g, mode); | ||
393 | - if (url.indexOf('imageView2') > 0) { | ||
394 | - quality = quality || 90; | ||
395 | - url += '/q/' + quality; | ||
396 | - } | ||
397 | - return url.replace('quality/80', 'quality/60').replace('http:', ''); | ||
398 | - }, | ||
399 | - sParamByIframe: function sParamByIframe(params) { | ||
400 | - $.getScript('//m.yohobuy.com/activity/wechat/1111' + params, function () {}); | ||
401 | - // $('<iframe style="display:none;" src="//m.yohobuy.com/activity/wechat/1111?' + params + '"></iframe>').prependTo('body'); | ||
402 | - }, | ||
403 | - showTip: function showTip(data) { | ||
404 | - data = data || { | ||
405 | - title: '', | ||
406 | - content: '', | ||
407 | - close: true | ||
408 | - }; | ||
409 | - | ||
410 | - $tipTmpl.find('.title').html(data.title); | ||
411 | - $tipTmpl.find('.content').html(data.content); | ||
412 | - | ||
413 | - if (data.close) { | ||
414 | - $tipTmpl.find('.button').addClass('close'); | ||
415 | - } else { | ||
416 | - $tipTmpl.find('.button').addClass('refresh').html('刷新'); | ||
417 | - } | ||
418 | - | ||
419 | - $('body').append($tipTmpl); | ||
420 | - $tipTmpl.show(); | ||
421 | - }, | ||
422 | - showCoinTip: function showCoinTip(data) { | ||
423 | - data = data || { | ||
424 | - title: '', | ||
425 | - content: '', | ||
426 | - close: true | ||
427 | - }; | ||
428 | - | ||
429 | - $cointipTmpl.find('.title').html(data.title); | ||
430 | - $cointipTmpl.find('.content').html(data.content); | ||
431 | - | ||
432 | - if (data.close) { | ||
433 | - $cointipTmpl.find('.button').addClass('close'); | ||
434 | - } | ||
435 | - | ||
436 | - if (data.coin) { | ||
437 | - $cointipTmpl.find('.coin').css('display', 'inline-block'); | ||
438 | - } else { | ||
439 | - $cointipTmpl.find('.coin').hide(); | ||
440 | - } | ||
441 | - | ||
442 | - if (data.img) { | ||
443 | - $cointipTmpl.find('.tip').css('background-image', 'url(' + data.img + ')'); | ||
444 | - } | ||
445 | - | ||
446 | - $('body').append($cointipTmpl); | ||
447 | - $cointipTmpl.show(); | ||
448 | - } | ||
449 | -}; | ||
450 | - | ||
451 | -var _noLoginUrl = function _noLoginUrl() { | ||
452 | - var referrer = location.href.split('?')[0]; | ||
453 | - return '//m.yohobuy.com/signin.html?refer=' + encodeURIComponent(location.href) + '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + referrer.replace(/\//g, '\\/') + '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}'; | ||
454 | -}; | ||
455 | - | ||
456 | -var user = { | ||
457 | - uid: '', | ||
458 | - noLoginUrl: _noLoginUrl, | ||
459 | - init: function init() { | ||
460 | - var _this = this; | ||
461 | - return jsonp({ | ||
462 | - url: '//m.yohobuy.com/passport/login/user?callback=?' | ||
463 | - }).then(function (res) { | ||
464 | - if (res.code === 200) { | ||
465 | - _this.uid = Number(res.data) || 0; | ||
466 | - } | ||
467 | - if (!_this.uid && utils.isApp()) { | ||
468 | - _this.uid = Number(utils.queryString().uid) || 0; | ||
469 | - } | ||
470 | - return $.Deferred().resolve(_this.uid); | ||
471 | - }, function () { | ||
472 | - utils.isApp() && (_this.uid = Number(utils.queryString().uid) || 0); | ||
473 | - return $.Deferred().resolve(_this.uid); | ||
474 | - }); | ||
475 | - }, | ||
476 | - auth: function auth() { | ||
477 | - if (!this.uid) { | ||
478 | - var noLoginUrl = _noLoginUrl(); | ||
479 | - | ||
480 | - $('a.auth').attr('href', noLoginUrl); | ||
481 | - } | ||
482 | - }, | ||
483 | - favout: function favout(skn) { | ||
484 | - if (!skn || !this.uid) { | ||
485 | - return; | ||
486 | - } | ||
487 | - | ||
488 | - jsonp({ | ||
489 | - url: '//service.yoho.cn/activity/favorite/addFavorite?productSkn=' + skn + '&uid=' + this.uid + '&callback=?' | ||
490 | - }).then(function (res) { | ||
491 | - if (res.code === 200) { | ||
492 | - utils.showTip({ | ||
493 | - content: '恭喜您,收藏成功', | ||
494 | - close: true | ||
495 | - }); | ||
496 | - } else { | ||
497 | - utils.showTip({ | ||
498 | - content: res.message, | ||
499 | - close: true | ||
500 | - }); | ||
501 | - } | ||
502 | - }, function () { | ||
503 | - utils.showTip({ | ||
504 | - title: '收藏失败<br>请刷新重新领取', | ||
505 | - content: '如多次收藏失败,请联系客服人员<br>带来不便敬请谅解', | ||
506 | - close: false | ||
507 | - }); | ||
508 | - }); | ||
509 | - }, | ||
510 | - getMktCode: function getMktCode() { | ||
511 | - var mkt_code = void 0; | ||
512 | - | ||
513 | - if (this.uid) { | ||
514 | - if (Number(this.uid) % 1024 >= 512) { | ||
515 | - mkt_code = 100000000000195; // 默认的值 | ||
516 | - } else { | ||
517 | - mkt_code = 100000000000193; // 个性化,动态接口数据 | ||
518 | - } | ||
519 | - } else { | ||
520 | - mkt_code = 100000000000197; // 访客接口数据 | ||
521 | - } | ||
522 | - return mkt_code; | ||
523 | - } | ||
524 | -}; | ||
525 | - | ||
526 | -var jsApiList = ['checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone']; | ||
527 | -var shareData = { | ||
528 | - title: document.title, | ||
529 | - link: location.href, | ||
530 | - desc: 'YOHO!BUY', | ||
531 | - imgUrl: 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png' | ||
532 | -}; | ||
533 | - | ||
534 | -var _getShareDataById = function _getShareDataById() { | ||
535 | - var shareId = utils.queryString().share_id; | ||
536 | - if (shareId) { | ||
537 | - return jsonp({ | ||
538 | - url: '//m.yohobuy.com/activity/share?callback=?', | ||
539 | - data: { | ||
540 | - shareId: shareId | ||
541 | - } | ||
542 | - }).then(function (res) { | ||
543 | - if (res && res.code === 200 && res.data) { | ||
544 | - shareData.title = res.data.title; | ||
545 | - shareData.link = res.data.link || location.href; | ||
546 | - shareData.desc = res.data.content || res.data.title; | ||
547 | - shareData.imgUrl = res.data.pic; | ||
548 | - } | ||
549 | - return $.Deferred().resolve(); | ||
550 | - }, function () { | ||
551 | - return $.Deferred().resolve(); | ||
552 | - }); | ||
553 | - } else { | ||
554 | - var shareTitle = $('#shareTitle').val(); | ||
555 | - var shareImg = $('#shareImg').val(); | ||
556 | - var shareDesc = $('#shareDesc').val(); | ||
557 | - var shareLink = $('#shareLink').val(); | ||
558 | - | ||
559 | - shareData.title = shareTitle ? shareTitle : shareData.title; | ||
560 | - shareData.imgUrl = shareImg ? shareImg : shareData.imgUrl; | ||
561 | - shareData.desc = shareDesc ? shareDesc : shareData.desc; | ||
562 | - shareData.link = shareLink ? shareLink : shareData.link; | ||
563 | - return $.Deferred().resolve(); | ||
564 | - } | ||
565 | -}; | ||
566 | - | ||
567 | -var share = { | ||
568 | - init: function init() { | ||
569 | - if (/QQ/i.test(navigator.userAgent)) { | ||
570 | - $.ajax({ | ||
571 | - url: '//qzonestyle.gtimg.cn/qzone/qzact/common/share/share.js', | ||
572 | - dataType: 'script', | ||
573 | - cache: true, | ||
574 | - success: function success() { | ||
575 | - _getShareDataById().then(function () { | ||
576 | - window.setShareInfo && window.setShareInfo({ | ||
577 | - title: shareData.title, | ||
578 | - summary: shareData.desc, | ||
579 | - pic: shareData.imgUrl, | ||
580 | - url: shareData.link | ||
581 | - }); | ||
582 | - }); | ||
583 | - } | ||
584 | - }); | ||
585 | - } | ||
586 | - | ||
587 | - if (/MicroMessenger/i.test(navigator.userAgent)) { | ||
588 | - $.ajax({ | ||
589 | - url: '//res.wx.qq.com/open/js/jweixin-1.3.2.js', | ||
590 | - dataType: 'script', | ||
591 | - cache: true, | ||
592 | - success: function success() { | ||
593 | - jsonp({ | ||
594 | - url: '//m.yohobuy.com/activity/wechat/share?callback=?', | ||
595 | - data: { | ||
596 | - url: location.href | ||
597 | - } | ||
598 | - }).then(function (res) { | ||
599 | - if (window.wx) { | ||
600 | - window.wx.config({ | ||
601 | - debug: false, | ||
602 | - appId: res.appId, | ||
603 | - timestamp: res.timestamp, | ||
604 | - nonceStr: res.nonceStr, | ||
605 | - signature: res.signature, | ||
606 | - jsApiList: jsApiList | ||
607 | - }); | ||
608 | - | ||
609 | - _getShareDataById().then(function () { | ||
610 | - window.wx.ready(function () { | ||
611 | - window.wx.onMenuShareAppMessage(shareData); | ||
612 | - window.wx.onMenuShareTimeline(shareData); | ||
613 | - window.wx.onMenuShareQQ(shareData); | ||
614 | - window.wx.onMenuShareWeibo(shareData); | ||
615 | - window.wx.onMenuShareQZone(shareData); | ||
616 | - }); | ||
617 | - }); | ||
618 | - } | ||
619 | - }); | ||
620 | - } | ||
621 | - }); | ||
622 | - } | ||
623 | - } | ||
624 | -}; | ||
625 | - | ||
626 | -/** | ||
627 | - * 移动端尝试打开 app | ||
628 | - */ | ||
629 | -var channelMap = { | ||
630 | - 'baidu.com': 100000000000055, | ||
631 | - 'so.com': 100000000000049, | ||
632 | - 'sogou.com': 100000000000053, | ||
633 | - 'bing.com': 100000000000057, | ||
634 | - 'm.sm.cn': 100000000000059, | ||
635 | - 'google.com': 100000000000061 | ||
636 | -}; | ||
637 | - | ||
638 | -var getMktcBySeo = function getMktcBySeo() { | ||
639 | - var mktc, | ||
640 | - rf = document.referrer; | ||
641 | - | ||
642 | - for (var domain in channelMap) { | ||
643 | - if (rf.indexOf(domain) > -1) { | ||
644 | - mktc = channelMap[domain]; | ||
645 | - break; | ||
646 | - } | ||
647 | - } | ||
648 | - return mktc; | ||
649 | -}; | ||
650 | - | ||
651 | -var getAppPath = function getAppPath() { | ||
652 | - var qs = utils.queryString(); | ||
653 | - var ct = qs.mkt_code || qs.union_type || getMktcBySeo() || '100000000000349'; | ||
654 | - | ||
655 | - delete qs.openapp; // 防止重复打开 | ||
656 | - | ||
657 | - var shareParams = qs.share_id ? '"share":"/operations/api/v5/webshare/getShare","shareparam":{"share_id":"' + qs.share_id + '"},' : '', | ||
658 | - appPath = 'yohobuy://yohobuy.com/goapp?ct=' + ct + '&openby:yohobuy={"action":"go.h5",' + shareParams + '"params":{"islogin":"N","url":"http://feature.yoho.cn' + location.pathname + '","param":' + JSON.stringify(qs) + '}}'; | ||
659 | - | ||
660 | - return appPath; | ||
661 | -}; | ||
662 | - | ||
663 | -var openapp = { | ||
664 | - init: function init() { | ||
665 | - if (utils.queryString().openapp) { | ||
666 | - var u = navigator.userAgent.toLowerCase(); | ||
667 | - var isiOS = u.indexOf('os') > -1 || u.indexOf('iphone') > -1 || u.indexOf('mac') > -1 || u.indexOf('ipad') > -1; | ||
668 | - var appPath = getAppPath(); | ||
669 | - | ||
670 | - if (isiOS) { | ||
671 | - window.location.href = appPath; | ||
672 | - } else { | ||
673 | - var ifr = document.createElement('iframe'); | ||
674 | - ifr.src = appPath; | ||
675 | - ifr.style.display = 'none'; | ||
676 | - document.body.appendChild(ifr); | ||
677 | - } | ||
678 | - } | ||
679 | - } | ||
680 | -}; | ||
681 | - | ||
682 | -function cookie(name) { | ||
683 | - var re = new RegExp(name + '=([^;$]*)', 'i'), | ||
684 | - matchPattern = '$1'; | ||
685 | - | ||
686 | - return re.test(decodeURIComponent(document.cookie)) ? RegExp[matchPattern] : ''; | ||
687 | -} | ||
688 | - | ||
689 | -function setCookie(name, value, options) { | ||
690 | - var expires = '', | ||
691 | - path, | ||
692 | - domain, | ||
693 | - secure, | ||
694 | - date; | ||
695 | - | ||
696 | - if (typeof value !== 'undefined') { | ||
697 | - options = options || {}; | ||
698 | - if (value === null) { | ||
699 | - value = ''; | ||
700 | - options.expires = -1; | ||
701 | - } | ||
702 | - | ||
703 | - if (options.expires && (typeof options.expires === 'number' || options.expires.toUTCString)) { | ||
704 | - if (typeof options.expires === 'number') { | ||
705 | - date = new Date(); | ||
706 | - date.setTime(date.getTime() + options.expires * 24 * 60 * 60 * 1000); | ||
707 | - } else { | ||
708 | - date = options.expires; | ||
709 | - } | ||
710 | - expires = '; expires=' + date.toUTCString(); | ||
711 | - } | ||
712 | - path = options.path ? '; path=' + options.path : ''; | ||
713 | - domain = options.domain ? '; domain=' + options.domain : ''; | ||
714 | - secure = options.secure ? '; secure' : ''; | ||
715 | - document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); | ||
716 | - } | ||
717 | -} | ||
718 | - | ||
719 | -var cookies = { | ||
720 | - cookie: cookie, | ||
721 | - setCookie: setCookie | ||
722 | -}; | ||
723 | - | ||
724 | -/* global wx */ | ||
725 | -// 1. 优惠券领取 | ||
726 | -// 2. YOHO币领取 | ||
727 | - | ||
728 | -var _getCoin = function _getCoin(data) { | ||
729 | - data.app = utils.queryString(); | ||
730 | - data.app.uid = data.uid; | ||
731 | - | ||
732 | - jsonp({ | ||
733 | - url: '//m.yohobuy.com/activity/coin/sendCoin?callback=?', | ||
734 | - data: data | ||
735 | - }).then(function (res) { | ||
736 | - if (res.code === 200 && res.data) { | ||
737 | - if (res.data.code === 200) { | ||
738 | - utils.showCoinTip({ | ||
739 | - title: '恭喜您,成功领取有货币!', | ||
740 | - content: '特殊情况下到账有延时<br>请耐心等待', | ||
741 | - close: true, | ||
742 | - coin: true, | ||
743 | - img: res.data.popupImg | ||
744 | - }); | ||
745 | - } else if (res.data.code === 501) { | ||
746 | - utils.showCoinTip({ | ||
747 | - title: '领取失败', | ||
748 | - content: '哎呀,你来的有点早,活动还没开始呢<br/>稍后再来哦', | ||
749 | - close: true, | ||
750 | - img: res.data.popupImg | ||
751 | - }); | ||
752 | - } else if (res.data.code === 502) { | ||
753 | - utils.showCoinTip({ | ||
754 | - title: '领取失败', | ||
755 | - content: '抱歉,活动已结束了,下次要快哟~~', | ||
756 | - close: true, | ||
757 | - img: res.data.popupImg | ||
758 | - }); | ||
759 | - } else if (res.data.code === 503) { | ||
760 | - utils.showCoinTip({ | ||
761 | - title: '已经领取', | ||
762 | - content: '贪心会长胖,你已经领取过了啦~~', | ||
763 | - close: true, | ||
764 | - img: res.data.popupImg | ||
765 | - }); | ||
766 | - } else if (res.data.code === 504) { | ||
767 | - utils.showCoinTip({ | ||
768 | - title: '领取失败', | ||
769 | - content: '哎呀,你来晚了,有货币已经领完了,<br/>下次早点来哦', | ||
770 | - close: true, | ||
771 | - img: res.data.popupImg | ||
772 | - }); | ||
773 | - } else if (res.data.msg) { | ||
774 | - utils.showCoinTip({ | ||
775 | - title: '领取失败', | ||
776 | - content: '抱歉,系统错误,有货君正奋力解决中...请稍后再来', | ||
777 | - close: true, | ||
778 | - img: res.data.popupImg | ||
779 | - }); | ||
780 | - } | ||
781 | - } else if (res.message) { | ||
782 | - utils.showCoinTip({ | ||
783 | - title: '领取失败', | ||
784 | - content: '抱歉,系统错误,有货君正奋力解决中...请稍后再来', | ||
785 | - close: true, | ||
786 | - img: res.data && res.data.popupImg | ||
787 | - }); | ||
788 | - } | ||
789 | - }, function () { | ||
790 | - utils.showCoinTip({ | ||
791 | - title: '领取失败', | ||
792 | - content: '抱歉,系统错误,有货君正奋力解决中...请稍后再来', | ||
793 | - close: true | ||
794 | - }); | ||
795 | - }); | ||
796 | -}; | ||
797 | - | ||
798 | -var _getCoupon = function _getCoupon(data) { | ||
799 | - data.app = utils.queryString(); | ||
800 | - | ||
801 | - data.app.uid = cookies.cookie('app_uid') || data.app.uid; | ||
802 | - data.app.app_version = cookies.cookie('app_version') || data.app.app_version; | ||
803 | - data.app.client_type = cookies.cookie('app_client_type') || data.app.client_type; | ||
804 | - data.app.session_key = cookies.cookie('app_session_key') || data.app.session_key; | ||
805 | - | ||
806 | - jsonp({ | ||
807 | - url: '//m.yohobuy.com/activity/feature/couponSend?callback=?', | ||
808 | - data: data | ||
809 | - }).then(function (res) { | ||
810 | - if (res.code === 200) { | ||
811 | - utils.showTip({ | ||
812 | - title: '领取成功', | ||
813 | - content: '恭喜您,领取成功', | ||
814 | - close: true | ||
815 | - }); | ||
816 | - } else if (res.code === 401) { | ||
817 | - utils.showTip({ | ||
818 | - title: '已经领取', | ||
819 | - content: '快去分享给更多<br>喜爱<span class="highlight">潮流</span>的小伙伴吧!', | ||
820 | - close: true | ||
821 | - }); | ||
822 | - } else if (res.message) { | ||
823 | - utils.showTip({ | ||
824 | - title: '领取失败<br>请刷新重新领取', | ||
825 | - content: res.message + '<br>如多次领取失败,请联系客服人员<br>带来不便敬请谅解', | ||
826 | - close: false | ||
827 | - }); | ||
828 | - } | ||
829 | - }, function () { | ||
830 | - utils.showTip({ | ||
831 | - title: '领取失败<br>请刷新重新领取', | ||
832 | - content: '如多次领取失败,请联系客服人员<br>带来不便敬请谅解', | ||
833 | - close: false | ||
834 | - }); | ||
835 | - }); | ||
836 | -}; | ||
837 | - | ||
838 | -var _initCoin = function _initCoin(uid) { | ||
839 | - if (uid) { | ||
840 | - var cointoken = cookies.cookie('yoho-coin-token'); | ||
841 | - if (cointoken) { | ||
842 | - _getCoin({ | ||
843 | - token: cointoken, | ||
844 | - uid: uid | ||
845 | - }); | ||
846 | - | ||
847 | - cookies.setCookie('yoho-coin-token', ''); | ||
848 | - } | ||
849 | - } | ||
850 | - | ||
851 | - $('body').on('click', '.yoho-coin', function () { | ||
852 | - var token = $(this).data('token'); | ||
853 | - if (user.uid) { | ||
854 | - _getCoin({ | ||
855 | - token: token, | ||
856 | - uid: user.uid | ||
857 | - }); | ||
858 | - } else { | ||
859 | - cookies.setCookie('yoho-coin-token', token); | ||
860 | - | ||
861 | - if (window.__wxjs_environment === 'miniprogram' && wx && wx.miniProgram) { | ||
862 | - wx.miniProgram.navigateTo({ | ||
863 | - url: '../bindPhoneNumber/bindPhoneNumber?h5back=' + location.href | ||
864 | - }); | ||
865 | - return; | ||
866 | - } | ||
867 | - | ||
868 | - if ($('#intimacy-link').length <= 0) { | ||
869 | - $('body').append('<a href=\'' + user.noLoginUrl() + '\' style="display:none;" id="intimacy-link"><span class="intimacy-link"></span></a>'); | ||
870 | - } | ||
871 | - $('.intimacy-link').click(); | ||
872 | - return; | ||
873 | - } | ||
874 | - }); | ||
875 | -}; | ||
876 | - | ||
877 | -var _initCoupon = function _initCoupon(uid) { | ||
878 | - if (uid) { | ||
879 | - var conpontoken = cookies.cookie('yoho-conpon-token'); | ||
880 | - if (conpontoken) { | ||
881 | - _getCoupon({ | ||
882 | - token: conpontoken, | ||
883 | - uid: uid | ||
884 | - }); | ||
885 | - | ||
886 | - cookies.setCookie('yoho-conpon-token', ''); | ||
887 | - } | ||
888 | - } | ||
889 | - | ||
890 | - $('body').on('click', '.yoho-conpon', function () { | ||
891 | - var token = $(this).data('token'); | ||
892 | - if (user.uid) { | ||
893 | - _getCoupon({ | ||
894 | - token: token, | ||
895 | - uid: user.uid | ||
896 | - }); | ||
897 | - } else { | ||
898 | - cookies.setCookie('yoho-conpon-token', token); | ||
899 | - | ||
900 | - if (window.__wxjs_environment === 'miniprogram' && wx && wx.miniProgram) { | ||
901 | - wx.miniProgram.navigateTo({ | ||
902 | - url: '../bindPhoneNumber/bindPhoneNumber?h5back=' + location.href | ||
903 | - }); | ||
904 | - return; | ||
905 | - } | ||
906 | - | ||
907 | - if ($('#intimacy-link').length <= 0) { | ||
908 | - $('body').append('<a href=\'' + user.noLoginUrl() + '\' style="display:none;" id="intimacy-link"><span class="intimacy-link"></span></a>'); | ||
909 | - } | ||
910 | - $('.intimacy-link').click(); | ||
911 | - return; | ||
912 | - } | ||
913 | - }); | ||
914 | -}; | ||
915 | - | ||
916 | -var promotion = { | ||
917 | - init: function init(uid) { | ||
918 | - _initCoin(uid); // 初始化有货币 | ||
919 | - _initCoupon(uid); // 初始化优惠券 | ||
920 | - } | ||
921 | -}; | ||
922 | - | ||
923 | -var abTestFlag = false; // ab测试 | ||
924 | -var _replaceData = function _replaceData(el, cond, data, wh, fp) { | ||
925 | - if (!data) { | ||
926 | - return; | ||
927 | - } | ||
928 | - | ||
929 | - el.find('.brand-name').html(data.brand_name); | ||
930 | - el.find('.product-detail').attr('href', '//m.yohobuy.com/product/' + data.product_skn + '.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":' + data.product_skn + '}}'); | ||
931 | - el.find('.product-detail-img').attr('src', utils.image(data.default_images, wh.w, wh.h, 2, 75)); | ||
932 | - el.find('.product-name').html(data.product_name); | ||
933 | - el.find('.vip-price-val').html('\xA5' + data.vip_price); | ||
934 | - el.find('.sale-price').html('\xA5' + data.sales_price); | ||
935 | - if (data.sales_price === data.market_price) { | ||
936 | - el.find('.market-price').hide(); | ||
937 | - } else { | ||
938 | - el.find('.market-price').html('\xA5' + data.market_price).show(); | ||
939 | - } | ||
940 | - | ||
941 | - var brandDom = el.find('.product-brand'); | ||
942 | - if (brandDom) { | ||
943 | - if (data.shop_id) { | ||
944 | - brandDom.attr('href', '//m.yohobuy.com/product/index/brand?domain=' + data.brand_domain + '&openby:yohobuy={"action":"go.shop","params":{"shop_id":' + data.shop_id + ',"shop_template_type":' + (data.shop_template_type || "1") + ',"is_red_shop":' + (data.is_red_shop || 1) + '}}'); | ||
945 | - } else { | ||
946 | - brandDom.attr('href', '//m.yohobuy.com/product/index/brand?domain=' + data.brand_domain + '&openby:yohobuy={"action":"go.brand","params":{"brand_id":' + data.brand_id + '}}'); | ||
947 | - } | ||
948 | - } | ||
949 | - | ||
950 | - // 楼层数据 | ||
951 | - if (fp) { | ||
952 | - if (!fp.I_INDEX) fp.I_INDEX = 0; | ||
953 | - | ||
954 | - fp.I_INDEX++; | ||
955 | - el.find('.product-detail').attr('fp', JSON.stringify(fp)); | ||
956 | - if (brandDom) { | ||
957 | - fp.I_INDEX++; | ||
958 | - brandDom.attr('fp', JSON.stringify(fp)); | ||
959 | - } | ||
960 | - } | ||
961 | - | ||
962 | - var listDom = el.find('.list-product'); | ||
963 | - if (listDom) { | ||
964 | - var sortStr = '', | ||
965 | - gender = cond.gender ? cond.gender : '1,3', | ||
966 | - url = '//list.m.yohobuy.com?gender=' + gender; | ||
967 | - | ||
968 | - if (listDom.data('sort')) { | ||
969 | - sortStr += ',"sort":' + data.small_sort_id; | ||
970 | - url += '&sort=' + data.small_sort_id; | ||
971 | - } | ||
972 | - if (listDom.data('misort')) { | ||
973 | - sortStr += ',"misort":' + data.middle_sort_id; | ||
974 | - url += '&misort=' + data.middle_sort_id; | ||
975 | - } | ||
976 | - if (listDom.data('msort')) { | ||
977 | - sortStr += ',"msort":' + data.max_sort_id; | ||
978 | - url += '&msort=' + data.max_sort_id; | ||
979 | - } | ||
980 | - | ||
981 | - url += '&openby:yohobuy={"action":"go.list","params":{"actiontype":1,"gender":' + gender + sortStr + '}}'; | ||
982 | - listDom.attr('href', url); | ||
983 | - } | ||
984 | - el.html(el.html()); | ||
985 | - return el; | ||
986 | -}; | ||
987 | - | ||
988 | -var _getProductData = function _getProductData(dataArr) { | ||
989 | - if (!dataArr.length) { | ||
990 | - return; | ||
991 | - } | ||
992 | - | ||
993 | - var data = dataArr.shift(); | ||
994 | - if (!data || !data.default_images) { | ||
995 | - return _getProductData(dataArr); | ||
996 | - } | ||
997 | - return data; | ||
998 | -}; | ||
999 | - | ||
1000 | -var _jsonp = function _jsonp(el, param, cond) { | ||
1001 | - var cloneitem = el.attr('cloneitem'); | ||
1002 | - var loading = el.find('.loading'); | ||
1003 | - var goods = el.find('.feature-product-info'); | ||
1004 | - var rowNum = el.data('rownum'); | ||
1005 | - | ||
1006 | - if (!goods.length) { | ||
1007 | - return; | ||
1008 | - } | ||
1009 | - | ||
1010 | - if (cond.abtest) { | ||
1011 | - // ab测试,访客 和 >=512的uid 显示默认推荐 | ||
1012 | - if (!param.uid || Number(param.uid) % 1024 >= 512) { | ||
1013 | - if (cloneitem) { | ||
1014 | - $(goods[0]).remove(); | ||
1015 | - } else { | ||
1016 | - goods.removeClass('novisible'); | ||
1017 | - loading.hide(); | ||
1018 | - } | ||
1019 | - return; | ||
1020 | - } | ||
1021 | - } | ||
1022 | - | ||
1023 | - var imgwh = el.find('.imgwh').val() || ''; // 获取图片宽x高 | ||
1024 | - imgwh = imgwh.split('x') || []; | ||
1025 | - | ||
1026 | - var wh = { | ||
1027 | - w: imgwh[0] || 300, | ||
1028 | - h: imgwh[1] || 400 | ||
1029 | - }; | ||
1030 | - | ||
1031 | - // 楼层数据 | ||
1032 | - var fp = el.attr('fp'); | ||
1033 | - fp = fp ? JSON.parse(fp) : ''; | ||
1034 | - | ||
1035 | - jsonp({ | ||
1036 | - url: '//m.yohobuy.com/activity/individuation?callback=?', | ||
1037 | - data: $.extend({}, param, cond) | ||
1038 | - }).then(function (res) { | ||
1039 | - if (!res || !res.length) { | ||
1040 | - if (cloneitem) { | ||
1041 | - $(goods[0]).remove(); | ||
1042 | - } else { | ||
1043 | - goods.removeClass('novisible'); | ||
1044 | - loading.hide(); | ||
1045 | - } | ||
1046 | - return; | ||
1047 | - } | ||
1048 | - | ||
1049 | - // 最后商品数量不足一行,截掉 | ||
1050 | - res.length = res.length - res.length % rowNum; | ||
1051 | - | ||
1052 | - if (cloneitem) { | ||
1053 | - // 可复制item | ||
1054 | - var cnt = isNaN(Number(cloneitem)) ? res.length : Number(cloneitem); | ||
1055 | - for (var indx = 0; indx < cnt; indx++) { | ||
1056 | - var data = _getProductData(res); // 获取商品数据 | ||
1057 | - if (indx === 0) { | ||
1058 | - var gel = $(goods[0]); | ||
1059 | - var nel = _replaceData(gel, cond, data, wh, fp); | ||
1060 | - if (nel) { | ||
1061 | - nel.removeClass('novisible'); | ||
1062 | - } else { | ||
1063 | - gel.remove(); | ||
1064 | - } | ||
1065 | - } else { | ||
1066 | - var _nel = _replaceData($(goods[0]).clone(), cond, data, wh, fp); | ||
1067 | - if (_nel) { | ||
1068 | - _nel.removeClass('novisible'); | ||
1069 | - _nel.appendTo(el); | ||
1070 | - } | ||
1071 | - } | ||
1072 | - } | ||
1073 | - } else { | ||
1074 | - for (var i = 1; i < res.length; i++) { | ||
1075 | - goods.last().after(goods.clone()); | ||
1076 | - } | ||
1077 | - | ||
1078 | - var $newGoods = el.find('.feature-product-info'); | ||
1079 | - | ||
1080 | - $newGoods.each(function (indx, perProduct) { | ||
1081 | - var $perProduct = $(perProduct); | ||
1082 | - _replaceData($perProduct, cond, _getProductData(res), wh, fp); | ||
1083 | - }); | ||
1084 | - $newGoods.removeClass('novisible'); | ||
1085 | - loading.hide(); | ||
1086 | - } | ||
1087 | - }, function () { | ||
1088 | - if (cloneitem) { | ||
1089 | - $(goods[0]).remove(); | ||
1090 | - } else { | ||
1091 | - goods.removeClass('novisible'); | ||
1092 | - loading.hide(); | ||
1093 | - } | ||
1094 | - }); | ||
1095 | -}; | ||
1096 | - | ||
1097 | -var _abTest = function _abTest() { | ||
1098 | - var mkt_code = user.getMktCode(); | ||
1099 | - | ||
1100 | - // cover覆盖mkt_code | ||
1101 | - utils.sParamByIframe('callback=jQueryMktCode&cover=1&mkt_code=' + mkt_code + '&expires=' + 7 * 24 * 60 * 60 * 1000); | ||
1102 | - | ||
1103 | - // 上报曝光事件 | ||
1104 | - var actionUrl = []; | ||
1105 | - $('a').each(function () { | ||
1106 | - var href = $(this).attr('href'); | ||
1107 | - if (href && !/^#.*$/.test(href) && !/^javascript.*$/i.test(href)) { | ||
1108 | - actionUrl.push(href); | ||
1109 | - } | ||
1110 | - }); | ||
1111 | - | ||
1112 | - var cnt = 0; | ||
1113 | - var timer = setInterval(function () { | ||
1114 | - cnt++; | ||
1115 | - if (cnt > 3) { | ||
1116 | - clearInterval(timer); | ||
1117 | - return; | ||
1118 | - } | ||
1119 | - if (window._yas && window._yas.sendAppLogs && window.appBaseLogs) { | ||
1120 | - clearInterval(timer); | ||
1121 | - window._yas.sendAppLogs({ | ||
1122 | - appop: 'YB_H5_PAGE_AB_OPEN_L', | ||
1123 | - param: JSON.stringify({ | ||
1124 | - C_ID: utils.queryString().yh_channel || 1, | ||
1125 | - PAGE_URL: window.originUrl, | ||
1126 | - PAGE_NAME: decodeURI(window.qs.title || document.title), | ||
1127 | - ACTION_URL: actionUrl, | ||
1128 | - CROWD_CODE: mkt_code + '' | ||
1129 | - }) | ||
1130 | - }, true); | ||
1131 | - | ||
1132 | - $('a').click(function () { | ||
1133 | - var furl = $(this).attr('href'); | ||
1134 | - if (furl && !/^#.*$/.test(furl) && !/^javascript.*$/i.test(furl)) { | ||
1135 | - window._yas.sendAppLogs({ | ||
1136 | - appop: 'YB_H5_PAGE_AB_FLR_C', | ||
1137 | - param: JSON.stringify({ | ||
1138 | - C_ID: utils.queryString().yh_channel || 1, | ||
1139 | - PAGE_URL: window.originUrl, | ||
1140 | - PAGE_NAME: decodeURI(window.qs.title || document.title), | ||
1141 | - F_URL: furl, | ||
1142 | - CROWD_CODE: mkt_code + '' | ||
1143 | - }) | ||
1144 | - }, true); | ||
1145 | - } | ||
1146 | - }); | ||
1147 | - } | ||
1148 | - }, 1000); | ||
1149 | -}; | ||
1150 | - | ||
1151 | -var _getProduct = function _getProduct(param) { | ||
1152 | - $('.product-source').each(function (i, el) { | ||
1153 | - el = $(el); | ||
1154 | - var cond = el.attr('condition'); | ||
1155 | - if (!cond) { | ||
1156 | - return; | ||
1157 | - } | ||
1158 | - cond = JSON.parse(cond); | ||
1159 | - | ||
1160 | - var yh_channel = utils.queryString().yh_channel; | ||
1161 | - if (cond.abtest) { | ||
1162 | - abTestFlag = true; | ||
1163 | - } | ||
1164 | - | ||
1165 | - if (yh_channel) { | ||
1166 | - cond.yh_channel = yh_channel; | ||
1167 | - } | ||
1168 | - | ||
1169 | - if (i > 3) { | ||
1170 | - setTimeout(function () { | ||
1171 | - _jsonp(el, param, cond); | ||
1172 | - }, 300); | ||
1173 | - } else { | ||
1174 | - _jsonp(el, param, cond); | ||
1175 | - } | ||
1176 | - }); | ||
1177 | - | ||
1178 | - abTestFlag && _abTest(); | ||
1179 | -}; | ||
1180 | - | ||
1181 | -var individuation = { | ||
1182 | - init: function init(uid) { | ||
1183 | - if (!uid && utils.isApp()) { | ||
1184 | - // document.addEventListener('deviceready', function() { | ||
1185 | - // window.yohoInterface.triggerEvent(function(data) { | ||
1186 | - // // 获取个性话数据 | ||
1187 | - // _getProduct({ | ||
1188 | - // uid: data.uid, | ||
1189 | - // udid: data.udid | ||
1190 | - // }); | ||
1191 | - // }, function() {}, { | ||
1192 | - // method: 'get.analyticAppData' | ||
1193 | - // }); | ||
1194 | - // }, false); | ||
1195 | - | ||
1196 | - _getProduct({ | ||
1197 | - uid: '', | ||
1198 | - udid: utils.queryString().udid || '' | ||
1199 | - }); | ||
1200 | - } else { | ||
1201 | - // 获取个性话数据 | ||
1202 | - _getProduct({ | ||
1203 | - uid: uid, | ||
1204 | - udid: cookies.cookie('_yasvd') | ||
1205 | - }); | ||
1206 | - } | ||
1207 | - } | ||
1208 | -}; | ||
1209 | - | ||
1210 | -// app.js | ||
1211 | - | ||
1212 | -$(function () { | ||
1213 | - openapp.init(); | ||
1214 | - | ||
1215 | - user.init().then(function (uid) { | ||
1216 | - individuation.init(uid); // 个性化推荐 | ||
1217 | - promotion.init(uid); // 促销 | ||
1218 | - user.auth(); // 权限验证 | ||
1219 | - share.init(); // 分享 | ||
1220 | - utils.init(); | ||
1221 | - }); | ||
1222 | -}); | ||
1223 | - | ||
1224 | -var jssdk = { | ||
1225 | - auth: user.auth, | ||
1226 | - favout: user.favout, | ||
1227 | - getMktCode: function getMktCode() { | ||
1228 | - return user.getMktCode(); | ||
1229 | - }, | ||
1230 | - getUid: function getUid() { | ||
1231 | - return user.uid; | ||
1232 | - } | ||
1233 | -}; | ||
1234 | - | ||
1235 | -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | ||
1236 | - return typeof obj; | ||
1237 | -} : function (obj) { | ||
1238 | - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
1239 | -}; | ||
1240 | - | ||
1241 | -(function (factory) { | ||
1242 | - /* eslint-disable */ | ||
1243 | - if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object' && _typeof(module.exports) === 'object') { | ||
1244 | - module.exports = factory(); | ||
1245 | - } else if (typeof define === 'function' && define.amd) { | ||
1246 | - define([], factory); | ||
1247 | - } else { | ||
1248 | - window._jssdk = factory(); | ||
1249 | - } | ||
1250 | - /* eslint-disable */ | ||
1251 | -})(function () { | ||
1252 | - return jssdk; | ||
1253 | -}); | ||
1254 | - | ||
1255 | -}(jQuery)); | 1 | +!function(e){"use strict";function t(e,t){if("undefined"==typeof document)return t;e=e||"";var i=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");return n.type="text/css",i.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),t}function i(){}function n(e){s=[e]}function o(e,t,i){return e&&e.apply&&e.apply(t.context||t,i)}function a(e){return/\?/.test(e)?"&":"?"}function r(t){function r(e){Y++||(H(),$&&(T[W]={s:[e]}),R&&(e=R.apply(t,[e])),o(P,t,[e,_,t]),o(L,t,[t,_]))}function c(e){Y++||(H(),$&&e!=S&&(T[W]=e),o(B,t,[t,e]),o(L,t,[t,e]))}t=e.extend({},j,t);var d,D,E,U,M,P=t.success,B=t.error,L=t.complete,R=t.dataFilter,z=t.callbackParameter,Q=t.callback,J=t.cache,$=t.pageCache,G=t.charset,W=t.url,F=t.data,X=t.timeout,Y=0,H=i;return I&&I(function(e){e.done(P).fail(B),P=e.resolve,B=e.reject}).promise(t),t.abort=function(){!Y++&&H()},!1===o(t.beforeSend,t,[t])||Y?t:(W=W||l,F=F?"string"==typeof F?F:e.param(F,t.traditional):l,W+=F?a(W)+F:l,z&&(W+=a(W)+encodeURIComponent(z)+"=?"),!J&&!$&&(W+=a(W)+"_"+(new Date).getTime()+"="),W=W.replace(/=\?(&|$)/,"="+Q+"$1"),$&&(d=T[W])?d.s?r(d.s[0]):c(d):(C[Q]=n,E=e(k)[0],E.id=m+A++,G&&(E[p]=G),O&&O.version()<11.6?(U=e(k)[0]).text="document.getElementById('"+E.id+"')."+y+"()":E[u]=u,q&&(E.htmlFor=E.id,E.event=g),E[v]=E[y]=E[b]=function(e){if(!E[w]||!/i/.test(E[w])){try{E[g]&&E[g]()}catch(e){}e=s,s=0,e?r(e[0]):c(f)}},E.src=W,H=function(e){M&&clearTimeout(M),E[b]=E[v]=E[y]=null,N[x](E),U&&N[x](U)},N[h](E,D=N.firstChild),U&&N[h](U,D),M=X>0&&setTimeout(function(){c(S)},X)),t)}function c(e){return new RegExp(e+"=([^;$]*)","i").test(decodeURIComponent(document.cookie))?RegExp.$1:""}function d(e,t,i){var n,o,a,r,c="";void 0!==t&&(i=i||{},null===t&&(t="",i.expires=-1),i.expires&&("number"==typeof i.expires||i.expires.toUTCString)&&("number"==typeof i.expires?(r=new Date,r.setTime(r.getTime()+24*i.expires*60*60*1e3)):r=i.expires,c="; expires="+r.toUTCString()),n=i.path?"; path="+i.path:"",o=i.domain?"; domain="+i.domain:"",a=i.secure?"; secure":"",document.cookie=[e,"=",encodeURIComponent(t),c,n,o,a].join(""))}e="default"in e?e.default:e;var s,u="async",p="charset",l="",f="error",h="insertBefore",m="_jqjsp",g="onclick",y="on"+f,v="onload",b="onreadystatechange",w="readyState",x="removeChild",k="<script>",_="success",S="timeout",C=window,I=e.Deferred,N=e("head")[0]||document.documentElement,T={},A=0,j={callback:m,url:location.href},O=C.opera,q=!!e("<div>").html("\x3c!--[if IE]><i><![endif]--\x3e").find("i").length;r.setup=function(t){e.extend(j,t)},e.jsonp=r,t(".featuretip.tip-wrap{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1000;background:rgba(0,0,0,.5)}.featuretip .tip{position:fixed;left:50%;top:50%;margin-left:-140px;margin-top:-140px;width:280px;background:#fff;border-top:40px solid #000;text-align:center;line-height:1.25}.featuretip .tip .title{margin:20px auto;font-size:24px;font-weight:700;text-align:center}.featuretip .tip .highlight{font-size:18px}.featuretip .tip .content{font-size:16px;color:#444;text-align:center}.featuretip .tip .button{display:block;margin:20px auto;width:150px;height:30px;font-size:14px;line-height:30px;text-align:center;color:#fff;background:#000;text-decoration:none}",void 0),t(".feature-coin.tip-wrap{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1000;background:rgba(0,0,0,.5)}.feature-coin .tip{position:fixed;left:50%;top:50%;margin-left:-140px;margin-top:-140px;width:280px;background:#fff;text-align:center;line-height:1.25;background-repeat:no-repeat}.feature-coin .tip .tip-close{position:absolute;right:0;top:0;width:25px;height:25px;line-height:25px;text-align:center;font-size:16px;color:#fff;background:#000;cursor:pointer}.feature-coin .tip .title{margin:21px auto;font-size:22px;font-weight:700;text-align:center}.feature-coin .tip .highlight{font-size:18px}.feature-coin .tip .content{padding:4px;font-size:16px;color:#444;text-align:center;height:48px;overflow:hidden}.feature-coin .bottom-button{text-align:center}.feature-coin .tip .button,.feature-coin .tip .coin{display:inline-block;margin:20px auto;width:116px;height:26px;font-size:14px;line-height:26px;text-align:center;color:#fff;background:#000;text-decoration:none;border:2px solid #000}.feature-coin .tip .coin{color:#000;background:#fff}",void 0);var D={Android:function(){return!!navigator.userAgent.match(/Android/i)},BlackBerry:function(){return!!navigator.userAgent.match(/BlackBerry/i)},iOS:function(){return!!navigator.userAgent.match(/iPhone|iPad|iPod/i)},Windows:function(){return!!navigator.userAgent.match(/IEMobile/i)},any:function(){return D.Android()||D.BlackBerry()||D.iOS()||D.Windows()}},E=D.any()?"//m.yohobuy.com/home/mycurrency":"//www.yohobuy.com/home/currency",U=e('<div class="featuretip tip-wrap"><div class="tip"><div class="title"></div><div class="content"></div><a class="button" href="">返回</a></div></div>'),M=e('<div class="feature-coin tip-wrap"><div class="tip"><div class="tip-close">×</div><div class="title"></div><div class="content"></div><div class="bottom-button"><a class="button" href="">去逛逛</a><a class="coin" href=\''+E+'?openby:yohobuy={"action":"go.mine"}\'>查看有货币</a></div></div></div>'),P=function(){if(!window._jssdkQS){var t={},i=void 0,n=void 0,o=window.location.search.slice(1).split("&");for(n=0;n<o.length;n++)i=o[n].split("="),t[i[0]]=i[1];window._jssdkQS=t}return e.extend({},window._jssdkQS)},B=function(){var t=P(),i=[],n="?";delete t.uid,delete t.app_version,delete t.client_type,delete t.session_key,delete t.client_secret;for(var o in t)i.push(o+"="+t[o]);t.expires||i.push("expires="+6048e5),i.push("callback=jQueryMktCode"),n+=i.join("&"),e.getScript("//m.yohobuy.com/activity/wechat/1111"+n,function(){})},L=function(){var t=e("body");t.on("click",".feature-coin .close,.feature-coin .tip-close",function(e){M.fadeOut(),e.preventDefault()}),t.on("click",".feature-coin.tip-wrap",function(e){"feature-coin tip-wrap"===e.target.className&&(M.fadeOut(),e.preventDefault())}),t.on("click",".featuretip .close",function(e){U.fadeOut(),e.preventDefault()}),t.on("click",".featuretip .refresh",function(){location.reload()}),t.on("click",".featuretip.tip-wrap",function(e){"featuretip tip-wrap"===e.target.className&&(U.fadeOut(),e.preventDefault())})},R={queryString:P,init:function(){B(),L()},isApp:function(){var e=P();return!(!e.app_version&&("app"!==e.openrefer||!e.uid))},image:function(e,t,i,n,o){return n=isNaN(Number(n))?2:n,e=e||"",e=e.replace(/{width}/g,t).replace(/{height}/g,i).replace(/{mode}/g,n),e.indexOf("imageView2")>0&&(o=o||90,e+="/q/"+o),e.replace("quality/80","quality/60").replace("http:","")},sParamByIframe:function(t){e.getScript("//m.yohobuy.com/activity/wechat/1111"+t,function(){})},showTip:function(t){t=t||{title:"",content:"",close:!0},U.find(".title").html(t.title),U.find(".content").html(t.content),t.close?U.find(".button").addClass("close"):U.find(".button").addClass("refresh").html("刷新"),e("body").append(U),U.show()},showCoinTip:function(t){t=t||{title:"",content:"",close:!0},M.find(".title").html(t.title),M.find(".content").html(t.content),t.close&&M.find(".button").addClass("close"),t.coin?M.find(".coin").css("display","inline-block"):M.find(".coin").hide(),t.img&&M.find(".tip").css("background-image","url("+t.img+")"),e("body").append(M),M.show()}},z=function(){var e=location.href.split("?")[0];return"//m.yohobuy.com/signin.html?refer="+encodeURIComponent(location.href)+'&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"'+e.replace(/\//g,"\\/")+'","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}'},Q={uid:"",noLoginUrl:z,init:function(){var t=this;return r({url:"//m.yohobuy.com/passport/login/user?callback=?"}).then(function(i){return 200===i.code&&(t.uid=Number(i.data)||0),!t.uid&&R.isApp()&&(t.uid=Number(R.queryString().uid)||0),e.Deferred().resolve(t.uid)},function(){return R.isApp()&&(t.uid=Number(R.queryString().uid)||0),e.Deferred().resolve(t.uid)})},auth:function(){if(!this.uid){var t=z();e("a.auth").attr("href",t)}},favout:function(e){e&&this.uid&&r({url:"//service.yoho.cn/activity/favorite/addFavorite?productSkn="+e+"&uid="+this.uid+"&callback=?"}).then(function(e){200===e.code?R.showTip({content:"恭喜您,收藏成功",close:!0}):R.showTip({content:e.message,close:!0})},function(){R.showTip({title:"收藏失败<br>请刷新重新领取",content:"如多次收藏失败,请联系客服人员<br>带来不便敬请谅解",close:!1})})},getMktCode:function(){return this.uid?Number(this.uid)%1024>=512?0x5af3107a40c3:0x5af3107a40c1:0x5af3107a40c5}},J=["checkJsApi","onMenuShareTimeline","onMenuShareAppMessage","onMenuShareQQ","onMenuShareWeibo","onMenuShareQZone"],$={title:document.title,link:location.href,desc:"YOHO!BUY",imgUrl:"http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png"},G=function(){var t=R.queryString().share_id;if(t)return r({url:"//m.yohobuy.com/activity/share?callback=?",data:{shareId:t}}).then(function(t){return t&&200===t.code&&t.data&&($.title=t.data.title,$.link=t.data.link||location.href,$.desc=t.data.content||t.data.title,$.imgUrl=t.data.pic),e.Deferred().resolve()},function(){return e.Deferred().resolve()});var i=e("#shareTitle").val(),n=e("#shareImg").val(),o=e("#shareDesc").val(),a=e("#shareLink").val();return $.title=i||$.title,$.imgUrl=n||$.imgUrl,$.desc=o||$.desc,$.link=a||$.link,e.Deferred().resolve()},W={init:function(){/QQ/i.test(navigator.userAgent)&&e.ajax({url:"//qzonestyle.gtimg.cn/qzone/qzact/common/share/share.js",dataType:"script",cache:!0,success:function(){G().then(function(){window.setShareInfo&&window.setShareInfo({title:$.title,summary:$.desc,pic:$.imgUrl,url:$.link})})}}),/MicroMessenger/i.test(navigator.userAgent)&&e.ajax({url:"//res.wx.qq.com/open/js/jweixin-1.3.2.js",dataType:"script",cache:!0,success:function(){r({url:"//m.yohobuy.com/activity/wechat/share?callback=?",data:{url:location.href}}).then(function(e){window.wx&&(window.wx.config({debug:!1,appId:e.appId,timestamp:e.timestamp,nonceStr:e.nonceStr,signature:e.signature,jsApiList:J}),G().then(function(){window.wx.ready(function(){window.wx.onMenuShareAppMessage($),window.wx.onMenuShareTimeline($),window.wx.onMenuShareQQ($),window.wx.onMenuShareWeibo($),window.wx.onMenuShareQZone($)})}))})}})}},F={"baidu.com":0x5af3107a4037,"so.com":0x5af3107a4031,"sogou.com":0x5af3107a4035,"bing.com":0x5af3107a4039,"m.sm.cn":0x5af3107a403b,"google.com":0x5af3107a403d},X=function(){var e,t=document.referrer;for(var i in F)if(t.indexOf(i)>-1){e=F[i];break}return e},Y=function(){var e=R.queryString(),t=e.mkt_code||e.union_type||X()||"100000000000349";return delete e.openapp,"yohobuy://yohobuy.com/goapp?ct="+t+'&openby:yohobuy={"action":"go.h5",'+(e.share_id?'"share":"/operations/api/v5/webshare/getShare","shareparam":{"share_id":"'+e.share_id+'"},':"")+'"params":{"islogin":"N","url":"http://feature.yoho.cn'+location.pathname+'","param":'+JSON.stringify(e)+"}}"},H={init:function(){if(R.queryString().openapp){var e=navigator.userAgent.toLowerCase(),t=e.indexOf("os")>-1||e.indexOf("iphone")>-1||e.indexOf("mac")>-1||e.indexOf("ipad")>-1,i=Y();if(t)window.location.href=i;else{var n=document.createElement("iframe");n.src=i,n.style.display="none",document.body.appendChild(n)}}}},Z={cookie:c,setCookie:d},V=function(e){e.app=R.queryString(),e.app.uid=e.uid,r({url:"//m.yohobuy.com/activity/coin/sendCoin?callback=?",data:e}).then(function(e){200===e.code&&e.data?200===e.data.code?R.showCoinTip({title:"恭喜您,成功领取有货币!",content:"特殊情况下到账有延时<br>请耐心等待",close:!0,coin:!0,img:e.data.popupImg}):501===e.data.code?R.showCoinTip({title:"领取失败",content:"哎呀,你来的有点早,活动还没开始呢<br/>稍后再来哦",close:!0,img:e.data.popupImg}):502===e.data.code?R.showCoinTip({title:"领取失败",content:"抱歉,活动已结束了,下次要快哟~~",close:!0,img:e.data.popupImg}):503===e.data.code?R.showCoinTip({title:"已经领取",content:"贪心会长胖,你已经领取过了啦~~",close:!0,img:e.data.popupImg}):504===e.data.code?R.showCoinTip({title:"领取失败",content:"哎呀,你来晚了,有货币已经领完了,<br/>下次早点来哦",close:!0,img:e.data.popupImg}):e.data.msg&&R.showCoinTip({title:"领取失败",content:"抱歉,系统错误,有货君正奋力解决中...请稍后再来",close:!0,img:e.data.popupImg}):e.message&&R.showCoinTip({title:"领取失败",content:"抱歉,系统错误,有货君正奋力解决中...请稍后再来",close:!0,img:e.data&&e.data.popupImg})},function(){R.showCoinTip({title:"领取失败",content:"抱歉,系统错误,有货君正奋力解决中...请稍后再来",close:!0})})},K=function(e){e.app=R.queryString(),e.app.uid=e.app.uid||Z.cookie("app_uid"),e.app.app_version=e.app.app_version||Z.cookie("app_version"),e.app.client_type=e.app.client_type||Z.cookie("app_client_type"),e.app.session_key=e.app.session_key||Z.cookie("app_session_key"),r({url:"//m.yohobuy.com/activity/feature/couponSend?callback=?",data:e}).then(function(e){200===e.code?R.showTip({title:"领取成功",content:"恭喜您,领取成功",close:!0}):401===e.code?R.showTip({title:"已经领取",content:'快去分享给更多<br>喜爱<span class="highlight">潮流</span>的小伙伴吧!',close:!0}):e.message&&R.showTip({title:"领取失败<br>请刷新重新领取",content:e.message+"<br>如多次领取失败,请联系客服人员<br>带来不便敬请谅解",close:!1})},function(){R.showTip({title:"领取失败<br>请刷新重新领取",content:"如多次领取失败,请联系客服人员<br>带来不便敬请谅解",close:!1})})},ee=function(t){if(t){var i=Z.cookie("yoho-coin-token");i&&(V({token:i,uid:t}),Z.setCookie("yoho-coin-token",""))}e("body").on("click",".yoho-coin",function(){var t=e(this).data("token");if(!Q.uid)return Z.setCookie("yoho-coin-token",t),"miniprogram"===window.__wxjs_environment&&"undefined"!=typeof wx&&wx.miniProgram?void wx.miniProgram.navigateTo({url:"../bindPhoneNumber/bindPhoneNumber?h5back="+location.href}):(e("#intimacy-link").length<=0&&e("body").append("<a href='"+Q.noLoginUrl()+'\' style="display:none;" id="intimacy-link"><span class="intimacy-link"></span></a>'),void e(".intimacy-link").click());V({token:t,uid:Q.uid})})},te=function(t){if(t){var i=Z.cookie("yoho-conpon-token");i&&(K({token:i,uid:t}),Z.setCookie("yoho-conpon-token",""))}e("body").on("click",".yoho-conpon",function(){var t=e(this).data("token");if(!Q.uid)return Z.setCookie("yoho-conpon-token",t),"miniprogram"===window.__wxjs_environment&&"undefined"!=typeof wx&&wx.miniProgram?void wx.miniProgram.navigateTo({url:"../bindPhoneNumber/bindPhoneNumber?h5back="+location.href}):(e("#intimacy-link").length<=0&&e("body").append("<a href='"+Q.noLoginUrl()+'\' style="display:none;" id="intimacy-link"><span class="intimacy-link"></span></a>'),void e(".intimacy-link").click());K({token:t,uid:Q.uid})})},ie={init:function(e){ee(e),te(e)}},ne=!1,oe=function(e,t,i,n,o){if(i){e.find(".brand-name").html(i.brand_name),e.find(".product-detail").attr("href","//m.yohobuy.com/product/"+i.product_skn+'.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'+i.product_skn+"}}"),e.find(".product-detail-img").attr("src",R.image(i.default_images,n.w,n.h,2,75)),e.find(".product-name").html(i.product_name),e.find(".vip-price-val").html("¥"+i.vip_price),e.find(".sale-price").html("¥"+i.sales_price),i.sales_price===i.market_price?e.find(".market-price").hide():e.find(".market-price").html("¥"+i.market_price).show();var a=e.find(".product-brand");a&&(i.shop_id?a.attr("href","//m.yohobuy.com/product/index/brand?domain="+i.brand_domain+'&openby:yohobuy={"action":"go.shop","params":{"shop_id":'+i.shop_id+',"shop_template_type":'+(i.shop_template_type||"1")+',"is_red_shop":'+(i.is_red_shop||1)+"}}"):a.attr("href","//m.yohobuy.com/product/index/brand?domain="+i.brand_domain+'&openby:yohobuy={"action":"go.brand","params":{"brand_id":'+i.brand_id+"}}")),o&&(o.I_INDEX||(o.I_INDEX=0),o.I_INDEX++,e.find(".product-detail").attr("fp",JSON.stringify(o)),a&&(o.I_INDEX++,a.attr("fp",JSON.stringify(o))));var r=e.find(".list-product");if(r){var c="",d=t.gender?t.gender:"1,3",s="//list.m.yohobuy.com?gender="+d;r.data("sort")&&(c+=',"sort":'+i.small_sort_id,s+="&sort="+i.small_sort_id),r.data("misort")&&(c+=',"misort":'+i.middle_sort_id,s+="&misort="+i.middle_sort_id),r.data("msort")&&(c+=',"msort":'+i.max_sort_id,s+="&msort="+i.max_sort_id),s+='&openby:yohobuy={"action":"go.list","params":{"actiontype":1,"gender":'+d+c+"}}",r.attr("href",s)}return e.html(e.html()),e}},ae=function e(t){if(t.length){var i=t.shift();return i&&i.default_images?i:e(t)}},re=function(t,i,n){var o=t.attr("cloneitem"),a=t.find(".loading"),c=t.find(".feature-product-info"),d=t.data("rownum");if(c.length){if(n.abtest&&(!i.uid||Number(i.uid)%1024>=512))return void(o?e(c[0]).remove():(c.removeClass("novisible"),a.hide()));var s=t.find(".imgwh").val()||"";s=s.split("x")||[];var u={w:s[0]||300,h:s[1]||400},p=t.attr("fp");p=p?JSON.parse(p):"",r({url:"//m.yohobuy.com/activity/individuation?callback=?",data:e.extend({},i,n)}).then(function(i){if(!i||!i.length)return void(o?e(c[0]).remove():(c.removeClass("novisible"),a.hide()));if(i.length=i.length-i.length%d,o)for(var r=isNaN(Number(o))?i.length:Number(o),s=0;s<r;s++){var l=ae(i);if(0===s){var f=e(c[0]),h=oe(f,n,l,u,p);h?h.removeClass("novisible"):f.remove()}else{var m=oe(e(c[0]).clone(),n,l,u,p);m&&(m.removeClass("novisible"),m.appendTo(t))}}else{for(var g=1;g<i.length;g++)c.last().after(c.clone());var y=t.find(".feature-product-info");y.each(function(t,o){var a=e(o);oe(a,n,ae(i),u,p)}),y.removeClass("novisible"),a.hide()}},function(){o?e(c[0]).remove():(c.removeClass("novisible"),a.hide())})}},ce=function(){var t=Q.getMktCode();R.sParamByIframe("callback=jQueryMktCode&cover=1&mkt_code="+t+"&expires=604800000");var i=[];e("a").each(function(){var t=e(this).attr("href");!t||/^#.*$/.test(t)||/^javascript.*$/i.test(t)||i.push(t)});var n=0,o=setInterval(function(){if(++n>3)return void clearInterval(o);window._yas&&window._yas.sendAppLogs&&window.appBaseLogs&&(clearInterval(o),window._yas.sendAppLogs({appop:"YB_H5_PAGE_AB_OPEN_L",param:JSON.stringify({C_ID:R.queryString().yh_channel||1,PAGE_URL:window.originUrl,PAGE_NAME:decodeURI(window.qs.title||document.title),ACTION_URL:i,CROWD_CODE:t+""})},!0),e("a").click(function(){var i=e(this).attr("href");!i||/^#.*$/.test(i)||/^javascript.*$/i.test(i)||window._yas.sendAppLogs({appop:"YB_H5_PAGE_AB_FLR_C",param:JSON.stringify({C_ID:R.queryString().yh_channel||1,PAGE_URL:window.originUrl,PAGE_NAME:decodeURI(window.qs.title||document.title),F_URL:i,CROWD_CODE:t+""})},!0)}))},1e3)},de=function(t){e(".product-source").each(function(i,n){n=e(n);var o=n.attr("condition");if(o){o=JSON.parse(o);var a=R.queryString().yh_channel;o.abtest&&(ne=!0),a&&(o.yh_channel=a),i>3?setTimeout(function(){re(n,t,o)},300):re(n,t,o)}}),ne&&ce()},se={init:function(e){de(!e&&R.isApp()?{uid:"",udid:R.queryString().udid||""}:{uid:e,udid:Z.cookie("_yasvd")})}};e(function(){H.init(),Q.init().then(function(e){se.init(e),ie.init(e),Q.auth(),W.init(),R.init()})});var ue={auth:Q.auth,favout:Q.favout,getMktCode:function(){return Q.getMktCode()},getUid:function(){return Q.uid}},pe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e){"object"===("undefined"==typeof module?"undefined":pe(module))&&"object"===pe(module.exports)?module.exports=e():"function"==typeof define&&define.amd?define([],e):window._jssdk=e()}(function(){return ue})}(jQuery); |
-
Please register or login to post a comment