You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

289 lines
6.3 KiB

2 years ago
//获取应用实例
var app = getApp();
var WXAPI = require('../../utils/server.js');
2 years ago
Page({
data: {
animation: {}, // 动画
animation_mask: {}, // 动画
showModalStatus: false, // modal是否需要渲染
currentIndex: 0,
navTab: [{'type':'全部','status':'','num':0},
{'type':'待付款','status':'payment','num':0},
{'type':'待发货','status':'send','num':0},
{'type':'待收货','status':'receipt','num':0},
{'type':'待评价','status':'evaluete','num':0}],
currentStatus: '',
listArray: [],
page: 1,
loading: false,
complete: false,
scrollTop: 0,
scrollHeight: 0,
2 years ago
sortingList: [{
key: 1,
value: "全部订单",
otype: 'pay'
},
{
key: 3,
value: "拼团",
otype: 'pay6'
}],
2 years ago
},
switchTab: function(e) {
var dataset = e.currentTarget.dataset
2 years ago
this.setData({
currentIndex: dataset.idx,
currentStatus: dataset.item.status,
scrollTop: 0,
page: 1,
loading: false,
complete: false
2 years ago
});
this.getOderList();
2 years ago
},
scroll: function (e) {
if (this.data.toView == "top") {
2 years ago
this.setData({
toView: ""
})
2 years ago
}
},
getOderList: function() {
//在当前页面显示导航条加载动画
wx.showNavigationBarLoading();
wx.showLoading({
title: '加载中...',
})
var that = this
WXAPI.orderList({
accessId: app.globalData.accessId,
storeId: 239,
storeType: 1,
queryOrderType: that.data.currentStatus,
page : that.data.page,
}).then(res => {
if (res.code == 200) {
var result = res.data.order || []
var list = (this.data.page == 1 ? [] : this.data.listArray).concat(result)
// var complete = (this.data.page >= res.data.page.pages)
var complete = (this.data.listArray.length >= res.data.order_num)
var loading = !complete
// console.log(res);
that.setData({
listArray: list,
loading: loading,
complete: complete,
})
//隐藏loading 提示框
wx.hideLoading();
// //隐藏导航条加载动画
wx.hideNavigationBarLoading();
//停止下拉刷新
wx.stopPullDownRefresh();
}
})
},
reloadData: function() {
this.setData({
page: 1
})
this.getOderList();
},
loadMoreData: function() {
if (this.data.loading && !this.data.complete) {
this.setData({
page: this.data.page + 1
})
this.getOderList();
}
},
//详情页跳转
lookDetail:function(e){
var goodsId = e.currentTarget.dataset.id;
wx.navigateTo({
url:"/pages/order/detail?id="+goodsId
})
},
toast: function(msg) {
wx.showToast({
title: msg,
icon: 'none',
duration: 2000
})
},
// 取消订单
removeOrder: function(e) {
var that = this;
var info = e.currentTarget.dataset.info
wx.showModal({
title: '提示',
content: '你确定要取消订单吗?',
success: function (res) {
WXAPI.removeOrder({
accessId: app.globalData.accessId,
storeId: 239,
storeType: 1,
order_id: info.id,
}).then(res => {
if (res.code == 200) {
that.reloadData();
}
})
2 years ago
}
});
},
//立即支付
payNow: function(e) {
var data = e.currentTarget.dataset.info
wx.navigateTo({
url: "/pages/order/payment?orderId="+data.sNo+"&price="+data.z_price,
})
},
//提醒发货
orderRemind: function(e) {
var that = this;
var info = e.currentTarget.dataset.info
WXAPI.orderRemind({
accessId: app.globalData.accessId,
storeId: 239,
storeType: 1,
order_id: info.id,
}).then(res => {
if (res.code == 200) {
that.reloadData();
}
})
2 years ago
},
// 确认收货
confirmOrder: function(e) {
2 years ago
var that = this;
var info = e.currentTarget.dataset.info
2 years ago
wx.showModal({
title: '提示',
content: '请确认你已收到货物',
2 years ago
success: function (res) {
WXAPI.confirmOrder({
accessId: app.globalData.accessId,
storeId: 239,
storeType: 1,
order_id: info.id,
}).then(res => {
if (res.code == 200) {
that.reloadData();
2 years ago
}
})
2 years ago
}
});
},
//删除订单
deleteOrder: function(e) {
2 years ago
var that = this;
var info = e.currentTarget.dataset.info
2 years ago
wx.showModal({
title: '提示',
content: '确定要删除订单吗',
2 years ago
success: function (res) {
WXAPI.deleteOrder({
accessId: app.globalData.accessId,
storeId: 239,
storeType: 1,
order_id: info.id,
}).then(res => {
if (res.code == 200) {
that.reloadData();
2 years ago
}
})
2 years ago
}
});
},
//查看物流
orderLogistics: function(e) {
var info = e.currentTarget.dataset.info
wx.navigateTo({
url:"/pages/logistics/logistics?orderId="+info.sNo
})
2 years ago
},
//去评价
evaluateOrder: function(e) {
2 years ago
var that = this;
var info = e.currentTarget.dataset.info
wx.navigateTo({
url:"/pages/comment/comment?id="+info.id
})
2 years ago
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
var that = this
that.setData({
currentIndex: options.index,
currentStatus: options.status
})
that.reloadData();
that.getWXTemplate()
},
getWXTemplate() {
WXAPI.getWXTemplate({
storeId: 239,
storeType: 1,
type: 2,
}).then(res => {
if (res.code == 200) {
var data = res.data
wx.setStorageSync('logmsgId', [data.template_id])
}
})
2 years ago
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
2 years ago
},
2 years ago
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.reloadData();
2 years ago
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
2 years ago
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
2 years ago
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
2 years ago
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
2 years ago
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
2 years ago
})