|
|
const app = getApp();
|
|
|
const Zan = require("../../../template/index.js");
|
|
|
const sliderWidth = 85; // 需要设置slider的宽度,用于计算中间位置
|
|
|
|
|
|
Page(Object.assign({}, Zan.Tab, {
|
|
|
name: "index",
|
|
|
/** 如果绑定事件 需要注册一个name属性 */
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
hideNoData: true, // 没有数据提示
|
|
|
selectedStatus: "",
|
|
|
tabs: [{
|
|
|
id: "",
|
|
|
name: "全部",
|
|
|
},
|
|
|
{
|
|
|
id: 2,
|
|
|
name: "已退款",
|
|
|
},
|
|
|
{
|
|
|
id: 3,
|
|
|
name: "已取消",
|
|
|
},
|
|
|
{
|
|
|
id: 5,
|
|
|
name: "已完成",
|
|
|
}
|
|
|
],
|
|
|
sliderOffset: 0,
|
|
|
sliderLeft: 0,
|
|
|
activeIndex: 0,
|
|
|
store: wx.getStorageSync("store"), //当前门店信息
|
|
|
list: [],
|
|
|
pageNumber: 1,
|
|
|
pageSize: 5,
|
|
|
tabIndex: 0
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function(options) {
|
|
|
var that = this;
|
|
|
wx.getSystemInfo({
|
|
|
success: function(res) {
|
|
|
that.setData({
|
|
|
sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
|
|
|
sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
wx.showLoading({
|
|
|
title: '加载订单...',
|
|
|
});
|
|
|
that.loadData();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 加载订单数据
|
|
|
*/
|
|
|
loadData: function() {
|
|
|
var that = this;
|
|
|
|
|
|
var params = {
|
|
|
"method": "wxdc.sales.order.list",
|
|
|
"memberId": app.userId,
|
|
|
"orderField": "saleDate", // 排序字段
|
|
|
"orderType": "DESC", // 排序方式(ASC,DESC)
|
|
|
"status": that.data.selectedStatus,
|
|
|
"startDate": "",
|
|
|
"endDate": "",
|
|
|
"pageNumber": that.data.pageNumber,
|
|
|
"pageSize": that.data.pageSize
|
|
|
}
|
|
|
// 不签名参数
|
|
|
var ignores = [];
|
|
|
ignores.push("pageNumber");
|
|
|
ignores.push("pageSize");
|
|
|
|
|
|
app.jsapi.api(app.globalData.appKey, app.globalData.appSecret, app.globalData.serverUrl).ajax(params, ignores,
|
|
|
function(json) {
|
|
|
wx.hideLoading();
|
|
|
wx.stopPullDownRefresh();
|
|
|
wx.hideNavigationBarLoading();
|
|
|
var result = json.data;
|
|
|
if (result.status == 1) {
|
|
|
var list = that.data.list;
|
|
|
list = list.concat(result.list);
|
|
|
var hideNoData = list.length > 0 ? true : false;
|
|
|
|
|
|
that.setData({
|
|
|
list: list,
|
|
|
hideNoData: hideNoData
|
|
|
});
|
|
|
} else {
|
|
|
app.msg.showMsg("提示", json.data.message);
|
|
|
}
|
|
|
},
|
|
|
function(error) {
|
|
|
app.msg.showMsg("提示", "网络中断,获取品类失败");
|
|
|
}
|
|
|
);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 查看订单详情
|
|
|
*/
|
|
|
bindGotoDetail: function(e) {
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
var list = this.data.list;
|
|
|
var order = list[index];
|
|
|
var orderId = order.ticketId;
|
|
|
var orderNo = order.ticketNo;
|
|
|
var storeId = order.storeId;
|
|
|
wx.navigateTo({
|
|
|
url: "../detail/detail?orderId=" + orderId + "&orderNo=" + orderNo + "&storeId=" + storeId,
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 门店列表
|
|
|
*/
|
|
|
goviewst: function() {
|
|
|
wx.switchTab({
|
|
|
url: '../../store/store'
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 状态筛选
|
|
|
*/
|
|
|
tabClick: function(e) {
|
|
|
this.setData({
|
|
|
sliderOffset: e.currentTarget.offsetLeft,
|
|
|
selectedStatus: e.currentTarget.id,
|
|
|
activeIndex: e.currentTarget.id,
|
|
|
pageNumber: 1,
|
|
|
pageCount: 1,
|
|
|
list: []
|
|
|
});
|
|
|
wx.showLoading({
|
|
|
title: '加载订单...',
|
|
|
});
|
|
|
|
|
|
this.loadData();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 监听页面下拉事件
|
|
|
*/
|
|
|
onPullDownRefresh: function() {
|
|
|
//在标题栏中显示加载
|
|
|
wx.showNavigationBarLoading()
|
|
|
|
|
|
wx.showLoading({
|
|
|
title: '加载订单...',
|
|
|
});
|
|
|
this.setData({
|
|
|
pageNumber: 1,
|
|
|
pageCount: 1,
|
|
|
list: []
|
|
|
});
|
|
|
this.loadData();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 监听页面上拉加载更多事件
|
|
|
*/
|
|
|
onReachBottom: function() {
|
|
|
var nextPageNumber = this.data.pageNumber + 1;
|
|
|
this.setData({
|
|
|
hide_bottom: false,
|
|
|
pageNumber: nextPageNumber
|
|
|
});
|
|
|
this.loadData();
|
|
|
}
|
|
|
|
|
|
})); |