|
|
|
|
|
import { getChannelCode, getGenderCode, getRecPosCode, getRecommandContentCode, getResourceCode,getHomeContentCode} from '../../utils/home';
|
|
|
import homeService from './indexService.js'
|
|
|
import { parseProductListData } from '../../utils/productListUtil';
|
|
|
|
|
|
//获取应用实例
|
|
|
let app = getApp()
|
...
|
...
|
@@ -36,69 +37,6 @@ Page({ |
|
|
},
|
|
|
}
|
|
|
},
|
|
|
|
|
|
'bannerList': [
|
|
|
{'src': 'http://img10.static.yhbimg.com/yhb-img01/2018/11/21/13/01028381b6f5db69fdbebba95f3aade7bc.jpg'},
|
|
|
{'src': 'http://img10.static.yhbimg.com/yhb-img01/2018/11/16/09/0159de652b1e164b2166e7665a0c329e4d.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/14/17/01e5af09eaec1c1d1e1c920586e8127489.jpg'}
|
|
|
],
|
|
|
'categoryList': [
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'}
|
|
|
],
|
|
|
'brandList':[
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/07/10/13/01f3619775fe5f22467ef884b614b1ec3e.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/07/10/13/01f3619775fe5f22467ef884b614b1ec3e.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/07/10/13/01f3619775fe5f22467ef884b614b1ec3e.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/07/10/13/01f3619775fe5f22467ef884b614b1ec3e.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/07/10/13/01f3619775fe5f22467ef884b614b1ec3e.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/07/10/13/01f3619775fe5f22467ef884b614b1ec3e.jpg'},
|
|
|
{'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/07/10/13/01f3619775fe5f22467ef884b614b1ec3e.jpg'}
|
|
|
],
|
|
|
'activityList': [
|
|
|
{'src': 'http://img13.static.yhbimg.com/article/2018/11/21/18/02a7e5be8e9c6e85492fa61d1cb57f913c.jpg'},
|
|
|
{'src': 'http://img13.static.yhbimg.com/article/2018/11/21/18/02a7e5be8e9c6e85492fa61d1cb57f913c.jpg'},
|
|
|
{'src': 'http://img13.static.yhbimg.com/article/2018/11/21/18/02a7e5be8e9c6e85492fa61d1cb57f913c.jpg'},
|
|
|
{'src': 'http://img13.static.yhbimg.com/article/2018/11/21/18/02a7e5be8e9c6e85492fa61d1cb57f913c.jpg'}
|
|
|
],
|
|
|
'productList': [
|
|
|
{
|
|
|
'src': 'http://img13.static.yhbimg.com/goodsimg/2017/09/27/13/02dac922f0856fcb6d9912865243cff2f6.jpg',
|
|
|
'title': 'THETHING',
|
|
|
'price': '¥1200.00'
|
|
|
},{
|
|
|
'src': 'http://img13.static.yhbimg.com/goodsimg/2017/09/27/13/02dac922f0856fcb6d9912865243cff2f6.jpg',
|
|
|
'title': 'THETHING羽绒服羽绒服羽绒服',
|
|
|
'price': '¥1200.00'
|
|
|
},{
|
|
|
'src': 'http://img13.static.yhbimg.com/goodsimg/2017/09/27/13/02dac922f0856fcb6d9912865243cff2f6.jpg',
|
|
|
'title': 'Red Charcoal',
|
|
|
'price': '¥1109.00'
|
|
|
},{
|
|
|
'src': 'http://img10.static.yhbimg.com/goodsimg/2018/10/25/11/01ac8f33d0272b233c7e303424d342ff65.jpg',
|
|
|
'title': 'Red Charcoal',
|
|
|
'price': '¥1109.00'
|
|
|
},{
|
|
|
'src': 'http://img10.static.yhbimg.com/goodsimg/2018/10/25/11/01ac8f33d0272b233c7e303424d342ff65.jpg',
|
|
|
'title': 'Red Charcoal',
|
|
|
'price': '¥1109.00'
|
|
|
},{
|
|
|
'src': 'http://img13.static.yhbimg.com/goodsimg/2017/09/27/13/02dac922f0856fcb6d9912865243cff2f6.jpg',
|
|
|
'title': 'THETHING',
|
|
|
'price': '¥1200.00'
|
|
|
}
|
|
|
],
|
|
|
'singleImage': 'http://img10.static.yhbimg.com/yhb-img01/2018/06/20/13/01b8a424ad754cf867b0bbe8d66e833300.jpg'
|
|
|
},
|
|
|
onLoad: function () {
|
|
|
this.fetchNewHomeData();
|
...
|
...
|
@@ -193,81 +131,88 @@ Page({ |
|
|
homelist: currentData.data,
|
|
|
})
|
|
|
}
|
|
|
console.log('====================================');
|
|
|
console.log('==============楼层数据===============');
|
|
|
console.log(currentData.data);
|
|
|
console.log('====================================');
|
|
|
|
|
|
// this.fetchRecommend(force);
|
|
|
this.fetchRecommend(force);
|
|
|
},
|
|
|
|
|
|
//请求(男生、女生)猜你喜欢数据
|
|
|
// fetchRecommend: function (force) {
|
|
|
// let currentChannel = this.data.selectedChannel;
|
|
|
// let currentChannelData = this.data.newChannels[currentChannel];
|
|
|
// let recommend = currentChannelData.recommend;
|
|
|
// if (recommend.data && recommend.data.length > 0 && !force) {
|
|
|
// return;
|
|
|
// }
|
|
|
fetchRecommend: function (force) {
|
|
|
let currentChannel = this.data.selectedChannel;
|
|
|
let currentChannelData = this.data.newChannels[currentChannel];
|
|
|
let recommend = currentChannelData.recommend;
|
|
|
if (recommend.data && recommend.data.length > 0 && !force) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// let param = {};
|
|
|
// let gender = getGenderCode(currentChannel);
|
|
|
// let yh_channel = getChannelCode(currentChannel);
|
|
|
// let content_code = getRecommandContentCode(currentChannel);
|
|
|
// let rec_pos = getRecPosCode(currentChannel);
|
|
|
// param = {
|
|
|
// content_code,
|
|
|
// gender,
|
|
|
// yh_channel,
|
|
|
// rec_pos,
|
|
|
// };
|
|
|
let param = {};
|
|
|
let gender = getGenderCode(currentChannel);
|
|
|
let yh_channel = getChannelCode(currentChannel);
|
|
|
let content_code = getRecommandContentCode(currentChannel);
|
|
|
let rec_pos = getRecPosCode(currentChannel);
|
|
|
param = {
|
|
|
content_code,
|
|
|
gender,
|
|
|
yh_channel,
|
|
|
rec_pos,
|
|
|
};
|
|
|
|
|
|
// let newChannelData = objectAssign(currentChannelData, { recommend: objectAssign(recommend, { isLoading: true, }) });
|
|
|
// let newChannels = this.data.newChannels;
|
|
|
// newChannels[currentChannel] = newChannelData;
|
|
|
let newChannelData = Object.assign(currentChannelData, { recommend: Object.assign(recommend, { isLoading: true, }) });
|
|
|
let newChannels = this.data.newChannels;
|
|
|
newChannels[currentChannel] = newChannelData;
|
|
|
|
|
|
// this.setData({
|
|
|
// newChannels: newChannels,
|
|
|
// });
|
|
|
this.setData({
|
|
|
newChannels: newChannels,
|
|
|
});
|
|
|
|
|
|
// homeService.getProductlist(param)
|
|
|
// .then(json => {
|
|
|
// if (!json || !json.code || json.code != 200) {
|
|
|
// let currentChannel = this.data.selectedChannel;
|
|
|
// let currentChannelData = this.data.newChannels[currentChannel];
|
|
|
// let newChannelData = objectAssign(currentChannelData, { recommend: objectAssign(recommend, { isLoading: false, error: { code: json.code, message: json.message } }) });
|
|
|
// let newChannels = this.data.newChannels;
|
|
|
// newChannels[currentChannel] = newChannelData;
|
|
|
homeService.getProductlist(param)
|
|
|
.then(json => {
|
|
|
console.log('==============商品数据===============');
|
|
|
console.log(json);
|
|
|
console.log('====================================');
|
|
|
if (!json || !json.code || json.code != 200) {
|
|
|
let currentChannel = this.data.selectedChannel;
|
|
|
let currentChannelData = this.data.newChannels[currentChannel];
|
|
|
let newChannelData = Object.assign(currentChannelData, { recommend: Object.assign(recommend, { isLoading: false, error: { code: json.code, message: json.message } }) });
|
|
|
let newChannels = this.data.newChannels;
|
|
|
newChannels[currentChannel] = newChannelData;
|
|
|
|
|
|
// this.setData({
|
|
|
// newChannels: newChannels,
|
|
|
// });
|
|
|
// return;
|
|
|
// }
|
|
|
this.setData({
|
|
|
newChannels: newChannels,
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// let data = json.data.product_list;
|
|
|
// data = parseBrandListData(data);
|
|
|
// let currentChannel = this.data.selectedChannel;
|
|
|
// let currentChannelData = this.data.newChannels[currentChannel];
|
|
|
// let newChannelData = objectAssign(currentChannelData, { recommend: objectAssign(recommend, { isLoading: false, data }) });
|
|
|
// let newChannels = this.data.newChannels;
|
|
|
// newChannels[currentChannel] = newChannelData;
|
|
|
let data = json.data.product_list;
|
|
|
data = parseProductListData(data);
|
|
|
let currentChannel = this.data.selectedChannel;
|
|
|
let currentChannelData = this.data.newChannels[currentChannel];
|
|
|
let newChannelData = Object.assign(currentChannelData, { recommend: Object.assign(recommend, { isLoading: false, data }) });
|
|
|
let newChannels = this.data.newChannels;
|
|
|
newChannels[currentChannel] = newChannelData;
|
|
|
|
|
|
// this.setData({
|
|
|
// newChannels: newChannels,
|
|
|
// });
|
|
|
// })
|
|
|
// .catch(error => {
|
|
|
// let currentChannel = this.data.selectedChannel;
|
|
|
// let currentChannelData = this.data.newChannels[currentChannel];
|
|
|
// let newChannelData = objectAssign(currentChannelData, { recommend: objectAssign(recommend, { isLoading: false, error }) });
|
|
|
// let newChannels = this.data.newChannels;
|
|
|
// newChannels[currentChannel] = newChannelData;
|
|
|
this.setData({
|
|
|
newChannels: newChannels,
|
|
|
});
|
|
|
|
|
|
// this.setData({
|
|
|
// newChannels: newChannels,
|
|
|
// });
|
|
|
// });
|
|
|
// },
|
|
|
console.log('====================================');
|
|
|
console.log(newChannels);
|
|
|
console.log('====================================');
|
|
|
})
|
|
|
.catch(error => {
|
|
|
let currentChannel = this.data.selectedChannel;
|
|
|
let currentChannelData = this.data.newChannels[currentChannel];
|
|
|
let newChannelData = Object.assign(currentChannelData, { recommend: Object.assign(recommend, { isLoading: false, error }) });
|
|
|
let newChannels = this.data.newChannels;
|
|
|
newChannels[currentChannel] = newChannelData;
|
|
|
|
|
|
this.setData({
|
|
|
newChannels: newChannels,
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
|
|
|
jumpByRuleEvent(event) {
|
|
|
console.log(event.detail);
|
...
|
...
|
|