indexpage.js
2.9 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
function getdata(){
var url = '/Index/index'
var params = {
t_id: '',
unique_id: localStorage.getItem('unique_id')
}
ajaxsend(url, params, function(res) {
/*console.log(JSON.stringify(res))*/
console.log(res);
var data = JSON.parse(JSON.stringify(res.data));
console.log(data);
//banner图
var banner = data.banner;
console.log(banner)
var html="";
for(var i=0;i<banner.length;i++){
html+='<div class="swiper-slide"><img src="'+banner[i].slide_pic+'" /></div>'
}
$(".swiper-wrapper").html(html)
//食品列表
var goods_list=data.goods_list;
console.log(goods_list)
for(var i=0;i<goods_list.length;i++){
var good=""
// good+='<div class="content_item">'+
// '<img src="'+goods_list[i].thumb+'" />'+
// '<div class="content_item_text">'+
// '<span class="content_item_text_h">'+goods_list[i].goods_name+'</span>'+
// '<span class="content_item_text_subh">'+goods_list[i].goods_name+'</span>'+
// '<div class="content_item_num">'
// '<span class="content_item_num_money">¥'+goods_list[i].goods_price+'</span>'+
// '<span class="content_item_num_num">月销 '+goods_list[i].month_sales+'件</span>'+
// '<div class="choose_num">'+
// '<p class="choose_num_control">'+
// '<span class="num_reduce">-</span>'+
// '<span style="display: inline-block; width: 0.6rem;font-size: 0.36rem;text-align: center;">1</span>'+
// '<span class="num_add">+</span>'+
// '</p>'+
// '</div>'+
// <!--//购物车-->
// '<div class="content_item_shop_car_icon">'+
//' <i class="iconfont icon-gouwuche_select"></i>'
// '</div>'+
// '</div>'+
// '</div>'+
// '</div>'
good+='<div class="content_item">'+
'<img src="'+goods_list[i].thumb+'" />'+
'<div class="content_item_text">'+
'<span class="content_item_text_h">'+goods_list[i].goods_name+'</span>'+
'<span class="content_item_text_subh">'+goods_list[i].goods_description+'</span>'+
'<div class="content_item_num">'+
'<span class="content_item_num_money">'+goods_list[i].goods_price+'</span>'+
'<span class="content_item_num_num">'+goods_list[i].month_sales+'</span>'+
'<div class="choose_num">'+
'<p class="choose_num_control">'+
'<span class="num_reduce">-</span>'+
'<span style="display: inline-block; width: 0.6rem;font-size: 0.36rem;text-align: center;">1</span>'+
'<span class="num_add">+</span>'+
'</p>'
'</div>'+
<!--//购物车-->
'<div class="content_item_shop_car_icon">'+
'<i class="iconfont icon-gouwuche_select"></i>'+
'</div>'
'</div>'+
'</div>'+
'</div>'
// console.log(good)
$(".content").html(good)
}
//美食种类
var type=data.type;
})
}
getdata();