This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,77 @@
define([
'jquery',
'mage/validation'
], function ($) {
'use strict';
$.widget('mage.esunForgotpassword', {
options: {
redirectUrl: ''
},
/** @inheritdoc */
_create: function () {
this.$form = this.element.find('#form-validate');
this.$modal = this.element.find('#esun-forgotpassword-modal');
this.$form.on('submit', $.proxy(this._onSubmit, this));
this.element.on('click', '#esun-forgotpassword-modal-confirm', $.proxy(this._onConfirm, this));
this.element.on('click', '#esun-forgotpassword-modal-close', $.proxy(this._closeModal, this));
},
/**
*
* @param {Event} event
* @private
*/
_onSubmit: function (event) {
var self = this,
$form = this.$form;
if (!$form.validation('isValid')) {
return;
}
event.preventDefault();
$.ajax({
url: $form.attr('action'),
data: $form.serialize(),
type: 'post',
dataType: 'html',
showLoader: true
}).done(function () {
self._openModal();
}).fail(function () {
// 网络/服务器异常时,退回默认行为,直接提交表单
$form.off('submit').trigger('submit');
});
},
/**
* 打开成功提示弹窗
* @private
*/
_openModal: function () {
this.$modal.addClass('esun-modal-overlay--open');
},
/**
* 关闭弹窗(不跳转)
* @private
*/
_closeModal: function () {
this.$modal.removeClass('esun-modal-overlay--open');
},
/**
* 点击 Confirm 后跳转回登录页
* @private
*/
_onConfirm: function () {
window.location.href = this.options.redirectUrl;
}
});
return $.mage.esunForgotpassword;
});
@@ -0,0 +1,34 @@
define([
'jquery'
], function ($) {
'use strict';
$.widget('mage.esunLoginPasswordToggle', {
options: {},
/** @inheritdoc */
_create: function () {
this.element.on('click', '.esun-password-toggle', $.proxy(this._toggle, this));
},
/**
*
* @param {Event} event
* @private
*/
_toggle: function (event) {
var $button = $(event.currentTarget),
$input = $button.siblings('.esun-input');
if ($input.attr('type') === 'password') {
$input.attr('type', 'text');
$button.addClass('esun-password-toggle--visible');
} else {
$input.attr('type', 'password');
$button.removeClass('esun-password-toggle--visible');
}
}
});
return $.mage.esunLoginPasswordToggle;
});
@@ -0,0 +1,66 @@
define([
'jquery',
'Magento_Ui/js/modal/modal',
'mage/validation'
], function ($, modal) {
'use strict';
return function (config, element) {
var $root = $(element),
$form = $root.find('#form-validate'),
$subscription = $root.find('#is_subscribed'),
$reminder = $root.find('[data-role="subscription-reminder"]'),
$dialog = $root.find('[data-role="subscription-confirmation"]'),
bypassConfirmation = false;
if (!$form.length || !$subscription.length || !$reminder.length || !$dialog.length) {
return;
}
function submitWithSubscription(subscribe) {
$subscription.prop('checked', subscribe).trigger('change');
bypassConfirmation = true;
$dialog.modal('closeModal');
$form.trigger('submit');
bypassConfirmation = false;
}
modal({
type: 'popup',
responsive: true,
innerScroll: false,
title: config.modalTitle,
modalClass: 'esun-subscription-modal',
buttons: [
{
text: config.declineButtonText,
class: 'action secondary esun-subscription-modal__decline',
click: function () {
submitWithSubscription(false);
}
},
{
text: config.subscribeButtonText,
class: 'action primary esun-subscription-modal__subscribe',
click: function () {
submitWithSubscription(true);
}
}
]
}, $dialog);
$form.on('submit.esunSubscriptionConfirmation', function (event) {
if (bypassConfirmation || $subscription.is(':checked')) {
return;
}
if (!$form.validation('isValid')) {
return;
}
event.preventDefault();
event.stopImmediatePropagation();
$dialog.modal('openModal');
});
};
});