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.
 

238 lines
5.0 KiB

var Api = require('../../../utils/common.js');
var re = require('../../../utils/request.js');
Page({
/**
* 页面的初始数据
*/
data: {
groups:[
{name:'洒洒水',tel:'13222222222',price:'200'},
{name:'洒洒水',tel:'13222222222',price:'200'},
],
allTotal:400,
trueTotal:400,
checked:true,
id:'',
payType:'1',
orderId:'',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this;
console.log(options)
that.setData({
id:options.id
})
that.getOrderPeople(options.id);
// that.getOrderDetail(options.id);
},
backChange:function(e){
var that = this;
that.setData({
payType:e.detail.value
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
getOrderPeople:function(id){
var that = this;
var postData = {
orderSerial:that.data.id,
};
var header = {
token: wx.getStorageSync('token'),
"Content-Type": "application/x-www-form-urlencoded"
};
re.request(Api.getOrderPeople(), postData, header).then((res) => {
console.log(res)
that.setData({
orderId:res.data.data[0].orderId
})
this.getOrderDetail(res.data.data[0].orderId)
})
},
getOrderDetail:function(id){
var that = this;
var postData = {
orderId:id,
};
var header = {
token: wx.getStorageSync('token'),
"Content-Type": "application/x-www-form-urlencoded"
};
re.request(Api.getOrderDetail(), postData, header).then((res) => {
console.log(">>>",res)
// this.setData({
// allTotal:res.data.
// })
})
},
topay:function(){
var that = this;
if(that.data.payType=='1'){
that.getwxpay()
}else if(that.data.payType=='3'){
that.walletpay();
}else{
that.getelsepay()
}
},
getwxpay:function(id){
var that = this;
let openId = wx.getStorageSync('openid')
var postData = {
orderSerial :that.data.id,
openId:openId,
realCost:'0.01',
body:'备注',
cost:'0.01',
payWay:that.data.payType,
subject:'我的订单'
};
var header = {
token: wx.getStorageSync('token'),
"Content-Type": "application/x-www-form-urlencoded"
};
re.request(Api.getwxpay(), postData, header).then((res) => {
console.log(res.data.data)
wx.requestPayment(
{
'timeStamp': res.data.data.timeStamp.toString(),
'nonceStr': res.data.data.nonceStr,
'package': res.data.data.package,
'signType': 'MD5',
'paySign': res.data.data.sign,
'success':function(res){
that.payokBack();
wx.navigateTo({
url: '../payOK/payok',
})
},
'fail':function(res){
console.log(res)
wx.showToast({
title: res.errMsg,
icon: 'none',
duration: 1000
})
},
})
})
},
getelsepay:function(){
var that = this;
let openId = wx.getStorageSync('openid')
var postData = {
orderSerial :that.data.id,
openId:openId,
realCost:'0.01',
body:'备注',
cost:'0.01',
payWay:that.data.payType,
subject:'我的订单'
};
var header = {
token: wx.getStorageSync('token'),
"Content-Type": "application/x-www-form-urlencoded"
};
re.request(Api.getwxpay(), postData, header).then((res) => {
that.payokBack();
wx.navigateTo({
url: '../payOK/payok',
})
})
},
payokBack:function(){
var that = this;
var postData = {
orderSerial:that.data.id,
orderStatus:'1'
};
var header = {
token: wx.getStorageSync('token'),
"Content-Type": "application/x-www-form-urlencoded"
};
re.request(Api.payokBack(), postData, header).then((res) => {
console.log(res)
})
},
walletpay:function(){
var that = this;
let openId = wx.getStorageSync('openid')
var postData = {
orderSerial :that.data.id,
openId:openId,
couponId:'',
realCost:'0.01',
body:'备注',
cost:'0.01',
realCost:'0.01',
subject:'我的订单'
};
var header = {
token: wx.getStorageSync('token'),
"Content-Type": "application/x-www-form-urlencoded"
};
re.request(Api.walletpay(), postData, header).then((res) => {
that.payokBack();
wx.navigateTo({
url: '../payOK/payok',
})
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})