|
|
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,
|
|
|
});
|
|
|
|
|
|
});
|
|
|
}
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|