[更新]
This commit is contained in:
187
pages/order/order.js
Normal file
187
pages/order/order.js
Normal file
@@ -0,0 +1,187 @@
|
||||
// pages/activityOrder/activityOrder.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
stateType : 'all', //状态
|
||||
counts : '', //数量
|
||||
orderArr : [], //列表
|
||||
page : {}, //下一页
|
||||
lodingStats : false, //加载状态
|
||||
pay : {
|
||||
payTips : 1, //支付方式
|
||||
payState : false, //支付状态
|
||||
orderId : '', //支付订单
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad (options) {
|
||||
this.setData({
|
||||
stateType: options.stateType
|
||||
})
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 获取商品活动订单
|
||||
this.orderInfo();
|
||||
},
|
||||
|
||||
/**
|
||||
* 商品活动订单
|
||||
*/
|
||||
orderInfo(page) {
|
||||
wx.$api.exchange.index(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()
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.exchange.cancel(orderId).then(res=>{
|
||||
// 获取商品活动订单
|
||||
this.orderInfo()
|
||||
|
||||
wx.showToast({
|
||||
title: res.data,
|
||||
icon : 'none'
|
||||
})
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
wx.showToast({
|
||||
title : '取消',
|
||||
icon : 'loading',
|
||||
duration: 1000
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 支付提交
|
||||
*/
|
||||
orderPay() {
|
||||
wx.$api.exchange.payments(this.data.pay.orderId).then(res=>{
|
||||
// payTips为1的时候为微信支付
|
||||
if(this.data.pay.payTips == 1) {
|
||||
wx.$api.index.wechat(res.data.trade_no).then(res=>{
|
||||
let payInfo = JSON.parse(res.data)
|
||||
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.reLaunch({
|
||||
url: '/pages/coupon/coupon?type=couponPublic'
|
||||
})
|
||||
},2000)
|
||||
}
|
||||
},
|
||||
fail : res=>{
|
||||
wx.redirectTo({
|
||||
url: '/pages/order/order?stateType=unpay'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
// payTips为2的时候为沃钱包支付
|
||||
if(this.data.pay.payTips == 2) {
|
||||
const newUrl = "https://lifetest.ysd-bs.com/unicom/payment?trade_no=" + res.data.trade_no
|
||||
let url= encodeURIComponent(newUrl)
|
||||
wx.navigateTo({
|
||||
// 跳转到webview页面
|
||||
url: `/pages/webView/webView?url=${url}`
|
||||
});
|
||||
}
|
||||
|
||||
this.setData({
|
||||
['pay.payState']: false
|
||||
})
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 支付选择弹出
|
||||
*/
|
||||
submitPay(e) {
|
||||
this.setData({
|
||||
['pay.payState']: !this.data.pay.payState,
|
||||
['pay.orderId'] : e.currentTarget.dataset.id
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 上拉加载
|
||||
*/
|
||||
onReachBottom(){
|
||||
this.setData({
|
||||
lodingStats: true
|
||||
})
|
||||
let pageNumber = this.data.page.current
|
||||
if(this.data.page.has_more){
|
||||
pageNumber++
|
||||
this.orderInfo(pageNumber)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 选择支付方式
|
||||
*/
|
||||
radioChange(e) {
|
||||
this.setData({
|
||||
['pay.payTips']: e.detail.value
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user