|
|
|
var Api = require('../../../utils/common.js');
|
|
|
|
var re = require('../../../utils/request.js');
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
logo:'../../../images/logo.jpg',
|
|
|
|
navTab: ['全部', '待支付', '已成功','已超时','已取消','待审核', '未通过'],
|
|
|
|
currentTab: 0,
|
|
|
|
status: '',
|
|
|
|
orderlist: [],
|
|
|
|
page:1,
|
|
|
|
more:false,
|
|
|
|
nomore:true
|
|
|
|
},
|
|
|
|
todetail: function (e) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '../orderdetail/orderdetail?id='+e.currentTarget.dataset.id+''
|
|
|
|
})
|
|
|
|
},
|
|
|
|
timeFormat(d, format = 'yyyy-MM-dd HH:mm:ss'){
|
|
|
|
let fnumber = v => v > 10 ? `${v}` : ('0' + v);
|
|
|
|
let date = new Date(d);
|
|
|
|
let result = format.replace('yyyy', date.getFullYear());
|
|
|
|
result = result.replace('MM', fnumber(date.getMonth() + 1));
|
|
|
|
result = result.replace('dd', fnumber(date.getDate()));
|
|
|
|
result = result.replace('HH', fnumber(date.getHours()));
|
|
|
|
result = result.replace('mm', fnumber(date.getMinutes()));
|
|
|
|
result = result.replace('ss', fnumber(date.getSeconds()));
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
currentTab: function (e) {
|
|
|
|
var that = this;
|
|
|
|
if (that.data.currentTab == e.currentTarget.dataset.idx) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
that.setData({
|
|
|
|
currentTab: e.currentTarget.dataset.idx,
|
|
|
|
})
|
|
|
|
if (e.currentTarget.dataset.idx == 0) {
|
|
|
|
that.setData({
|
|
|
|
status: ''
|
|
|
|
})
|
|
|
|
} else if (e.currentTarget.dataset.idx == 1) {
|
|
|
|
that.setData({
|
|
|
|
status: 0
|
|
|
|
})
|
|
|
|
}else if (e.currentTarget.dataset.idx == 2) {
|
|
|
|
that.setData({
|
|
|
|
status: 1
|
|
|
|
})
|
|
|
|
} else if (e.currentTarget.dataset.idx == 3) {
|
|
|
|
that.setData({
|
|
|
|
status: 2
|
|
|
|
})
|
|
|
|
} else if (e.currentTarget.dataset.idx == 4) {
|
|
|
|
that.setData({
|
|
|
|
status: 3
|
|
|
|
})
|
|
|
|
} else if (e.currentTarget.dataset.idx == 5) {
|
|
|
|
that.setData({
|
|
|
|
status: 4
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
that.setData({
|
|
|
|
status: 5
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.getOrderList();
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
|
|
|
|
},
|
|
|
|
getOrderList: function () {
|
|
|
|
var that = this;
|
|
|
|
let postData = {
|
|
|
|
orderStatus:2,//that.data.status,
|
|
|
|
pageSize: 5,
|
|
|
|
pageNum: that.data.page
|
|
|
|
};
|
|
|
|
var header = {
|
|
|
|
token: wx.getStorageSync('token'),
|
|
|
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
|
|
};
|
|
|
|
re.request(Api.getOrderList(), postData, header).then((res) => {
|
|
|
|
let datas = res.data.rows;
|
|
|
|
that.setData({
|
|
|
|
orderlist:[]
|
|
|
|
})
|
|
|
|
if(datas.length!=0){
|
|
|
|
for(var i=0;i<datas.length;i++){
|
|
|
|
this.getactiveInfo(datas[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getactiveInfo:function(val){
|
|
|
|
var that = this;
|
|
|
|
const imgUrl = wx.getStorageSync('imgUrl')
|
|
|
|
var header = {
|
|
|
|
token:wx.getStorageSync('token'),
|
|
|
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
|
|
};
|
|
|
|
var pastData = {
|
|
|
|
activityId:val.activityId
|
|
|
|
}
|
|
|
|
re.request(Api.getactiveInfo(), pastData, header).then((res) => {
|
|
|
|
let datas = res.data.data;
|
|
|
|
let orderlist = that.data.orderlist;
|
|
|
|
if(datas.activityLogo){
|
|
|
|
datas.activityLogo = imgUrl + datas.activityLogo
|
|
|
|
}
|
|
|
|
datas.orderSerial = val.orderSerial;
|
|
|
|
datas.orderStatus = val.orderStatus;
|
|
|
|
datas.cost = val.cost;
|
|
|
|
datas.createdTime = val.createdTime;
|
|
|
|
datas.orderId = val.orderId;
|
|
|
|
// console.log('datas:', datas)
|
|
|
|
// orderlist.forEach(item => {
|
|
|
|
datas.startTime = that.timeFormat(datas.startTime, 'yyyy-MM-dd HH:mm');
|
|
|
|
datas.endTime = that.timeFormat(datas.endTime, 'yyyy-MM-dd HH:mm');
|
|
|
|
// });
|
|
|
|
|
|
|
|
orderlist = orderlist.concat([datas]);
|
|
|
|
// console.log('orderlist:', orderlist);
|
|
|
|
that.setData({
|
|
|
|
// array:array,
|
|
|
|
orderlist:orderlist
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getmore:function(){
|
|
|
|
var that = this;
|
|
|
|
var page = that.data.page;
|
|
|
|
page++;
|
|
|
|
var postData = {
|
|
|
|
orderStatus:that.data.status,
|
|
|
|
pageSize: 5,
|
|
|
|
pageNum: page
|
|
|
|
};
|
|
|
|
var header = {
|
|
|
|
token: wx.getStorageSync('token'),
|
|
|
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
|
|
};
|
|
|
|
re.request(Api.getOrderList(), postData, header).then((res) => {
|
|
|
|
let datas = res.data.rows;
|
|
|
|
if(datas.length>0){
|
|
|
|
for(var i=0;i<datas.length;i++){
|
|
|
|
this.getactiveInfos(datas[i])
|
|
|
|
}
|
|
|
|
that.setData({
|
|
|
|
page: page,
|
|
|
|
array:[]
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
that.setData({
|
|
|
|
orderlist:[],
|
|
|
|
more:true,
|
|
|
|
nomore:false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getactiveInfos:function(val){
|
|
|
|
var that = this;
|
|
|
|
const imgUrl = wx.getStorageSync('imgUrl')
|
|
|
|
var header = {
|
|
|
|
token:wx.getStorageSync('token'),
|
|
|
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
|
|
};
|
|
|
|
var pastData = {
|
|
|
|
activityId:val.activityId
|
|
|
|
}
|
|
|
|
re.request(Api.getactiveInfo(), pastData, header).then((res) => {
|
|
|
|
let datas = res.data.data;
|
|
|
|
var oldlist = that.data.orderlist;
|
|
|
|
if(datas.activityLogo){
|
|
|
|
datas.activityLogo = imgUrl + datas.activityLogo
|
|
|
|
}
|
|
|
|
datas.orderSerial = val.orderSerial;
|
|
|
|
datas.orderStatus = val.orderStatus;
|
|
|
|
datas.cost = val.cost;
|
|
|
|
datas.createdTime = val.createdTime;
|
|
|
|
datas.orderId = val.orderId;
|
|
|
|
oldlist = oldlist.concat(datas);
|
|
|
|
console.log('new',oldlist);
|
|
|
|
that.setData({
|
|
|
|
orderlist:oldlist
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
this.getOrderList();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|