纸通宝SAAS仓库
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.
 

72 lines
2.3 KiB

// pages/process/payment/index.js
import Dialog from '../../../components/dialog/dialog'
import { getPeymentList, repeatOrder } from "../../../api/saas"
const event = require('../../../utils/event')
const util = require('../../../utils/util')
const math = require('../../../utils/math') //导入模块
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
safeBottom: app.globalData.safeBottom,
form: {
status: 4,
pageNum: 1,
pageSize: 100
},
amount: 0,
orderList: null
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.mobile){
this.data.form.mobile = options.mobile
}
wx.showLoading({ title: '正在获取', mask: true })
getPeymentList(this.data.form).then(result => {
wx.hideLoading()
var amount = 0
if (result.data && result.data.records.length) {
for (let index = 0; index < result.data.records.length; index++) {
amount = math.plus(amount, result.data.records[index].settlePrice)
}
this.setData({ safeBottom: app.globalData.safeBottom, orderList: result.data.records, amount })
} else {
this.setData({ safeBottom: app.globalData.safeBottom })
}
}).catch(err => {
wx.hideLoading()
this.setData({ safeBottom: app.globalData.safeBottom })
util.showToast(err)
})
},
lookItem: function(e){
var item = this.data.orderList[e.currentTarget.dataset.index]
item.checked = !item.checked
var amount = 0
for (let index = 0; index < this.data.orderList.length; index++) {
if(!this.data.orderList[index].checked){
amount = math.plus(amount, this.data.orderList[index].settlePrice)
}
}
this.setData({ ['orderList[' + e.currentTarget.dataset.index + '].checked']: item.checked, amount })
},
paymentOrder: function(){
Dialog.confirm({ title: '温馨提示', message: '确定要付款吗?' }).then(() => {
wx.showLoading({ title: '正在获取', mask: true })
repeatOrder(this.data.form.id).then(result => {
wx.hideLoading()
util.showBackToast('订单已经处理')
event.emit('OrderMessage', { what: 12, desc: 'cancelOrder' })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
})
}
})