1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
|
var $ = function (obj) {
if
(!obj) return
null ;
if
( typeof
(obj) === "object" ) {
return
new B(obj);
}
else
if ( typeof
(obj) === "string" ) {
if
(obj.indexOf( "#" ) === 0) {
return
new B(document.querySelector(obj));
}
else
{
return
new B(document.querySelectorAll(obj));
}
}
} var
B = function (DOM) {
this .parent = function () {
return
new B(DOM.parentNode);
}
this .children = function () {
return
new B(DOM.children);
}
this .eq = function (i) {
return
new B(DOM[i]);
}
this .length = function () {
if
(DOM) {
if
(DOM.length) {
return
DOM.length;
}
else
{
if
(DOM.innerHTML || DOM.value || DOM.tagName) { /*value for input tagName for empty element*/
return
1;
}
else
{
return
0;
}
}
}
else
{
return
0;
}
}
this .css = function (cssName, cssVal) {
/*$(dom).css({"":"","":""})->$(dom).css("","")->$(dom).css("")*/
if
( typeof
(cssName) === "object" ) {
for
( var
v in
cssName) {
var
x = v; /*临时记录*/
var
_split = v.indexOf( "-" );
if
(_split != -1) {
var
a = v.substring(_split + 1, _split + 2);
v = v.replace( "-"
+ a, a.toUpperCase());
/*console.log(v)*/
}
DOM.style[v] = cssName[x];
}
return
this ;
}
else
{
var
_split = cssName.indexOf( "-" );
if
(_split != -1) {
var
a = cssName.substring(_split + 1, _split + 2);
cssName = cssName.replace( "-"
+ a, a.toUpperCase());
}
if
(cssName && !cssVal) {
return
DOM.style[cssName];
}
else
{ /*background-color to backgroundColor*/
DOM.style[cssName] = cssVal;
return
this ;
}
}
},
this .attr = function (attrName, attrVal) {
/*$(dom).attr({"":"","":""})->$(dom).attr("","")->$(dom).attr("")*/
if
( typeof
(attrName) === "object" ) {
for
( var
v in
attrName) {
DOM.setAttribute(v, attrName[v]);
}
return
this ;
}
else
{
if
(attrName && !attrVal) {
return
DOM.getAttribute(attrName);
}
else
{
DOM.setAttribute(attrName, attrVal);
return
this ;
}
}
},
this .val = function (val) {
/*$(dom).val()*/
if
(val || typeof
(val) === "string" ) { /*val("")*/
DOM.value = val;
return
this ;
}
else
{
return
DOM.value;
}
},
this .html = function (_val) {
/*$(dom).html("")->$(dom).html()->*/
var
val = typeof
(_val) == "number"
? _val.toString() : _val;
if
(val) {
DOM.innerHTML = val;
return
this ;
}
else
{
if
(DOM.length) {
return
DOM[0].innerHTML;
}
else
{
return
DOM.innerHTML;
}
}
},
this .prev = function () {
return
new B(DOM.previousElementSibling);
},
this .next = function () {
return
new B(DOM.nextElementSibling);
},
this .addClass = function (cls) {
/*$(dom).addClass("")*/
//var clsSome = cls.indexOf(" ") ? true : false;/*addClass("a b c")*/
var
_l = this .length();
if
(_l == 1) {
if
(DOM.length) {
if
(DOM[0].classList) {
DOM[0].classList.add(cls);
}
else
{
var
current_className = DOM[0].className;
if
(current_className.indexOf(cls) == -1) {
DOM[0].className = current_className + " "
+ cls;
}
}
}
else
{
if
(DOM.classList) {
DOM.classList.add(cls);
}
else
{
var
current_className = DOM.className;
if
(current_className.indexOf(cls) == -1) {
DOM.className = current_className + " "
+ cls;
}
}
}
return
this ;
}
else
if (_l > 1) {
if
(DOM[0].classList) {
for
( var
i = _l; i--; ) {
DOM[i].classList.add(cls);
}
}
else
{
for
( var
i = _l; i--; ) {
var
current_className = DOM[i].className;
if
(current_className.indexOf(cls) == -1) {
DOM[i].className = current_className + " "
+ cls;
}
}
}
return
DOM[_l - 1];
}
},
this .removeClass = function (cls) {
/*$(dom).removeClass("")*/
//var clsSome = cls.indexOf(" ") ? true : false;/*removeClass("a b c")*/
var
_l = this .length();
if
(_l == 1) {
if
(DOM.length) { /*class*/
if
(DOM[0].classList) {
DOM[0].classList.remove(cls);
}
else
{
var
current_className = DOM[0].className;
if
(current_className.indexOf(cls) != -1) {
DOM[0].className = current_className.replace(cls, "" );
}
}
}
else
{ /*id*/
if
(DOM.classList) {
DOM.classList.remove(cls);
}
else
{
var
current_className = DOM.className;
if
(current_className.indexOf(cls) != -1) {
DOM.className = current_className.replace(cls, "" );
}
}
}
return
this ;
}
else
if (_l > 1) {
if
(DOM[0].classList) {
for
( var
i = _l; i--; ) {
DOM[i].classList.remove(cls);
}
}
else
{
for
( var
i = _l; i--; ) {
var
current_className = DOM[i].className;
if
(current_className.indexOf(cls) != -1) {
DOM[i].className = current_className.replace(cls, "" );
}
}
}
return
DOM[_l - 1];
}
},
this .clearClass = function () {
/*$(dom).clearClass()*/
var
_l = DOM.length;
if
(_l) {
for
( var
i = _l; i--; ) {
DOM[i].className = "" ;
}
return
DOM[_l - 1];
}
else
{
DOM.className = "" ;
return
this ;
}
}
this .hasClass = function (cls) {
/*if( $(dom).hasClass("") )*/
if
(DOM.classList) {
return
DOM.classList.contains(cls);
}
else
{
if
(DOM.className.indexOf(cls) != -1) {
return
true ;
}
else
{
return
false ;
}
}
},
this .show = function () {
/*$(dom).show()*/
DOM.style.display = "block" ;
return
this ;
},
this .hide = function () {
/*$(dom).hide()*/
DOM.style.display = "none" ;
return
this ;
},
this .remove = function () {
/*$(dom).remove()*/
DOM.parentNode.removeChild(DOM);
},
this .trigger = function (type) {
/*$(dom).trigger("touchend")*/
var
_event = document.createEvent( "Event" );
_event.initEvent(type, true , true );
DOM.dispatchEvent(_event);
return
this ;
},
this .bind = function (type, fun) {
/*$(dom).bind("click",function(){})*/
/*if(!DOM) return false;*/
if
(DOM.length) { /*class*/
if
(DOM.length == 1) {
DOM[0].addEventListener(type, function () {
fun.call( this );
}, false )
}
else
{
var
_l = this .length();
for
( var
i = _l; i--; ) {
DOM[i].addEventListener(type, function () {
fun.call( this );
}, false )
}
return
DOM[_l - 1];
}
}
else
{ /*id || window.length == 0*/
if
(DOM.innerHTML || DOM === window || DOM.value || DOM.tagName) { /*tagName for empty element*/
DOM.addEventListener(type, function () {
fun.call( this );
}, false )
}
else
{
return
null ;
}
}
return
this ;
/*
if(type === "tap"){
DOM.addEventListener("touchstart",function(){
event.preventDefault();
},false)
DOM.addEventListener("touchend",function(){
event.preventDefault();
fun.call(this);
},false)
}
*/
},
this .unbind = function (type, fun) {
/*$(dom).unbind("click",fun)*/
DOM.removeEventListener(type, fun, false );
return
this ;
},
this .width = function () {
/*$(dom).width()*/
return
DOM.offsetWidth;
},
this .height = function () {
/*$(dom).height()*/
return
DOM.offsetHeight;
},
this .offset = function () {
/*$(dom).offset().top*/
return
{
top: DOM.offsetTop,
left: DOM.offsetLeft
}
},
this .find = function (options) {
/*$(dom).find("p")*/
return
new B(DOM.querySelectorAll(options));
}
this .append = function (ele) {
if
( typeof
(ele) === "string" ) {
DOM.innerHTML += ele;
}
else
{
DOM.appendChild(ele);
}
return
this ;
}
/*以下为动效*/
this .fadeIn = function (second, callback, fadeOut) {
/*$(DOM).fadeIn(200,function(){ alert("ok"); })*/
var
t = this ;
var
_second;
var
_second_callback = false ;
if
( typeof
(second) === "function" ) {
_second = 200;
_second_callback = true ;
}
else
{
_second = second > 200 ? second : 200;
}
if
(fadeOut) {
t.css( "webkitTransition" , "opacity 200ms ease" );
setTimeout(function () {
t.css( "opacity" , 0.1);
var
transEndOut = function () {
/*console.log(t.attr("id")+"out");*/
$( this ).hide();
_second_callback ? second.call( this ) : (callback && callback.call( this ));
DOM.removeEventListener( "webkitTransitionEnd" , transEndOut, false );
}
DOM.addEventListener( "webkitTransitionEnd" , transEndOut, false );
}, 100)
}
else
{
t.css({ "opacity" : 0, "display" : "block" , "webkitTransition" : "opacity "
+ _second + "ms ease"
});
setTimeout(function () {
t.css( "opacity" , 1);
var
transEndIn = function () {
/*console.log(t.attr("id")+"in");*/
_second_callback ? second.call( this ) : (callback && callback.call( this ));
DOM.removeEventListener( "webkitTransitionEnd" , transEndIn, false );
}
DOM.addEventListener( "webkitTransitionEnd" , transEndIn, false );
}, 100)
}
},
this .fadeOut = function (second, callback) {
this .fadeIn(second, callback, true );
},
this .animate = function ( params , dur, callback, eas, delay) {
/*
检测浏览器类型 webkit moz o IE
left,right,top,bottom
fadeIn,fadeOut,
*/
var
dummyStyle = document.createElement( "div" ).style;
var
prefix = (function () {
var
prefixs = "t,webkitT,MozT,msT,OT" .split( "," ), t, i = 0, l = prefixs.length;
for
(; i < l; i++) {
t = prefixs[i] + "ransform" ;
if
(t in
dummyStyle) {
return
prefixs[i].substr(0, prefixs[i].length - 1);
}
}
return
false ;
} ());
var
cssPrefix = prefix ? "-"
+ prefix.toLowerCase() + "-"
: "" ; /*-webkit- webkitTransition = cssPrefix + ‘transform‘,1s,linear*/
var
transEnd = (function () {
if
(!prefix) return
false ;
var
transitionEnd = {
‘‘ : ‘transitionend‘ ,
‘webkit‘ : ‘webkitTransitionEnd‘ ,
‘Moz‘ : ‘transitionend‘ ,
‘O‘ : ‘otransitionend‘ ,
‘ms‘ : ‘MSTransitionEnd‘
};
return
transitionEnd[prefix];
} ());
var
prefixStyle = function (style) { /*style = transform return = webkitTransform*/
if
(!prefix) return
style;
style = style.charAt(0).toUpperCase() + style.substr(1);
return
prefix + style;
}
var
transform = prefixStyle( ‘transform‘ ),
transitionProperty = prefixStyle( ‘transitionProperty‘ ),
transitionDuration = prefixStyle( ‘transitionDuration‘ ),
transitionTimingFunction = prefixStyle( ‘transitionTimingFunction‘ ),
transitionDelay = prefixStyle( ‘transitionDelay‘ );
/*transformOrigin = prefixStyle(‘transformOrigin‘),*/
var
paramArray = new
Array();
for
( var
param in
params ) {
paramArray.push(param);
}
/*
需要变换的属性 width height font-size left right=transform translateX top bottom=translateY 放大 缩小=scale 旋转=rotate
translate的属性都不影响周边 都是浮着改变
left top jquery也是不影响周边 而且不给父级加position属性
*/
var
transEndFun = function (e) {
callback ? callback() : "" ;
e.target.removeEventListener(transEnd, transEndFun, false );
}
this .css({
transitionProperty: paramArray. join ( "," ),
transitionDuration: dur ? dur / 1000 + "s"
: ".2s" ,
transitionTimingFunction: eas ? eas : "ease" ,
transitionDelay: delay ? delay / 1000 + "s"
: "0s"
}).dom.addEventListener(transEnd, transEndFun, false );
/*设置CSS 此时已经有了动画参数 根据参数的长度*/
var
iCss = 0, param_l = paramArray.length;
for
(; iCss < param_l; iCss++) {
var
i = paramArray[iCss];
this .css(i, params [i]);
}
return
this ;
}
} var
M = {
baseUrl: "/vshop/1/H5" ,
h5Href: location.href,
version: 201402141327,
doc: document,
win: window,
w: document.body.offsetWidth,
h: document.body.offsetHeight,
toJSON: function (obj) {
return
JSON.stringify(obj);
},
trim: function (str) {
return
str.replace(/(^\s*)|(\s*$)/g, "" );
},
jsonp: function (href, _callback, _err) {
var
date_start = new
Date(); /*局部*/
var
_t = date_start.getTime() + "_"
+ Math.random().toString().substr(2); /*后缀防重复*/
var
a = "jsonpcallback_"
+ _t; /*全局 避免重复*/
var
b = "interval_"
+ _t; /*全局 避免重复 循环处理*/
window[a] = function (json) {
window[a] = undefined;
_callback && _callback(json);
}
window[b] = setInterval(function () {
if
( new
Date() - date_start > 8000) {
clearInterval(window[b]);
_err && _err();
}
}, 100);
M.loadScript(href + (href.indexOf( "?" ) == -1 ? "?callback="
: "&callback=" ) + a, function () {
/*
如果地址不对 不会触发onload事件 也就不考虑了
如果地址对 并且 已经加载了 那就是已经返回值了
*/
clearInterval(window[b]);
});
},
ajax: function (url, data, callback, error_callback, method, async) {
var
request = new
XMLHttpRequest();
request.open(method ? method : ‘POST‘ , url, async ? async : true );
request.setRequestHeader( "Content-Type" , "application/x-www-form-urlencoded" );
request.send(data)
var
date_start = new
Date();
var
ajax_notice = setInterval(function () {
if
( new
Date() - date_start > 8000) {
//alert("网络不给力,一会再试试吧");
clearInterval(ajax_notice);
error_callback && error_callback();
}
}, 100);
request.onreadystatechange = function () {
if
(request.readyState == 4) {
clearInterval(ajax_notice);
switch
(request.status) {
case
200:
callback && callback(request.responseText);
break ;
case
404:
alert( "404--URL地址未找到" );
ajax_error();
break ;
case
500:
alert( "500--服务器错误" );
ajax_error();
break ;
}
}
}
function ajax_error() {
ajax.abort();
error_callback && error_callback();
}
},
get : function (href, callback, error_callback) {
var
ajax = new
XMLHttpRequest();
ajax.open( "GET" , href, true );
ajax.send();
var
date_start = new
Date();
var
ajax_notice = setInterval(function () {
if
( new
Date() - date_start > 8000) {
alert( "网络不给力,一会再试试吧" );
error_callback && error_callback();
}
}, 100);
ajax.onreadystatechange = function () {
if
(ajax.readyState == 4) {
clearInterval(ajax_notice);
switch
(ajax.status) {
case
200:
callback(ajax.responseText);
break ;
case
404:
alert( "404--URL地址未找到" );
ajax_error();
break ;
case
500:
alert( "500--服务器错误" );
ajax_error();
break ;
}
}
}
function ajax_error() {
ajax.abort();
error_callback && error_callback();
}
},
lazyLoad: function () { /*原生 非B*/
var
img = M.doc.getElementsByClassName( "lazy_load" ), img_l = img.length;
if
(img_l) {
var
img_arr = [];
var
lazy_src = "" ;
for
( var
i = 0; i < img_l; i++) {
(function (i) {
var
z = i, that = img[z], src = that.getAttribute( "data-src" ), thatClass = that.className;
that.src = lazy_src;
img_arr[z] = new
Image();
img_arr[z].src = src;
img_arr[z].onload = function () {
that.src = src;
that.className = thatClass.replace( "lazy_load" , "" );
}
} (i));
}
}
},
loadScript: function (url, callback) {
var
script = document.createElement( "script" );
if
(script.readyState) {
script.onreadystatechange = function () {
if
(script.readyState == "loaded"
|| script.readyState == "complete" ) { script.onreadystatechange = null ; callback && callback(); }
}
}
else
{ script.onload = function () { callback && callback(); } }
script.src = (url.indexOf( "?" ) > 0) ? (url + "&ver="
+ M.version) : (url + "?ver="
+ M.version);
var
_s = document.getElementsByTagName( "script" )[0];
_s.parentNode.insertBefore(script, _s);
},
json: function (data) {
return
JSON.parse(data);
},
urlQuery: function (name) {
var
href = location.search;
href = href.replace(/#[^&]*$/, ‘‘ );
var
a = href.substr(href.indexOf(name));
var
b = new
Array();
if
(a.indexOf( "&" ) == -1) {
b = a.split( "=" );
}
else
{
b = a.substr(0, a.indexOf( "&" )).split( "=" );
}
return
b[1];
},
getCookie: function (name) {
if
(localStorage) {
return
localStorage.getItem(name) ? localStorage.getItem(name) : (sessionStorage.getItem(name) ? sessionStorage.getItem(name) : "" );
}
else
{
var
cookie_start = document.cookie.indexOf(name);
var
cookie_end = document.cookie.indexOf( ";" , cookie_start);
return
cookie_start == -1 ? ""
: unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
}
},
setCookie: function (name, value, isSession) {
if
(localStorage) {
isSession ? sessionStorage.setItem(name, value) : localStorage.setItem(name, value);
}
else
{
var
expires = new
Date();
expires.setTime(expires.getTime() + 2592000000);
isSession ? document.cookie = escape(name) + ‘=‘
+ escape(value) + ( ‘/‘ ) + ( ‘‘ ) + ( ‘‘ ) : document.cookie = escape(name) + ‘=‘
+ escape(value) + (expires ? ‘; expires=‘
+ expires.toGMTString() : ‘‘ ) + ( ‘/‘ ) + ( ‘‘ ) + ( ‘‘ );
}
},
delCookie: function (name) {
if
(localStorage) {
localStorage.removeItem(name);
}
else
{
document.cookie = name + "=;expires="
+ ( new
Date(0)).toGMTString();
}
},
clearCookie: function () {
if
(localStorage) {
localStorage.clear();
}
else
{
var
keys = document.cookie.match(/[^ =;]+(?=\=)/g);
if
(keys) {
var
l = keys.length;
for
( var
i = l; i--; )
document.cookie = keys[i] + ‘=0;expires=‘
+ new
Date(0).toUTCString()
}
}
},
ua: function () {
return
navigator.userAgent.toLowerCase();
},
isMobile: function () {
return
M.ua().match(/iPhone|iPad|iPod|Android|IEMobile/i);
},
isAndroid: function () {
return
M.ua().indexOf( "android" ) != -1 ? 1 : 0;
},
isIOS: function () {
var
a = M.ua();
return
(a.indexOf( "iphone" ) != -1 || a.indexOf( "ipad" ) != -1 || a.indexOf( "ipod" ) != -1) ? 1 : 0;
},
platform: function () {
if
(M.isMobile()) { /*移动端*/
if
(M.isIOS()) {
return
"IOS" ;
}
else
if (M.isAndroid()) {
return
"Android" ;
}
else
{
return
"other-mobile" ;
}
}
else
{ /*PC端*/
return
"PC" ;
}
},
isWeixin: function () {
return
M.ua().indexOf( "micromessenger" ) != -1 ? 1 : 0;
},
isWeixinPay: function () {
if
(M.isWeixin()) {
var
a = M.ua();
var
b = a.substr(a.indexOf( "micromessenger" ), 18).split( "/" );
if
(Number(b[1]) >= 5) {
return
1;
}
else
{
return
0;
}
}
else
{
return
0;
}
},
/*alert & confirm start*/
_alert: function (txt, callback) {
if
($( "#_alert_bg" ).length()) {
$( "#_alert_bg" ).show();
}
else
{
var
_d = document;
var
_alert_bg = _d.createElement( "div" );
_alert_bg.setAttribute( "id" , "_alert_bg" );
_d.body.appendChild(_alert_bg);
var
_alert_content = _d.createElement( "div" );
_alert_content.setAttribute( "id" , "_alert_content" );
_alert_bg.appendChild(_alert_content);
}
var
_this = $( "#_alert_content" );
_this.html(txt).fadeIn(function () {
setTimeout(function () {
_this.fadeOut(function () {
$( "#_alert_bg" ).hide();
callback && callback();
})
}, 1000)
});
},
_confirm: function (tle, btnA, btnB, submit_fun, cancel_fun) {
var
_d = document;
var
_confirm_bg = _d.createElement( "div" );
_confirm_bg.setAttribute( "id" , "_confirm_bg" );
_d.body.appendChild(_confirm_bg);
var
_confirm_content = _d.createElement( "div" );
_confirm_content.setAttribute( "id" , "_confirm_content" );
_confirm_bg.appendChild(_confirm_content);
var
_wrap = $( "#_confirm_content" );
var
_temp = "" ;
_temp = _temp + "<p>"
+ tle + "</p>" ;
_temp = _temp + "<em id=‘_confirm_shadowA‘> </em>" ;
_temp = _temp + "<em id=‘_confirm_shadowB‘> </em>" ;
_temp = _temp + "<div id=‘_confirm_btnW‘>" ;
if
(btnB[0]) { //B按钮有
_temp = _temp + "<div id=‘_confirm_btnA‘ class=‘"
+ btnA[1] + "‘>"
+ btnA[0] + "</div>" ;
_temp = _temp + "<em id=‘_confirm_shadowC‘> </em>" ;
_temp = _temp + "<em id=‘_confirm_shadowD‘> </em>" ;
_temp = _temp + "<div id=‘_confirm_btnB‘ class=‘"
+ btnB[1] + "‘>"
+ btnB[0] + "</div>" ;
}
else
{
_temp = _temp + "<div id=‘_confirm_btnA‘ class=‘"
+ btnA[1] + "‘ style=‘width:100%‘>"
+ btnA[0] + "</div>" ;
}
_temp = _temp + "</div>" ;
_wrap.html(_temp).fadeIn();
$( "#_confirm_btnA" ).bind( "click" , function () { /*cancel*/
cancel_fun && cancel_fun();
_wrap.fadeOut(function () {
$( "#_confirm_bg" ).remove();
})
})
if
(btnB[0]) { //B按钮有
$( "#_confirm_btnB" ).bind( "click" , function () { /*submit*/
submit_fun();
_wrap.fadeOut(function () {
$( "#_confirm_bg" ).remove();
})
})
}
},
/*alert & confirm end*/
init: function () {
//M.isWeixin() || window.scroll(0,0);
setTimeout(function () {
if
($( "#cart" ).length()) {
/*if(Number(M.getCookie("WD_c_l"))){
$("#cart_bg").addClass("orange_bg").parent().append("<i id=‘cart_count‘ class=‘abs c_txt‘>"+ M.getCookie("WD_c_l") +"</i>");
}*/
if
(M.getCookie( "WD_i" )) {
var
count = M.getCookie( "WD_i" ).split( "|" ).length;
$( "#cart_bg" ).addClass( "orange_bg" ).parent().append( "<i id=‘cart_count‘ class=‘abs c_txt‘>"
+ count + "</i>" );
}
$( "#cart" ).fadeIn();
}
}, 100)
}
} $(window).bind( "load" , function () {
M.init();
}) |