小程序微信支付
一、图解二、代码
一、图解
二、代码
requestPayment
: function(obj
) {
const vm
= this;
console
.log(vm
.detailData
.orderMoney
);
uni
.requestPayment({
'provider': 'wxpay',
'timeStamp': obj
.timestamp
,
'nonceStr': obj
.nonce_str
,
'package': `prepay_id=${obj.prepay_id}`,
'signType': 'MD5',
'paySign': obj
.sign
,
'success':function(res
){
uni
.navigateTo({
url
: '/pages/order/paySuccess?params=' + vm
.detailData
.orderMoney
})
},
'fail':function(res
){
console
.log(111,res
);
},
'complete':function(res
){
console
.log(111,res
);
}
});
},
getDataSource1(id
) {
const vm
= this;
wx
.request({
url
: `${store.state.httpRequst.url}/wxpay/unified`,
method
: 'GET',
header
: {
'token': store
.state
.token
},
data
: {id
},
success
: function(data
) {
if (data
.data
.result_code
=== "FAIL") {
uni
.showModal({
title
: '生成订单失败',
content
: data
.data
.err_code_des
});
} else {
vm
.requestPayment(data
.data
);
}
}
});
},
转载请注明原文地址: https://lol.8miu.com/read-20118.html