2023-10-24 14:49:37 +00:00
|
|
|
{% put scripts %}
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
$('#loader_form').hide();
|
|
|
|
|
function registerFunc() {
|
|
|
|
|
|
|
|
|
|
var first_name = document.getElementsByName("first_name")[0].value;
|
|
|
|
|
var last_name = document.getElementsByName("last_name")[0].value;
|
|
|
|
|
var phone = document.getElementsByName("phone")[0].value;
|
|
|
|
|
var pass = document.getElementsByName("password")[0].value;
|
|
|
|
|
var deviceName = 'from Web Register';
|
|
|
|
|
|
|
|
|
|
var fd = new FormData();
|
|
|
|
|
fd.append('first_name', first_name);
|
|
|
|
|
fd.append('last_name', last_name);
|
|
|
|
|
fd.append('phone', phone);
|
|
|
|
|
fd.append('password', pass);
|
|
|
|
|
fd.append('device_name', deviceName);
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
2023-10-24 15:43:23 +00:00
|
|
|
url: 'http://216.250.11.229/app/api/customer/register',
|
2023-10-24 14:49:37 +00:00
|
|
|
data: fd,
|
|
|
|
|
processData: false,
|
|
|
|
|
contentType: false,
|
|
|
|
|
type: 'POST',
|
|
|
|
|
beforeSend: function () {
|
|
|
|
|
$('#loader_form').show();
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
$('#loader_form').hide();
|
|
|
|
|
console.log(data);
|
|
|
|
|
console.log(data.data.name);
|
|
|
|
|
console.log(data.token);
|
|
|
|
|
|
|
|
|
|
// onSetData(data.token, data.data.name, data.data.phone);
|
|
|
|
|
|
|
|
|
|
$('input[name=token]').val(data.token);
|
|
|
|
|
$('input[name=name]').val(data.data.name);
|
|
|
|
|
$('input[name=phone]').val(data.data.phone);
|
|
|
|
|
|
|
|
|
|
var link = document.querySelector('#testq');
|
|
|
|
|
if(link) {
|
|
|
|
|
link.click();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// $(document).on(function () {
|
|
|
|
|
// $(this).request('onSetSessionNurgul', { data: { token: 'someVar' } });
|
|
|
|
|
// });
|
|
|
|
|
// $(this).request('onSetSession', {
|
|
|
|
|
// data: { nurgulToken: data.token }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// $(this).request('onSetSession', {
|
|
|
|
|
// data: { nurgulToken: data.token, name: data.data.name, phone: data.data.phone }
|
|
|
|
|
// });
|
|
|
|
|
},
|
|
|
|
|
error: function (data) {
|
|
|
|
|
$('#loader_form').hide();
|
|
|
|
|
dataq = JSON.parse(data.responseText);
|
|
|
|
|
// console.log(dataq);
|
|
|
|
|
for (var error of dataq.errors) {
|
|
|
|
|
$('#errors').append(`<a href="#" style="padding-bottom: 15px;"><small style="color: darkred;font-weight: bold;background: #ff8888;padding: 10px;border-radius: 5px;"> * ` + error + `</small></a>`);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// console.log(dataq.errors);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{% endput %}
|