From e98f20cb232a58ef66783f72fd802bfcd35a2ec9 Mon Sep 17 00:00:00 2001 From: zhangjialiang Date: Wed, 18 Jun 2025 12:44:46 +0800 Subject: [PATCH] * [story#75371,doing,1h] Fix that the JS did not execute when entering the page for the first time. --- module/admin/js/register.ui.js | 33 ++++++++++++------------------- module/admin/ui/register.html.php | 26 ++++++++++++++++++------ 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/module/admin/js/register.ui.js b/module/admin/js/register.ui.js index 03c8461af3..90213b0c05 100644 --- a/module/admin/js/register.ui.js +++ b/module/admin/js/register.ui.js @@ -1,13 +1,14 @@ -$('#agreeUX').on('change', function(e) +window.changeAgreeUX = function(e) { - $.post($.createLink('admin', 'changeAgreeUX'),{agreeUX:e.target.checked},function(response) + e = $(e); + $.post($.createLink('admin', 'changeAgreeUX'),{agreeUX:e.prop('checked')},function(response) { response = JSON.parse(response); zui.Messager.show(response.message); }); -}); +} -$('#unBind').on('click', function(e) +window.unBind = function() { $.post($.createLink('admin', 'unBindCommunity'),{},function(response) { @@ -20,20 +21,11 @@ $('#unBind').on('click', function(e) }, 1000); } }); -}); +} -$().ready(function() -{ - getCaptchaContent($('.image-box')); -}); - -$('.image-box').on('click', function() -{ - getCaptchaContent($('.image-box')); -}); - -function getCaptchaContent($ele) +window.getCaptchaContent = function(ele) { + $ele = $(ele); $.get($.createLink('admin', 'getCaptcha'), function(response) { response = JSON.parse(response); @@ -41,13 +33,14 @@ function getCaptchaContent($ele) }); } -$('#captcha-btn').on('click', function(e) +window.showCaptcha = function() { $('.captcha-mobile-sender').show(); -}); +} -$('#checkMobileSender').on('click', function(e) +window.checkMobileSender = function(e) { + e = $(checkMobileSenderID); e.preventDefault(); $('#captchaImageError').html(''); $('#captchaMobileError').html(''); @@ -68,7 +61,7 @@ $('#checkMobileSender').on('click', function(e) if(response.captchaContent) $('.captch-box .image-box').html(response.captchaContent); } }); -}); +} function setSmsSenderTime() { diff --git a/module/admin/ui/register.html.php b/module/admin/ui/register.html.php index f650215ee2..6afff8e002 100644 --- a/module/admin/ui/register.html.php +++ b/module/admin/ui/register.html.php @@ -34,7 +34,12 @@ if($bindCommunity) $bindCommunityMobile ), div( - html("") + button( + setClass('btn btn-wide btn-primary'), + setID('unBind'), + $lang->admin->register->unBindText, + on::click()->call('unBind'), + ) ) ), div( @@ -50,7 +55,12 @@ if($bindCommunity) $lang->admin->register->joinDesc, ), div( - html("") + input( + set('type', 'checkbox'), + setID('agreeUX'), + set('checked', $checked), + on::change()->call('changeAgreeUX', '#agreeUX'), + ) ) ) ); @@ -111,7 +121,8 @@ else setID('captcha-btn'), setClass('captcha-btn-class'), set('href', 'javascript:;'), - $lang->admin->register->sendCode + $lang->admin->register->sendCode, + on::click()->call('showCaptcha'), ) ), formRow @@ -153,7 +164,9 @@ else setClass('captcha-wrapper'), div ( - setClass('image-box') + setClass('image-box'), + on::init()->call('getCaptchaContent', ".image-box"), + on::click()->call('getCaptchaContent', ".image-box"), ) ) ), @@ -168,10 +181,11 @@ else ), btn ( - setID('checkMobileSender'), + setID('checkMobileSenderID'), setClass('px-4'), set::type('primary'), - $lang->admin->register->sure + $lang->admin->register->sure, + on::click()->call('checkMobileSender', '#checkMobileSenderID'), ) ) )