magazine320.js
5.32 KB
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
/*
* @description: 杂志页
* @author: chenglong.wang@yoho.cn
* @date: 2015/1/13
*/
var $ = require('jquery');
var swiper = require('yoho.swiper');
var Hammer = require('hammerjs');
var oShare = require("../plugin/share");
exports.init = function () {
var buySlide=new swiper('#buy-slide',{
paginationClickable: true,
slidesPerView: 'auto',
slideElement: 'li',
onSlideChangeEnd: fallSwiperItems_buy
});
var ruleSlide=new swiper('.rules-slide',{
wrapperClass:"rules-wrapper",
paginationClickable: true,
slidesPerView: 'auto',
slideElement: 'li',
onSlideChangeEnd: fallSwiperItems_rule
});
function fallSwiperItems_buy(){
var currentSlide=arguments[0];
_fallSwiperItems(currentSlide,"buy");
}
function fallSwiperItems_rule(){
var currentSlide=arguments[0];
_fallSwiperItems(currentSlide,"rule");
}
var currentPageNumber=1;
function _fallSwiperItems(currentSlide,type){
var url="";
if(type=="buy") {
url="/channel/magazine/page?type=1&p=";
} else if( type=="zine") {
url="/channel/magazine/page?type=2&p=";
} else {
url="/channel/magazine/rules?p=";
}
var totalLength=$(currentSlide.container).find(".swiper-slide").length;
var currentIndex=currentSlide.activeIndex;
if(totalLength-currentIndex<=6) {
$.ajax({
url:YohoConfig.mainUrl+url+(currentPageNumber++),
cache:false,
success:function(data){
for(var i=0;i<data.data.length;i++) {
var cItem=data.data[i];
var newAppend=currentSlide.createSlide("<a><img src='"+cItem.cover+"' dynamic='"+cItem.dynamic+"'/></a><time>"+cItem.title+"</time>");
newAppend.append();
}
var oLi=$(currentSlide.container).find(".swiper-slide");
var LastSlide = currentSlide.getLastSlide();
oLi.css({'width':'131px'});
$(LastSlide).css({'width':'121px'});
currentSlide.reInit();
}
});
}
}
//e-zine
$.ajax({
type:'GET',
url:YohoConfig.mainUrl+'/channel/magazine/ezine',
success:function(response){
var data = response.data;
var len = data.length;
var item ='';
for(var i=0;i<len;i++){
if (data[i].magazineType == 2) {
item += '<li class="swiper-slide"><a class="magazine-special" href="javascript:;" title="'+data[i].releaseDate+'"><img src="'+data[i].cover+'" alt="" /></a><time>'+data[i].releaseDate+'</time></li>';
}else{
item += '<li class="swiper-slide"><a href="javascript:;" title="'+data[i].releaseDate+'"><img src="'+data[i].cover+'" alt="" /></a><time>'+data[i].releaseDate+'</time></li>';
}
}
$(".zine-wrapper").html(item);
var zineSlide=new swiper('.zine-slide',{
wrapperClass:"zine-wrapper",
paginationClickable: true,
slidesPerView: 'auto',
slideElement: 'li'
});
}
});
//rules动图弹层
var mobile = $("#mobile");
var rules = new Hammer(document.getElementById('rules'));
rules.on('tap',function (event) {
if ($(event.target).is($('img'))) {
var rulesMark = $('<div id="rulesMark"><img src="" class="popImg" /></div>').appendTo(mobile);
var url = $(event.target).attr('dynamic');
var popImg = $('.popImg');
popImg.attr('src',url);
rulesMark.fadeIn();
}
});
//关闭弹层
var close = new Hammer(document.getElementById('mobile'));
close.on('tap',function (event) {
var $temp = $('#rulesMark');
if ($(event.target).is($temp)) {
$temp.fadeOut().remove();
}
});
//分享
var shareUrl = $("#share").attr("data-link");
oShare.init({
shareUrl:shareUrl,
img:$("#share").attr("cover"),
sinaText:'随时引领潮流生活,我正在看《YOHO!潮流志》'+$(".magazine-more").find("time").text()+'期点杂志,每月7日,17日,27日出刊哦~',
fbTextFunction:function(){
return {
des:'随时引领潮流生活,我正在看《YOHO!潮流志》'+$(".magazine-more").find("time").text()+'期点杂志,每月7日,17日,27日出刊哦~',
name:'随时引领潮流生活,我正在看《YOHO!潮流志》'+$(".magazine-more").find("time").text()+'期点杂志,每月7日,17日,27日出刊哦~',
caption:'随时引领潮流生活,我正在看《YOHO!潮流志》'+$(".magazine-more").find("time").text()+'期点杂志,每月7日,17日,27日出刊哦~',
url:location.href
}
},
tweetText:'随时引领潮流生活,我正在看《YOHO!潮流志》'+$(".magazine-more").find("time").text()+'期点杂志,每月7日,17日,27日出刊哦~',
qqText:'随时引领潮流生活,我正在看《YOHO!潮流志》'+$(".magazine-more").find("time").text()+'期点杂志,每月7日,17日,27日出刊哦~'
});
};