|
|
@ -1,6 +1,6 @@ |
|
|
// pages/process/payment/index.js
|
|
|
// pages/process/payment/index.js
|
|
|
import Dialog from '../../../components/dialog/dialog' |
|
|
import Dialog from '../../../components/dialog/dialog' |
|
|
import { getPeymentList, repeatOrder } from "../../../api/saas" |
|
|
|
|
|
|
|
|
import { getPeymentList, paymentOrder } from "../../../api/saas" |
|
|
const event = require('../../../utils/event') |
|
|
const event = require('../../../utils/event') |
|
|
const util = require('../../../utils/util') |
|
|
const util = require('../../../utils/util') |
|
|
const math = require('../../../utils/math') //导入模块
|
|
|
const math = require('../../../utils/math') //导入模块
|
|
|
@ -18,7 +18,12 @@ Page({ |
|
|
pageSize: 100 |
|
|
pageSize: 100 |
|
|
}, |
|
|
}, |
|
|
amount: 0, |
|
|
amount: 0, |
|
|
orderList: null |
|
|
|
|
|
|
|
|
orderList: null, |
|
|
|
|
|
params: { |
|
|
|
|
|
ids: [], |
|
|
|
|
|
payRemark: '' |
|
|
|
|
|
}, |
|
|
|
|
|
requesting: false |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面加载 |
|
|
* 生命周期函数--监听页面加载 |
|
|
@ -31,9 +36,11 @@ Page({ |
|
|
getPeymentList(this.data.form).then(result => { |
|
|
getPeymentList(this.data.form).then(result => { |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
var amount = 0 |
|
|
var amount = 0 |
|
|
|
|
|
this.data.params.ids = [] |
|
|
if (result.data && result.data.records.length) { |
|
|
if (result.data && result.data.records.length) { |
|
|
for (let index = 0; index < result.data.records.length; index++) { |
|
|
for (let index = 0; index < result.data.records.length; index++) { |
|
|
amount = math.plus(amount, result.data.records[index].settlePrice) |
|
|
amount = math.plus(amount, result.data.records[index].settlePrice) |
|
|
|
|
|
this.data.params.ids.push(result.data.records[index].id) |
|
|
} |
|
|
} |
|
|
this.setData({ safeBottom: app.globalData.safeBottom, orderList: result.data.records, amount }) |
|
|
this.setData({ safeBottom: app.globalData.safeBottom, orderList: result.data.records, amount }) |
|
|
} else { |
|
|
} else { |
|
|
@ -49,24 +56,39 @@ Page({ |
|
|
var item = this.data.orderList[e.currentTarget.dataset.index] |
|
|
var item = this.data.orderList[e.currentTarget.dataset.index] |
|
|
item.checked = !item.checked |
|
|
item.checked = !item.checked |
|
|
var amount = 0 |
|
|
var amount = 0 |
|
|
|
|
|
this.data.params.ids = [] |
|
|
for (let index = 0; index < this.data.orderList.length; index++) { |
|
|
for (let index = 0; index < this.data.orderList.length; index++) { |
|
|
if(!this.data.orderList[index].checked){ |
|
|
if(!this.data.orderList[index].checked){ |
|
|
amount = math.plus(amount, this.data.orderList[index].settlePrice) |
|
|
amount = math.plus(amount, this.data.orderList[index].settlePrice) |
|
|
|
|
|
this.data.params.ids.push(this.data.orderList[index].id) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
this.setData({ ['orderList[' + e.currentTarget.dataset.index + '].checked']: item.checked, amount }) |
|
|
this.setData({ ['orderList[' + e.currentTarget.dataset.index + '].checked']: item.checked, amount }) |
|
|
}, |
|
|
}, |
|
|
|
|
|
bindInput: function (e) { |
|
|
|
|
|
this.data.params[e.target.id] = e.detail.value |
|
|
|
|
|
}, |
|
|
paymentOrder: function(){ |
|
|
paymentOrder: function(){ |
|
|
|
|
|
if(this.data.requesting){ |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if(this.data.params.ids.length <= 0){ |
|
|
|
|
|
util.showToast('请选择要付款的订单') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
Dialog.confirm({ title: '温馨提示', message: '确定要付款吗?' }).then(() => { |
|
|
Dialog.confirm({ title: '温馨提示', message: '确定要付款吗?' }).then(() => { |
|
|
wx.showLoading({ title: '正在获取', mask: true }) |
|
|
wx.showLoading({ title: '正在获取', mask: true }) |
|
|
repeatOrder(this.data.form.id).then(result => { |
|
|
|
|
|
|
|
|
this.data.requesting = true |
|
|
|
|
|
paymentOrder(this.data.params).then(result => { |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
util.showBackToast('订单已经处理') |
|
|
|
|
|
|
|
|
util.showBackToast('订单已经付款') |
|
|
event.emit('OrderMessage', { what: 12, desc: 'cancelOrder' }) |
|
|
event.emit('OrderMessage', { what: 12, desc: 'cancelOrder' }) |
|
|
}).catch(err => { |
|
|
}).catch(err => { |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
|
|
|
this.data.requesting = false |
|
|
util.showToast(err) |
|
|
util.showToast(err) |
|
|
}) |
|
|
}) |
|
|
|
|
|
}).catch(err => { |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |