topic.js
2.53 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
define(['jquery', 'underscore'], function() {
var Topic = {
wap: false,
initialize: function() {
this.bindEvents();
this.render();
},
bindEvents: function() {
$(document).on('touchstart', '.m-to-top', function(e) {
e.preventDefault();
$('body').animate({
scrollTop: 0
}, 300);
});
},
getParameterByName: function(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
},
render: function() {
var _this = this,
source = this.getParameterByName('source'),
banner = this.getParameterByName('banner'),
title = this.getParameterByName('title'),
tplName = this.getParameterByName('tplName'),
fullScreenBanner = this.getParameterByName('fullScreenBanner'),
modelCode = this.getParameterByName('modelCode');
if (source != '' && source.length > 0) {
if (source && source.toLowerCase() == 'wap') {
this.wap = true;
}
}
if (tplName == '' && tplName.length <= 0) {
tplName = 'product';
}
if (title == '' && title.length <= 0) {
title = '活动专题';
}
if (modelCode == '' || modelCode.length <= 0) {
alert('模块标示[modelCode]不能为空!');
return;
}
if (banner == '' || banner.length <= 0) {
alert('专题banner图[banner]不能为空!');
return;
}
if(tplName.toLowerCase() == 'activity'){
if(fullScreenBanner == '' || fullScreenBanner.length <= 0){
alert('专题全屏banner图[fullScreenBanner]不能为空!');
return;
}
}
require([tplName], function(Ctrl) {
Ctrl.initialize({
wap: _this.wap,
banner: banner,
title: title,
modelCode: modelCode,
fullScreenBanner: fullScreenBanner
});
});
}
};
return Topic;
});