|
|
import wx from '../../utils/wx';
|
|
|
import config from '../../common/config';
|
|
|
import Yas from '../../common/yas';
|
|
|
import AccountModel from '../../models/account/index';
|
|
|
import LimitModel from '../../models/limit/index';
|
|
|
|
|
|
// 获取应用实例
|
|
|
let app = getApp();
|
...
|
...
|
@@ -10,8 +10,35 @@ let router = global.router; |
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
tabSelected: 0,
|
|
|
refreshText: '下拉刷新',
|
|
|
userInfo: {},
|
|
|
hasUserInfo: false
|
|
|
tabBarArr: [
|
|
|
{
|
|
|
icon: '../../static/images/icon_rmfs_n@3x.png',
|
|
|
iconSelected: '../../static/images/icon_rmfs_p@3x.png',
|
|
|
name: '热门发售',
|
|
|
method: 'app.limitProduct.hotLimitProduct'
|
|
|
},
|
|
|
{
|
|
|
icon: '../../static/images/icon_jjfs_n@3x.png',
|
|
|
iconSelected: '../../static/images/icon_jjfs_p@3x.png',
|
|
|
name: '即将发售',
|
|
|
method: 'app.limitProduct.soonToSaleLimitProduct'
|
|
|
},
|
|
|
{
|
|
|
icon: '../../static/images/icon_yjfs_n@3x.png',
|
|
|
iconSelected: '../../static/images/icon_yjfs_p@3x.png',
|
|
|
name: '已经发售',
|
|
|
method: 'app.limitProduct.alreadySaleLimitProduct'
|
|
|
}
|
|
|
],
|
|
|
listData: [
|
|
|
{}, {}, {}
|
|
|
],
|
|
|
icon: {
|
|
|
clock: '../../static/images/clock_left.png'
|
|
|
}
|
|
|
},
|
|
|
onLoad: function() {
|
|
|
yas = new Yas(app);
|
...
|
...
|
@@ -22,27 +49,89 @@ Page({ |
|
|
hasUserInfo: true
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
onReady: function() {
|
|
|
|
|
|
this.getList(0, 1, 20, false);
|
|
|
},
|
|
|
onShow: function() {
|
|
|
yas.pageOpenReport();
|
|
|
},
|
|
|
onPullDownRefresh: function() {
|
|
|
this.setData({
|
|
|
refreshText: '加载中...'
|
|
|
});
|
|
|
|
|
|
|
|
|
this.getList(this.data.tabSelected, 1, 20, false).then(() => {
|
|
|
wx.stopPullDownRefresh();
|
|
|
});
|
|
|
|
|
|
},
|
|
|
onReachBottom: function() {
|
|
|
let page = this.data.listData[this.data.tabSelected].page;
|
|
|
let page_total = this.data.listData[this.data.tabSelected].page_total;
|
|
|
|
|
|
if (page < page_total) {
|
|
|
page += 1;
|
|
|
this.getList(this.data.tabSelected, page, 20, true);
|
|
|
}
|
|
|
|
|
|
},
|
|
|
getUserInfo: function(e) {
|
|
|
console.log(e);
|
|
|
if (e.detail.errMsg === 'getUserInfo:ok') {
|
|
|
app.setUserInfo(e.detail.userInfo);
|
|
|
// AccountModel.decodeUserInfo();
|
|
|
}
|
|
|
app.setUserInfo(e.detail.userInfo);
|
|
|
this.setData({
|
|
|
userInfo: e.detail.userInfo,
|
|
|
hasUserInfo: true
|
|
|
});
|
|
|
},
|
|
|
tabChange: function(e) {
|
|
|
let index = e.currentTarget.dataset.index;
|
|
|
|
|
|
if (index !== this.data.tabSelected) {
|
|
|
this.setData({
|
|
|
tabSelected: index
|
|
|
});
|
|
|
if (!this.data.listData[index].limitProductVoList || this.data.listData[index].limitProductVoList.length === 0) {
|
|
|
this.getList(index, 1, 20, false);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* index: tab的index,page:分页,limit: 每页数量, isBottom:是否是到达底部后触发
|
|
|
*/
|
|
|
getList: function(index, page, limit, isBottom) { // 获取限定发售列表
|
|
|
let method = this.data.tabBarArr[index].method;
|
|
|
let that = this;
|
|
|
|
|
|
return LimitModel.getLimitSaleList({
|
|
|
method: method,
|
|
|
page: page,
|
|
|
limit: limit
|
|
|
}).then(res => {
|
|
|
console.log(res.data);
|
|
|
if (res.data && res.data.limitProductVoList) {
|
|
|
let list = that.data.listData;
|
|
|
|
|
|
if (isBottom) {
|
|
|
list[index].page = page;
|
|
|
list[index].limitProductVoList = list[index].limitProductVoList.concat(res.data.limitProductVoList);
|
|
|
} else {
|
|
|
list[index] = res.data;
|
|
|
}
|
|
|
that.setData({
|
|
|
listData: list
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
navigateToDetail: function(e) { // 跳转到详情页
|
|
|
console.log(e);
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
let limitProductCode = e.currentTarget.dataset.code;
|
|
|
|
|
|
|
|
|
}
|
|
|
}); |
...
|
...
|
|