146 lines
4.0 KiB
JavaScript
146 lines
4.0 KiB
JavaScript
// pages/activityOrder/activityOrder.js
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
stateType : '', //状态
|
|
counts : '', //数量
|
|
orderArr : [], //列表
|
|
page : {}, //下一页
|
|
lodingStats : false //加载状态
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad (options) {
|
|
|
|
// 获取商品活动订单
|
|
this.orderInfo();
|
|
},
|
|
|
|
/**
|
|
* 商品活动订单
|
|
*/
|
|
orderInfo(page) {
|
|
wx.$api.index.activityOrder(this.data.stateType, page).then(res=>{
|
|
let listArr = this.data.orderArr,
|
|
newData = []
|
|
if(page == 1 || page == undefined) listArr = []
|
|
|
|
newData = listArr.concat(res.data.data)
|
|
this.setData({
|
|
counts : res.data.count,
|
|
orderArr : newData,
|
|
page : res.data.page,
|
|
lodingStats : false
|
|
})
|
|
wx.stopPullDownRefresh()
|
|
}).catch(err => {});
|
|
},
|
|
|
|
/**
|
|
* tabs
|
|
*/
|
|
orderTab(e){
|
|
if(this.data.stateType != e.currentTarget.dataset.state){
|
|
this.setData({
|
|
stateType: e.currentTarget.dataset.state
|
|
})
|
|
|
|
// 获取商品活动订单
|
|
this.orderInfo()
|
|
|
|
wx.pageScrollTo({
|
|
scrollTop: 0
|
|
})
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 取消订单
|
|
*/
|
|
orderDelete(e) {
|
|
let orderId = e.currentTarget.dataset.id
|
|
wx.showModal({
|
|
title : '订单取消',
|
|
content : '确认取消吗?',
|
|
success : res=> {
|
|
if (res.confirm) {
|
|
wx.$api.index.cance(orderId).then(res=>{
|
|
// 获取商品活动订单
|
|
this.orderInfo()
|
|
|
|
wx.showToast({
|
|
title: res.data,
|
|
icon : 'none'
|
|
})
|
|
}).catch(err => {});
|
|
} else if (res.cancel) {
|
|
wx.showToast({
|
|
title : '取消',
|
|
icon : 'loading',
|
|
duration: 1000
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 订单支付
|
|
*/
|
|
orderPay(e) {
|
|
let orderId = e.currentTarget.dataset.id
|
|
|
|
wx.login({
|
|
success: res=> {
|
|
wx.$api.index.repay(orderId).then(res=>{
|
|
let payInfo = JSON.parse(res.data.json)
|
|
wx.requestPayment({
|
|
timeStamp: payInfo.timeStamp,
|
|
nonceStr : payInfo.nonceStr,
|
|
package : payInfo.package,
|
|
paySign : payInfo.paySign,
|
|
signType : payInfo.signType,
|
|
success : res=>{
|
|
if(res.errMsg == "requestPayment:ok"){
|
|
wx.showToast({
|
|
title: '支付成功',
|
|
icon : 'success'
|
|
})
|
|
setTimeout(()=>{
|
|
wx.redirectTo({
|
|
url: '/pages/activityOrder/activityOrder',
|
|
})
|
|
},2000)
|
|
}
|
|
},
|
|
fail : res=>{
|
|
wx.redirectTo({
|
|
url: '/pages/activityOrder/activityOrder',
|
|
})
|
|
}
|
|
})
|
|
}).catch(err => {});
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 上拉加载
|
|
*/
|
|
onReachBottom(){
|
|
this.setData({
|
|
lodingStats: true
|
|
})
|
|
let pageNumber = this.data.page.current
|
|
if(this.data.page.has_more){
|
|
pageNumber++
|
|
this.orderInfo(pageNumber)
|
|
}
|
|
}
|
|
|
|
}) |