289 lines
9.2 KiB
JavaScript
Raw Normal View History

2019-11-16 10:21:14 +03:00
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./../../bootstrap');
import Vue from 'vue';
2020-01-03 12:10:07 +03:00
import DashboardPlugin from './../../plugins/dashboard-plugin';
2022-06-01 10:15:55 +03:00
import BulkAction from './../../plugins/bulk-action';
2020-01-03 12:10:07 +03:00
2019-11-16 10:21:14 +03:00
import Global from './../../mixins/global';
import Form from './../../plugins/form';
import CardForm from './../../components/CreditCard/CardForm';
2022-06-01 10:15:55 +03:00
import Swiper, { Navigation, Pagination } from 'swiper';
Swiper.use([Navigation, Pagination]);
2020-01-03 12:10:07 +03:00
// plugin setup
Vue.use(DashboardPlugin);
2019-11-16 10:21:14 +03:00
const app = new Vue({
el: '#app',
mixins: [
Global
],
components: {
CardForm
},
2022-06-01 10:15:55 +03:00
data: function() {
2019-11-16 10:21:14 +03:00
return {
2022-06-01 10:15:55 +03:00
form: new Form('portal'),
bulk_action: new BulkAction('portal'),
// for profile
show_password: false,
// for payments
connect: {
show: false,
currency: {},
documents: [],
},
// for invoices
2019-11-16 10:21:14 +03:00
redirectForm: new Form('redirect-form'),
method_show_html: '',
formData: {
cardName: '',
cardNumber: '',
cardMonth: '',
cardYear: '',
2021-01-17 17:26:57 +03:00
cardCvv: '',
storeCard: false,
2021-01-17 23:55:27 +03:00
card_id: 0,
2022-06-01 10:15:55 +03:00
},
2019-11-16 10:21:14 +03:00
}
},
2022-06-01 10:15:55 +03:00
mounted() {
if (typeof this.form.password !== 'undefined') {
this.form.password = '';
}
new Swiper(".swiper-links", {
loop: false,
2022-11-02 11:29:15 +03:00
slidesPerView: 3,
2022-06-01 10:15:55 +03:00
pagination: {
el: ".swiper-pagination",
clickable: true
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});
},
methods: {
// for profile
onChangePassword(event) {
if (this.show_password == false) {
event.target.closest('.grid-rows-4').classList.replace('grid-rows-4', 'grid-rows-5');
event.target.closest('.grid-rows-5').nextElementSibling.classList.replace('grid-rows-4', 'grid-rows-5');
this.show_password = true;
} else {
event.target.closest('.grid-rows-5').classList.replace('grid-rows-5', 'grid-rows-4');
event.target.closest('.grid-rows-4').nextElementSibling.classList.replace('grid-rows-5', 'grid-rows-4');
this.show_password = false;
}
},
// for payments
onConnect(transaction, currency, documents) {
this.connect.show = true;
this.connect.transaction = transaction;
this.connect.currency = {
decimal_mark: currency.decimal_mark,
precision: currency.precision,
symbol: currency.symbol,
symbol_first: currency.symbol_first,
thousands_separator: currency.thousands_separator,
};
this.connect.documents = documents;
},
// for invoices
onChangePaymentMethod(payment_method) {
2022-06-01 10:15:55 +03:00
if (! payment_method) {
return;
}
let method = payment_method.split('.');
2019-11-16 10:21:14 +03:00
2021-04-17 01:29:18 +03:00
let path = url + '/portal/' + method[0] + '/invoices/' + this.form.document_id;
2019-11-16 10:21:14 +03:00
2020-12-24 01:28:38 +03:00
this.method_show_html = Vue.component('payment-method-confirm', function (resolve, reject) {
resolve({
2022-06-01 10:15:55 +03:00
template:'<div id="loading" class="description text-center"><i class="submit-spin absolute w-2 h-2 rounded-full left-0 right-0 -top-3.5 m-auto"></i></div>'
2020-12-24 01:28:38 +03:00
})
});
2019-11-16 10:21:14 +03:00
2020-12-24 01:28:38 +03:00
axios.get(path, {
params: {
payment_method: payment_method
}
})
2019-11-16 10:21:14 +03:00
.then(response => {
this.method_show_html = '';
if (response.data.redirect) {
location = response.data.redirect;
}
if (response.data.html) {
this.method_show_html = Vue.component('payment-method-confirm', function (resolve, reject) {
resolve({
template: '<div>' + response.data.html + '</div>',
2022-11-28 14:38:20 +03:00
mixins: [
Global
],
components: {
CardForm
},
2021-01-12 23:45:32 +03:00
created: function() {
this.form = new Form('redirect-form');
2021-01-12 23:45:32 +03:00
},
data: function () {
return {
2021-01-12 23:45:32 +03:00
form: {},
formData: {
cardName: '',
cardNumber: '',
cardMonth: '',
cardYear: '',
2021-01-17 17:26:57 +03:00
cardCvv: '',
storeCard: false,
2021-01-17 23:55:27 +03:00
card_id: 0,
}
}
},
2019-11-16 10:21:14 +03:00
methods: {
onRedirectConfirm() {
let redirect_form = new Form('redirect-form');
this.$emit('interface', redirect_form);
}
}
})
});
}
})
.catch(error => {
this.method_show_html = error.message;
});
},
onRedirectConfirm() {
this.redirectForm = new Form('redirect-form');
axios.post(this.redirectForm.action, this.redirectForm.data())
.then(response => {
if (response.data.redirect) {
location = response.data.redirect;
}
if (response.data.success) {
location.reload();
}
})
.catch(error => {
this.method_show_html = error.message;
});
},
onChangePaymentMethodSigned(payment_method) {
2022-06-01 10:15:55 +03:00
if (! payment_method) {
return;
}
this.form.payment_action = payment_method;
2019-11-16 10:21:14 +03:00
2021-01-14 12:30:02 +03:00
let method = payment_method.split('.');
let payment_action = payment_action_path[method[0]];
2019-11-16 10:21:14 +03:00
2020-12-24 01:28:38 +03:00
this.method_show_html = Vue.component('payment-method-confirm', function (resolve, reject) {
resolve({
2022-06-01 10:15:55 +03:00
template:'<div id="loading" class="description text-center"><i class="submit-spin absolute w-2 h-2 rounded-full left-0 right-0 -top-3.5 m-auto"></i></div>'
2020-12-24 01:28:38 +03:00
})
});
2021-01-14 12:30:02 +03:00
axios.get(payment_action, {
params: {
payment_method: payment_method
}
})
2019-11-16 10:21:14 +03:00
.then(response => {
this.method_show_html = '';
if (response.data.redirect) {
location = response.data.redirect;
}
if (response.data.html) {
this.method_show_html = Vue.component('payment-method-confirm', function (resolve, reject) {
resolve({
template: '<div>' + response.data.html + '</div>',
2022-11-28 14:38:20 +03:00
mixins: [
Global
],
components: {
CardForm
},
2021-01-12 23:45:32 +03:00
created: function() {
this.form = new Form('redirect-form');
2021-01-12 23:45:32 +03:00
},
data: function () {
return {
2021-01-12 23:45:32 +03:00
form: {},
formData: {
cardName: '',
cardNumber: '',
cardMonth: '',
cardYear: '',
2021-01-17 17:26:57 +03:00
cardCvv: '',
storeCard: false,
2021-01-17 23:55:27 +03:00
card_id: 0,
}
}
},
2019-11-16 10:21:14 +03:00
methods: {
onRedirectConfirm() {
let redirect_form = new Form('redirect-form');
this.$emit('interface', redirect_form);
}
}
})
});
}
})
.catch(error => {
this.method_show_html = error.message;
});
},
2022-06-01 10:15:55 +03:00
},
2019-11-16 10:21:14 +03:00
});