index.js
3.06 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
import api from '../../common/api';
import { parseProductListData } from '../../utils/productListUtil';
Page({
data:{
tabs:[
{
id:0,
name: "最新0",
isShowIcon: false,
data:{},
},
{
id: 1,
name: "最新1",
isShowIcon: false,
data:{},
},
{
id: 2,
name: "最新2",
isShowIcon: false,
data:{},
},
{
id: 3,
name: "最新3",
isShowIcon: true,
iconUrl: "../../assets/images/arrow_normal@2x.png",
iconType: 1,
data:{},
}
],
activeIndex: 0,
contentWidth: 0,
contentHeight: 0,
},
onLoad: function () {
try{
let systemInfo = tt.getSystemInfoSync();
let contentWidth = systemInfo.screenWidth;
// let contentWidth = screenWidth;
let contentHeight = systemInfo.screenHeight - 115;
this.setData({
contentWidth,
contentHeight,
})
}catch(e){
console.log(e.message)
}
let tab = this.data.tabs[0];
this.fechProductList(tab);
},
onTabClick: function (e) {
//获取到点击当前Tab的信息
let tab = e.detail;
this.fechProductList(tab);
},
fechProductList: function (tab) {
// debugger
let id = tab.id;
let orderType = tab.iconType;
let iconUrl = tab.iconUrl;
let order = "s_p_desc";
// console.log("id:"+id+"===orderType:"+orderType);
if(id === 1){
order = "s_t_desc";
}else if(id === 2){
order = "h_v_desc";
}else if(id === 3){
if(orderType && orderType === 1){
order= "s_p_desc";
}else{
order= "s_p_asc";
}
}else {
order = "s_p_desc";
}
let that = this;
// that.data.tabs.activeIndex = id;
let param = {
method: "app.search.category",
firstProductSkn: "51167928",
gender:"1,3",
limit: 10,
page: 1,
sort: "116",
subCategoryId: "48",
title: "POLO",
order: order,
}
api.get({data: param})
.then(data => {
let listData = data.data;
let productList = listData.product_list;
// let tab = that.tabs[0]
// tab.data = data;
let tabs = that.data.tabs;
for (var index in productList) {
let skn = productList[index].product_skn;
let name = productList[index].product_name;
// console.log("name:"+name+"==skn:"+skn)
}
productList = parseProductListData(productList);
listData.product_list = productList;
tabs[id].data = listData;
// tablist[id].iconType = orderType;
// tablist[id].iconUrl = iconUrl;
// console.log("id:"+id)
that.setData({
tabs: tabs,
activeIndex: id,
});
});
}
})