nfyx.html
4.99 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<!-- <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> -->
<meta content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" name="viewport" />
<title>农丰网--专题</title>
<link rel="stylesheet" href="../css/common.css">
<link rel="stylesheet" href="../css/topic.css">
</head>
<body class="topicPage">
<div class="m-page"></div>
<script src="../js/jquery-2.1.3.min.js"></script>
<script src="../js/underscore-min.js"></script>
<script type="text/template" id="topicPageTmpl">
<%if(wap){%>
<header class="m-header header-light">
<div class="head">
<a href="javascript:history.go(-1);" class="lt-bar m-icon icon-back">返回</a>
<h1>活动专题</h1>
<!-- <a href="#" class="rt-bar text">分享</a> -->
</div>
</header>
<%}%>
<section class="m-content">
<div class="cover" style="background-image: url(../images/upload/banner_nfyx.jpg); background-size:100% 100%;">
</div>
<ul class="list clearfix" id="topicList">
<%_.each(products, function(item){%>
<li>
<a href="<%=wap ? 'http://m.nong12.com/goods/getIntroductionPageById.do?pid='+item.id : 'http://www.nong12.com/product/'+item.id+'.html'%>">
<div class="pic" style="background-image:url(<%=item.defaultPic%>); background-size:cover;"></div>
<h3><%=item.title%></h3>
<p><em><%=(item.price/100).toFixed(2,10)%>元/<%=item.unit%></em></p>
</a>
</li>
<%})%>
</ul>
</section>
<a href="#" class="m-to-top"></a>
</script>
<script>
$(function(){
var Topic = {
wap:false,
initialize:function(){
this.render();
},
bindEvents:function(){
},
parseUrl: function() {
if(!location.search.split('?')[1] || location.search.split('?')[1].length <= 0){
return;
}
var arr = location.search.split('?')[1].split('&');
var params = {};
for (var i = 0, l = arr.length; i < l; i++) {
var param = arr[i].split('=');
params[param[0]] = param[1];
}
return params;
},
render:function(){
var _this = this;
if(this.parseUrl() && this.parseUrl().source){
source = this.parseUrl().source;
if(source && source.toLowerCase() == 'wap'){
this.wap = true;
}
}
var opt = {
data:{
modelCode: "nfyx"
},
success:function(response){
if(response.code == 200){
response.wap = _this.wap;
$('.m-page').html(_.template($('#topicPageTmpl').html())(response));
}else{
alert('请求数据失败,未知错误!');
}
},
error:function(){
alert('未知错误!');
}
};
this.request(opt);
},
request:function(opt){
$.ajax({
type: 'POST',
data: JSON.stringify(opt.data),
url: 'http://mobapi.nong12.com/mobsiteApp/topic/getTopicProducts.do',
// url: 'http://10.28.2.183/mobsiteApp/topic/getTopicProducts.do',
async: true,
timeout: 15000,
dataType: 'json',
contentType: "application/json; charset=utf-8"
}).done(function(data) {
opt.success && opt.success(data);
}).fail(function(xhr, ajaxOptions, thrownError) {
// console.log('error code: ' + xhr.status + '\n ajaxOptions:' + ajaxOptions + '\n message: ' + thrownError + '\n APIName:' + opt.apiName);
});
}
};
Topic.initialize();
});
</script>
</body>
</html>