Merge pull request #1758 from jitendra-webkul/jitendra
Issue #1746, #1271, #1735 fixed
This commit is contained in:
commit
d474a26b8e
|
|
@ -357,8 +357,7 @@ class OnepageController extends Controller
|
|||
public function loginForCheckout()
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required'
|
||||
'email' => 'required|email'
|
||||
]);
|
||||
|
||||
if (! auth()->guard('customer')->attempt(request(['email', 'password']))) {
|
||||
|
|
|
|||
|
|
@ -164,7 +164,9 @@
|
|||
|
||||
summeryComponentKey: 0,
|
||||
|
||||
reviewComponentKey: 0
|
||||
reviewComponentKey: 0,
|
||||
|
||||
is_customer_exist: 0
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -229,6 +231,44 @@
|
|||
});
|
||||
},
|
||||
|
||||
isCustomerExist: function() {
|
||||
this.$validator.attach('email', 'required|email');
|
||||
|
||||
var this_this = this;
|
||||
|
||||
this.$validator.validate('email', this.address.billing.email)
|
||||
.then(function(isValid) {
|
||||
if (! isValid)
|
||||
return;
|
||||
|
||||
this_this.$http.post("{{ route('customer.checkout.exist') }}", {email: this_this.address.billing.email})
|
||||
.then(function(response) {
|
||||
this_this.is_customer_exist = response.data ? 1 : 0;
|
||||
})
|
||||
.catch(function (error) {})
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
loginCustomer: function() {
|
||||
var this_this = this;
|
||||
|
||||
this_this.$http.post("{{ route('customer.checkout.login') }}", {
|
||||
email: this_this.address.billing.email,
|
||||
password: this_this.address.billing.password
|
||||
})
|
||||
.then(function(response) {
|
||||
if (response.data.success) {
|
||||
window.location.href = "{{ route('shop.checkout.onepage.index') }}";
|
||||
} else {
|
||||
window.flashMessages = [{'type': 'alert-error', 'message': response.data.error }];
|
||||
|
||||
this_this.$root.addFlashMessages()
|
||||
}
|
||||
})
|
||||
.catch(function (error) {})
|
||||
},
|
||||
|
||||
getOrderSummary () {
|
||||
var this_this = this;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,23 @@
|
|||
<div class="control-group" id="password" :class="[errors.has('address-form.password') ? 'has-error' : '']">
|
||||
<label for="password" class="required">
|
||||
{{ __('shop::app.checkout.onepage.password') }}
|
||||
</label>
|
||||
<div v-if="is_customer_exist">
|
||||
<div class="control-group" id="password">
|
||||
<label for="password">{{ __('shop::app.checkout.onepage.password') }}</label>
|
||||
|
||||
<input type="password" v-validate="'required|min:6'" class="control" id="password" name="password" v-model="address.billing.password" data-vv-as=""{{ __('shop::app.checkout.onepage.password') }}""/>
|
||||
<input type="password" class="control" id="password" name="password" v-model="address.billing.password"/>
|
||||
</div>
|
||||
|
||||
<span class="control-error" v-if="errors.has('address-form.password')">
|
||||
@{{ errors.first('address-form.password') }}
|
||||
</span> <br>
|
||||
<span>{{ __('shop::app.checkout.onepage.login-exist-message') }}</span>
|
||||
</div>
|
||||
<div class="control-group" id="login-and-forgot-btn">
|
||||
<div class="forgot-password-link" style="float: right;margin-right: 503px; margin-top: 11px;">
|
||||
<a href="{{ route('customer.forgot-password.create') }}">{{ __('shop::app.customer.login-form.forgot_pass') }}</a>
|
||||
|
||||
|
||||
<div class="control-group" id="login-and-forgot-btn">
|
||||
<div class="forgot-password-link" style="float: right;margin-right: 503px; margin-top: 11px;">
|
||||
<a href="{{ route('customer.forgot-password.create') }}">{{ __('shop::app.customer.login-form.forgot_pass') }}</a>
|
||||
<div class="mt-10">
|
||||
@if (Cookie::has('enable-resend'))
|
||||
@if (Cookie::get('enable-resend') == true)
|
||||
<div class="mt-10">
|
||||
@if (Cookie::has('enable-resend') && Cookie::get('enable-resend') == true)
|
||||
<a href="{{ route('customer.resend.verification-email', Cookie::get('email-for-resend')) }}">{{ __('shop::app.customer.login-form.resend-verification') }}</a>
|
||||
@endif
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type='button' id="" class="btn btn-primary btn-lg btn-login" @click="loginCustomer">
|
||||
{{ __('shop::app.customer.login-form.button_title') }}
|
||||
</button>
|
||||
</div>
|
||||
<input type='button' id="" class="btn btn-primary btn-lg btn-login" value="{{ __('shop::app.customer.login-form.button_title') }}" />
|
||||
</div>
|
||||
|
|
@ -81,7 +81,7 @@
|
|||
{{ __('shop::app.checkout.onepage.email') }}
|
||||
</label>
|
||||
|
||||
<input type="text" v-validate="'required|email'" class="control" id="billing[email]" name="billing[email]" v-model="address.billing.email" data-vv-as=""{{ __('shop::app.checkout.onepage.email') }}""/>
|
||||
<input type="text" v-validate="'required|email'" class="control" id="billing[email]" name="billing[email]" v-model="address.billing.email" data-vv-as=""{{ __('shop::app.checkout.onepage.email') }}"" @blur="isCustomerExist"/>
|
||||
|
||||
<span class="control-error" v-if="errors.has('address-form.billing[email]')">
|
||||
@{{ errors.first('address-form.billing[email]') }}
|
||||
|
|
@ -452,81 +452,4 @@
|
|||
</div>
|
||||
@endif
|
||||
|
||||
</form>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
|
||||
var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#password").hide();
|
||||
$('#login-and-forgot-btn').hide();
|
||||
$("[name='billing[email]']").on('blur', function() {
|
||||
//get the given emai
|
||||
var email = $("[name='billing[email]']").val();
|
||||
|
||||
$.ajax({
|
||||
/* the route pointing to the post function */
|
||||
url: '{{ route('customer.checkout.exist') }}',
|
||||
type: 'POST',
|
||||
|
||||
/* send the csrf-token and the input to the controller with data */
|
||||
data: {'_token': CSRF_TOKEN,
|
||||
'email': email },
|
||||
dataType: 'JSON',
|
||||
|
||||
/* remind that 'data' is the response of the OnePageController */
|
||||
success: function (data) {
|
||||
if (data == true) {
|
||||
$("#password").show();
|
||||
$('#login-and-forgot-btn').show();
|
||||
} else {
|
||||
$("#password").hide();
|
||||
$('#login-and-forgot-btn').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.btn-login').click(function(e) {
|
||||
var email = $("[name='billing[email]']").val();
|
||||
var password = $("[name='password']").val();
|
||||
event.preventDefault();
|
||||
$.ajax({
|
||||
|
||||
/* the route pointing to the post function */
|
||||
url: '{{ route('customer.checkout.login') }}',
|
||||
type: 'POST',
|
||||
|
||||
/* send the csrf-token and the input to the controller with data */
|
||||
data: {'_token': CSRF_TOKEN,
|
||||
'email': email,
|
||||
'password': password
|
||||
},
|
||||
dataType: 'JSON',
|
||||
|
||||
/* remind that 'data' is the response of the OnePageController */
|
||||
success: function (response) {
|
||||
|
||||
if (response.success) {
|
||||
window.location.href = "{{ route('shop.checkout.onepage.index') }}";
|
||||
} else {
|
||||
var appendData = '<div class="alert alert-error"><span class="icon white-cross-sm-icon"></span><p>'+response.error+'</p></div>';
|
||||
$('.alert-wrapper').html('');
|
||||
$('.alert-wrapper').append(appendData);
|
||||
|
||||
setTimeout(function () {
|
||||
$('.alert-error').hide();
|
||||
}, 5000);
|
||||
Success = false;
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
</form>
|
||||
Loading…
Reference in New Issue