...
|
...
|
@@ -5,143 +5,190 @@ let app = getApp(); |
|
|
let yas;
|
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
navIndex: 0,
|
|
|
navItems: [
|
|
|
{id: -1, name: '限定发售'},
|
|
|
{id: 1, name: '潮流课堂'},
|
|
|
{id: 2, name: '至IN活动'}
|
|
|
],
|
|
|
saleItem: []
|
|
|
},
|
|
|
onLoad: function(options) {
|
|
|
let navIndex = parseInt(`0${options.nav}`, 10);
|
|
|
let navItems = this.data.navItems || [];
|
|
|
let tcategoryId = 0;
|
|
|
let saleItem = [];
|
|
|
|
|
|
navItems.map((nav, index) => {
|
|
|
saleItem.push({ page: 1, end: false, data: [] }); // init
|
|
|
|
|
|
if (navIndex === index) {
|
|
|
tcategoryId = nav.id;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.setData({saleItem, navIndex });
|
|
|
yas = new Yas(app);
|
|
|
yas.pageOpenReport();
|
|
|
return this.getListCategory(tcategoryId, navIndex);
|
|
|
},
|
|
|
onShareAppMessage: function() {
|
|
|
return {
|
|
|
title: '潮人汇聚、尖货集结,一个城市,一个潮流中心!南京新街口艾尚天地YOHO!STORE',
|
|
|
path: `/pages/activity/index?nav=${this.data.navIndex}`
|
|
|
};
|
|
|
},
|
|
|
tapNav: function(e) {
|
|
|
let dataset = e.detail.dataset || {};
|
|
|
let saleItem = this.data.saleItem;
|
|
|
|
|
|
wx.showLoading({
|
|
|
title: '正在加载中...'
|
|
|
});
|
|
|
|
|
|
Object.assign(saleItem[dataset.index], {page: 1, end: false});
|
|
|
|
|
|
this.setData({ saleItem });
|
|
|
return this.getListCategory(dataset.id, dataset.index).then(() => {
|
|
|
this.setData({ navIndex: dataset.index }, wx.hideLoading);
|
|
|
});
|
|
|
},
|
|
|
getListCategory: function(id, index) {
|
|
|
let saleItem = this.data.saleItem[index];
|
|
|
|
|
|
if (saleItem.end) {
|
|
|
return Promise.resolve({code: 402, data: [], message: ''});
|
|
|
}
|
|
|
|
|
|
if (id === -1) {
|
|
|
return this.queryLimitActivityList(index);
|
|
|
}
|
|
|
|
|
|
return this.getActivityList(id, index);
|
|
|
},
|
|
|
|
|
|
// 活动列表
|
|
|
getActivityList: function(id, index) {
|
|
|
return Promise.all([
|
|
|
IndexModel.getActivityNowList({activityType: id, isFront: 1}),
|
|
|
IndexModel.getActivityEndList({activityType: id, isFront: 1})
|
|
|
]).then(res => {
|
|
|
let saleItem = this.data.saleItem;
|
|
|
let itemSub = saleItem[index];
|
|
|
let activityData = [].concat(res[0].data || [], res[1].data || []);
|
|
|
|
|
|
if (itemSub.page === 1) {
|
|
|
itemSub.data = [];
|
|
|
}
|
|
|
|
|
|
itemSub.data = itemSub.data.concat(activityData).map(item => {
|
|
|
return IndexModel.activityDataFormat(item);
|
|
|
});
|
|
|
itemSub.end = true;
|
|
|
|
|
|
saleItem[index] = itemSub;
|
|
|
|
|
|
this.setData({saleItem});
|
|
|
|
|
|
return res;
|
|
|
}).catch(e => {
|
|
|
console.log(e.message);
|
|
|
});
|
|
|
},
|
|
|
|
|
|
// 限定发售列表
|
|
|
queryLimitActivityList: function(index) {
|
|
|
let saleItem = this.data.saleItem;
|
|
|
let itemSub = saleItem[index];
|
|
|
|
|
|
return IndexModel.queryLimitActivityList({pageNum: itemSub.page++, pageSize: 10}).then(res => {
|
|
|
if (res.code !== 200) {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
let limitActivityList = res.data && res.data.limitActivityList || [];
|
|
|
|
|
|
if (itemSub.page === 2) {
|
|
|
itemSub.data = [];
|
|
|
}
|
|
|
|
|
|
itemSub.data = itemSub.data.concat(limitActivityList);
|
|
|
itemSub.end = !limitActivityList.length;
|
|
|
|
|
|
saleItem[index] = itemSub;
|
|
|
|
|
|
this.setData({saleItem});
|
|
|
|
|
|
return res;
|
|
|
}).catch(e => {
|
|
|
console.log(e.message);
|
|
|
});
|
|
|
},
|
|
|
tapBooking: function(e) {
|
|
|
let dataset = e.currentTarget.dataset;
|
|
|
|
|
|
return global.router.go('classroomDetail', {id: dataset.id});
|
|
|
},
|
|
|
tapSaleDetail: function(e) {
|
|
|
let dataset = e.currentTarget.dataset;
|
|
|
|
|
|
if (['C', 'D'].indexOf(dataset.type) > -1) {
|
|
|
return global.router.go('limitSaleNews', {id: dataset.id});
|
|
|
}
|
|
|
|
|
|
global.router.go('limitSaleDetail', {id: dataset.id});
|
|
|
},
|
|
|
tapLoadMore: function() {
|
|
|
let index = this.data.navIndex;
|
|
|
|
|
|
return this.getListCategory(this.data.navItems[index].id, index);
|
|
|
data: {
|
|
|
navIndex: 0,
|
|
|
navItems: [{
|
|
|
id: -1,
|
|
|
name: '限定发售'
|
|
|
},
|
|
|
{
|
|
|
id: 1,
|
|
|
name: '潮流课堂'
|
|
|
},
|
|
|
{
|
|
|
id: 2,
|
|
|
name: '至IN活动'
|
|
|
}
|
|
|
],
|
|
|
saleItem: []
|
|
|
},
|
|
|
onLoad: function(options) {
|
|
|
let navIndex = parseInt(`0${options.nav}`, 10);
|
|
|
let navItems = this.data.navItems || [];
|
|
|
let tcategoryId = 0;
|
|
|
let saleItem = [];
|
|
|
|
|
|
navItems.map((nav, index) => {
|
|
|
saleItem.push({
|
|
|
page: 1,
|
|
|
end: false,
|
|
|
data: []
|
|
|
}); // init
|
|
|
|
|
|
if (navIndex === index) {
|
|
|
tcategoryId = nav.id;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.setData({
|
|
|
saleItem,
|
|
|
navIndex
|
|
|
});
|
|
|
yas = new Yas(app);
|
|
|
yas.pageOpenReport();
|
|
|
return this.getListCategory(tcategoryId, navIndex);
|
|
|
},
|
|
|
onShareAppMessage: function() {
|
|
|
return {
|
|
|
title: '潮人汇聚、尖货集结,一个城市,一个潮流中心!南京新街口艾尚天地YOHO!STORE',
|
|
|
path: `/pages/activity/index?nav=${this.data.navIndex}`
|
|
|
};
|
|
|
},
|
|
|
tapNav: function(e) {
|
|
|
let dataset = e.detail.dataset || {};
|
|
|
let saleItem = this.data.saleItem;
|
|
|
|
|
|
wx.showLoading({
|
|
|
title: '正在加载中...'
|
|
|
});
|
|
|
|
|
|
Object.assign(saleItem[dataset.index], {
|
|
|
page: 1,
|
|
|
end: false
|
|
|
});
|
|
|
|
|
|
this.setData({
|
|
|
saleItem
|
|
|
});
|
|
|
return this.getListCategory(dataset.id, dataset.index).then(() => {
|
|
|
this.setData({
|
|
|
navIndex: dataset.index
|
|
|
}, wx.hideLoading);
|
|
|
});
|
|
|
},
|
|
|
getListCategory: function(id, index) {
|
|
|
let saleItem = this.data.saleItem[index];
|
|
|
|
|
|
if (saleItem.end) {
|
|
|
return Promise.resolve({
|
|
|
code: 402,
|
|
|
data: [],
|
|
|
message: ''
|
|
|
});
|
|
|
}
|
|
|
}); |
|
|
|
|
|
if (id === -1) {
|
|
|
return this.queryLimitActivityList(index);
|
|
|
}
|
|
|
|
|
|
return this.getActivityList(id, index);
|
|
|
},
|
|
|
|
|
|
// 活动列表
|
|
|
getActivityList: function(id, index) {
|
|
|
return Promise.all([
|
|
|
IndexModel.getActivityNowList({
|
|
|
activityType: id,
|
|
|
isFront: 1
|
|
|
}),
|
|
|
IndexModel.getActivityEndList({
|
|
|
activityType: id,
|
|
|
isFront: 1
|
|
|
})
|
|
|
]).then(res => {
|
|
|
let saleItem = this.data.saleItem;
|
|
|
let itemSub = saleItem[index];
|
|
|
let activityData = [].concat(res[0].data || [], res[1].data || []);
|
|
|
|
|
|
if (itemSub.page === 1) {
|
|
|
itemSub.data = [];
|
|
|
}
|
|
|
|
|
|
itemSub.data = itemSub.data.concat(activityData).map(item => {
|
|
|
return IndexModel.activityDataFormat(item);
|
|
|
});
|
|
|
itemSub.end = true;
|
|
|
|
|
|
saleItem[index] = itemSub;
|
|
|
|
|
|
this.setData({
|
|
|
saleItem
|
|
|
});
|
|
|
|
|
|
return res;
|
|
|
}).catch(e => {
|
|
|
console.log(e.message);
|
|
|
});
|
|
|
},
|
|
|
|
|
|
// 限定发售列表
|
|
|
queryLimitActivityList: function(index) {
|
|
|
let saleItem = this.data.saleItem;
|
|
|
let itemSub = saleItem[index];
|
|
|
let params = {
|
|
|
pageNum: itemSub.page++,
|
|
|
pageSize: 10,
|
|
|
belongStoreId: 94,
|
|
|
}
|
|
|
|
|
|
return IndexModel.queryLimitActivityList(params).then(res => {
|
|
|
if (res.code !== 200) {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
let limitActivityList = res.data && res.data.limitActivityList || [];
|
|
|
|
|
|
if (itemSub.page === 2) {
|
|
|
itemSub.data = [];
|
|
|
}
|
|
|
|
|
|
itemSub.data = itemSub.data.concat(limitActivityList);
|
|
|
itemSub.end = !limitActivityList.length;
|
|
|
|
|
|
saleItem[index] = itemSub;
|
|
|
|
|
|
this.setData({
|
|
|
saleItem
|
|
|
});
|
|
|
|
|
|
return res;
|
|
|
}).catch(e => {
|
|
|
console.log(e.message);
|
|
|
});
|
|
|
},
|
|
|
tapBooking: function(e) {
|
|
|
let dataset = e.currentTarget.dataset;
|
|
|
|
|
|
return global.router.go('classroomDetail', {
|
|
|
id: dataset.id
|
|
|
});
|
|
|
},
|
|
|
tapSaleDetail: function(e) {
|
|
|
let dataset = e.currentTarget.dataset;
|
|
|
|
|
|
if (['C', 'D'].indexOf(dataset.type) > -1) {
|
|
|
return global.router.go('limitSaleNews', {
|
|
|
id: dataset.id
|
|
|
});
|
|
|
}
|
|
|
|
|
|
global.router.go('limitSaleDetail', {
|
|
|
id: dataset.id
|
|
|
});
|
|
|
},
|
|
|
tapLoadMore: function() {
|
|
|
let index = this.data.navIndex;
|
|
|
|
|
|
return this.getListCategory(this.data.navItems[index].id, index);
|
|
|
}
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|