我的水疗应用程序中有如下付款表格:
<form Method='post' Action='https://pep.shaparak.ir/gateway.aspx'>
invoiceNumber<input type='text' name='invoiceNumber' v-model='InvoiceNumber' />
invoiceDate<input type='text' name='invoiceDate' v-model='InvoiceDate' />
amount<input type='text' name='amount' v-model='Amount' />
terminalCode<input type='text' name='terminalCode' v-model='TerminalCode' />
merchantCode<input type='text' name='merchantCode' v-model='MerchantCode' />
redirectAddress<input type='text' name='redirectAddress' v-model='RedirectAddress' />
timeStamp<input type='text' name='timeStamp' v-model='TimeStamp' />
action<input type='text' name='action' v-model='Action' />
sign<input type='text' name='sign' v-model='Sign' />
<input type='submit' name='submit' value='Checkout' @click="Checkout()" />
</form>
和
Checkout: function(){
axios.get('./api/pasargad').then(response => {
var vm = this;
vm.InvoiceNumber = response.data.InvoiceNumber;
vm.InvoiceDate = response.data.InvoiceDate;
vm.Amount = response.data.Amount;
vm.TerminalCode = response.data.TerminalCode;
vm.MerchantCode = response.data.MerchantCode;
vm.RedirectAddress = response.data.RedirectAddress;
vm.TimeStamp = response.data.TimeStamp;
vm.Action = response.data.Action;
vm.Sign = response.data.Sign;
}.bind(vm));
});
},
当我单击Checkout()函数时,我需要运行以下步骤:
但是在此示例中,首先将重定向到具有未知数据的网关!!!
答案 0 :(得分:0)
首先,应防止默认提交表单,然后在函数内添加另一个Axios调用。
<form v-on:submit.prevent>
和checkout
应该看起来像这样,
Checkout: function(){
var vm = this;
axios.get('./api/pasargad').then(response => {
vm.InvoiceNumber = response.data.InvoiceNumber;
vm.InvoiceDate = response.data.InvoiceDate;
vm.Amount = response.data.Amount;
vm.TerminalCode = response.data.TerminalCode;
vm.MerchantCode = response.data.MerchantCode;
vm.RedirectAddress = response.data.RedirectAddress;
vm.TimeStamp = response.data.TimeStamp;
vm.Action = response.data.Action;
vm.Sign = response.data.Sign;
}.bind(vm));
});
axios.post('https://pep.shaparak.ir/gateway.aspx',vm)
},