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.
 

241 lines
5.6 KiB

// pagesA/orderList/orderList.js
const app = getApp()
const WXAPI = require('../../utils/request')
import moment from '../../utils/moment'
var util = require('../../utils/util');
Page({
/**
* 页面的初始数据
*/
data: {
active:0,
orderLogList:[],
pageSize:10,
pageNum:1,
radio:'2',
leases:{},
show:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getOrderList()
},
onChange(event){
this.setData({
active:event.detail.name
})
if(event.detail.name=='0'){
this.getOrderList()
}else if(event.detail.name==1){
this.getOrderList()
}else if(event.detail.name==2){
this.getOrderList()
}
},
onClose() {
this.setData({ show: false });
},
confirmMethods(event) {
this.confimPay()
},
confimPay(){
let leases =this.data.leases
let userInfo = wx.getStorageSync('userInfo')
let productName = leases.orderType == '0'?'短信充值':leases.orderType == '1'?'交租':leases.orderType == '2'?'语音电话充值':leases.orderType == '3'?'系统续费':'未知'
var data = {
description: productName,
productName: productName,
total: parseInt(leases.totalFee)*100,//parseInt(this.data.leases.expand.rent)*100,
userId: leases.cardId,
cardId:leases.cardId,
openid:wx.getStorageSync('openid'),
appid:'wx885b65d99da00084',//'wx20de9fe5943934a1',//'wx885b65d99da00084',
uid:userInfo.id,
eid:userInfo.enterpriseId,
orderType:leases.orderType,
payType:this.data.radio,
expand:JSON.stringify({
phone:leases.phone,
nickname:leases.cardName
}),
relevanceId:leases.id
}
WXAPI.miniPrepayOrderT(data).then(res=>{
wx.requestPayment({
timeStamp: res.data.data.timeStamp,
appid: res.data.data.appId,
nonceStr: res.data.data.nonceStr,
package: res.data.data.package,
signType: res.data.data.signType,
totalFee: parseInt(leases.totalFee)*100,
paySign: res.data.data.paySign,
success (res1) {
wx.showToast({
title: "支付成功",
duration: 2000,
icon: 'success'
})
let dataOne={
code: "wx/updatePrepayStatus",
cardId:leases.cardId,
data: {
orderNo: res.data.data.orderNo,
status:0
}
}
WXAPI.sendCommand(dataOne).then(res2=>{
wx.showToast({
title: '支付成功',
duration:2000
})
})
},
fail (res1) {
wx.showToast({
title: "支付失败",
duration: 2000,
icon: 'none'
})
let dataOne={}
if(res1.errMsg == 'requestPayment:fail cancel'){
dataOne={
code: "wx/updatePrepayStatus",
data: {
orderNo: res.data.data.orderNo,
status:8
}
}
}else{
dataOne={
code: "wx/updatePrepayStatus",
cardId:leases.cardId,
data: {
orderNo: res.data.data.orderNo,
status:6
}
}
}
WXAPI.sendCommand(dataOne).then(res2=>{
})
}
})
// WXAPI.miniPrepayOrder(data).then(res=>{
// let dataOne={
// code: "wx/updatePrepayStatus",
// data: {
// orderNo: res.data.data.orderNo,
// status:0
// }
// }
// WXAPI.sendCommand(dataOne).then(res2=>{
// if(res2.success){
// wx.showToast({
// title: "支付成功",
// duration: 2000,
// icon: 'success'
// })
// }else{
// wx.showToast({
// title: res2.message,
// duration: 2000,
// icon: 'error'
// })
// }
// })
// })
})
},
onChangeRadio(event){
this.setData({
radio: event.detail,
});
},
rentMethods(e){
let leases = e.currentTarget.dataset.item
this.setData({
show:true,
leases
})
},
getOrderList(){
let data={
pageSize:this.data.pageSize,
pageNum:this.data.pageNum,
q:JSON.stringify({
orderStatus:this.data.active
})
}
WXAPI.getSiteOrder(data).then(res=>{
if(res.success){
res.data.list.map(li=>{
li.createTime = moment(li.createTime).format('YYYY-MM-DD HH:mm:ss')
li.waterFee = parseFloat(li.waterFee/100).toFixed(2)
li.electricityFee = parseFloat(li.electricityFee/100).toFixed(2)
})
this.setData({
orderLogList:res.data.list
})
}else{
wx.showToast({
title: res.message,
duration:200,
icon:'none'
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})