这是alipay里面的
export default{
name:'alipay',
components:{
Loading
},
data(){
return{
orderId:this.$route.query.orderId,
content:'',
loading:true,
payMoney:0
}
},
mounted () {
this.paySubmit();
this.getOrderDetail()
},
methods:{
getOrderDetail(){
this.axios.get(`/orders/${this.orderId}`).then((res)=>{
this.payMoney=res.payment;
alert(this.payMoney)
})
},
paySubmit(){
this.axios.post('/pay',{
orderId:this.orderId,
orderName:'Vue高仿小米商城',
amount:this.payMoney,//单位元
payType:1 //1支付宝,2微信
}).then((res)=>{
this.content = res.content;
setTimeout(()=>{
document.forms[0].submit() //submit() 方法把表单数据提交到 Web 服务器,因为用的返回的是表单字符串,所以用submit()方法
},100)
})
}
}
}
但是我用微信那边把价格写了却成功了,一样的写法在这里输入代码
paySubmit(payType){
// let allMsoney=this. payMoney;
if(payType == 1){
window.open('/#/order/alipay?orderId='+this.orderId,'_blank');
}else{
this.axios.post('/pay',{
orderId:this.orderId,
orderName:'Vue高仿小米商城',
amount:this. payMoney,//单位元
payType:2//1支付宝,2微信
}).then((res)=>{
QRCode.toDataURL(res.content)
.then(url => {
this.showPay = true;
this.payImg = url;
this.loopOrderState()
})
.catch(() => {
this.$message.error('微信二维码生成失败,请稍后重试');
})
})
}
}