hedera-web/forms/ecomerce/orders/index.js

58 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-11-16 01:44:39 +00:00
import './style.scss';
2022-11-16 01:44:39 +00:00
export default new Class({
Extends: Hedera.Form,
2022-11-16 01:44:39 +00:00
Template: require('./ui.xml'),
2022-11-16 01:46:44 +00:00
activate() {
2022-05-30 01:30:33 +00:00
this.tpv = new Hedera.Tpv({
conn: this.conn,
hash: this.hash
});
2022-11-28 08:51:31 +00:00
const tpvStatus = this.tpv.check();
if (tpvStatus === 'ko') this.$.errorDialog.show();
},
2022-11-16 01:46:44 +00:00
onBasketClick() {
2022-05-30 01:30:33 +00:00
this.hash.setAll({form: 'ecomerce/basket'});
},
2015-12-02 17:26:58 +00:00
2022-11-16 01:46:44 +00:00
repeaterFunc(res, form) {
2022-05-28 01:18:06 +00:00
res.$.link.href = this.hash.make({
2017-12-14 14:33:48 +00:00
form: 'ecomerce/ticket',
2022-05-28 15:49:46 +00:00
ticket: form.$.id
});
},
// TPV
2022-11-28 08:51:31 +00:00
balanceConditionalFunc(_, value) {
if (value >= 0)
2022-05-28 01:18:06 +00:00
Vn.Node.removeClass(this.$.balance, 'negative');
else
2022-05-28 01:18:06 +00:00
Vn.Node.addClass(this.$.balance, 'negative');
},
2022-11-28 08:51:31 +00:00
async onPayButtonClick() {
2022-05-28 01:18:06 +00:00
var amount = -this.$.debt.value;
amount = amount <= 0 ? null : amount;
var defaultAmountStr = '';
2015-07-10 12:30:08 +00:00
if (amount !== null)
defaultAmountStr = Vn.Value.format(amount, '%.2d');
2017-12-01 14:38:23 +00:00
amount = prompt(_('AmountToPay:'), defaultAmountStr);
if (amount != null) {
amount = parseFloat(amount.replace(',', '.'));
2022-11-28 08:51:31 +00:00
await this.tpv.pay(amount, null);
2017-12-01 14:38:23 +00:00
}
},
2022-11-28 08:51:31 +00:00
async onDialogResponse(_, response) {
if (response == Htk.Dialog.Button.RETRY)
2022-11-28 08:51:31 +00:00
await this.tpv.retryPay();
}
});