返回列表 发帖
查看: 2513|回复: 4

求助大神 强制设定登录需要设定昵称才可操作

8

主题

33

回帖

92

积分

渐入佳境

贡献
0 点
金币
48 个
发表于 2019-7-9 16:39:21 | 显示全部楼层 |阅读模式
Snipaste_2019-07-09_16-33-49.jpg
求助,如何在用户登录后论坛直接设定昵称  若不设定昵称  自动退出  

请问这些代码应该要加入到哪里呢?
  1. <script src="template/XXX/image/js/nv.js" type="text/javascript"></script>              
  2. <div class="p_pop h_pop" id="mn_userapp_menu" style="display: none"></div><div id="mu" class="cl">
  3. </div>               
  4. </div>        
  5. </div>            <div class="index_tkbg hide">
  6.     <div class="index_tk">
  7.       <p class="tk_top">亲爱的客户</p>
  8.       <span class="tk_close">×</span>
  9.       <p class="tk_ts">创建论坛账号,请先填写昵称(填写后不能更改)</p>
  10.       <div class="tk_inp tk_mar"><input type="text" name="username" id="username" maxlength="15" /><span class="warn_tk"></span></div>
  11.       <div class="tk_inp"><button id="subname" class="disable">提交</button></div>
  12.     </div>
  13.    
  14. </div>
  15. <div class="login_tkbg hide">
  16.     <div class="index_tk">
  17.       <p class="tk_top">亲爱的客户</p>
  18.       <span class="tk_close">×</span>
  19.       <p class="tk_ts">请先登录您的账号</p>
  20.       <div class="tk_inp login_marg"><button id="login_bth">立即登录</button> <button id="login_know">我知道了</button></div>
  21.     </div>
  22. </div>
  23. <div id="login_bbslink" class="hide">online</div>
  24.          <div id="login_bbsactive" class="hide">0</div>
  25. <script type="text/javascript">
复制代码
加载的js:
  1. <script type="text/javascript">
复制代码
除此之外还需要加入哪些修改呢?
回复

使用道具 举报

8

主题

33

回帖

92

积分

渐入佳境

贡献
0 点
金币
48 个
 楼主| 发表于 2019-7-9 16:40:40 | 显示全部楼层

加载的js:
  1. <script type="text/javascript">
  2. var prj = {};
  3. //按钮上几个点的loading效果
  4. prj.loadingAnimation = function(container){
  5. var loading = '<ul class="clearfix loadingpoint"><li class="active"></li><li></li><li></li><li></li><li></li></ul>';
  6. var loadingpoint = jQuery(container).find('.loadingpoint');
  7. if(loadingpoint.length == 0){
  8. //需要先加入,再选择        
  9. jQuery(container).append(loading);
  10. }
  11. var num = 0;
  12. var el = $('.loadingpoint li');
  13. setInterval(function () {
  14. num++;
  15. num %= jQuery(el).length;
  16. $(el[num]).addClass('active').siblings('li').removeClass();
  17. }, 500);
  18. }
  19. prj.btnloading = function (btn, loadingword) {
  20. var loadingword = typeof !loadingword ? '提交中' : loadingword;
  21. //复制一个副本
  22. var cloneBtn = btn.clone(true);

  23. /*
  24. 按钮克隆,需要单例
  25. */
  26. btn.hide();
  27. btn.siblings('.btnloading').remove();
  28. cloneBtn.insertAfter(btn);
  29. cloneBtn.addClass('disable btnloading').html(loadingword);
  30. //loading效果
  31. prj.loadingAnimation(cloneBtn);

  32. //透明度为0的遮罩
  33. // this.newloading();
  34. }
  35. prj.singleWay = (function () {

  36. var fgs = {},
  37. kit = {
  38. resolve: function (key) {
  39. fgs[key] = false;
  40. }
  41. };

  42. return function (key, func) {
  43. if (fgs[key] === true) {
  44. return;
  45. } else {
  46. fgs[key] = true;
  47. func.call(kit, key);
  48. }
  49. }
  50. })();
  51. if(!String.prototype.trim){
  52. String.prototype.trim = function(){
  53. return this.replace(/^\s*|\s*&/g,"");
  54. }
  55. }

  56. jQuery(function(jQuery){
  57.     var active=jQuery('#login_bbsactive').text();                        //0:无论坛账号  非0:有账号
  58.     var urls=window.location.search;
  59.     var urlone=urls.split("?");
  60.     if(urlone !=""){
  61.     var urlstyle=urlone[1].split("=")
  62.     var scookie=jQuery.cookie('cookieispop');
  63.      if(scookie!=undefined && urlstyle[0]=='ispop'){
  64.         if (active!=0) {
  65.           jQuery('.index_tkbg').addClass('hide');
  66.         }else{
  67.           jQuery('.index_tkbg').removeClass('hide');
  68.         }
  69.      };
  70.     }
  71.     jQuery(document).on('blur','#username',function(){
  72.               var floag=0;
  73.               var  inp=document.getElementById('username');
  74.               var username=inp.value;
  75.         if (username.length<3) {
  76.                 jQuery('.warn_tk').text('账号的长度为3-15位');
  77.                 return;
  78.         }else{
  79.                 for(var i=0;i<username.length;i++){
  80.           var reg=/^[a-z0-9A-Z\u4e00-\u9fa5]*$/;
  81.           if(reg.test(username[i])==false){
  82.             floag=1;
  83.             jQuery('.warn_tk').text('昵称不能包含特殊字符');
  84.             return;
  85.           }
  86.         }
  87.               }
  88.     if (floag==0) {
  89.               var cookies = document.cookie.split(';');
  90.         var iscookie=';'
  91.         for(var i = 0;i<cookies.length;i++){
  92.               var name='cookieispop'+'=';
  93.               var ca=cookies[i].trim();
  94.               if (ca.indexOf(name)==0) {
  95.                 iscookie=ca.substring(name.length,ca.length)
  96.               };
  97.         };
  98.         var urls=window.location.search;
  99.           if(urls !=""){
  100.             var urlstyle=urls.split("=")
  101.             uels=urlstyle[1];
  102.         }
  103.         jQuery.ajax({
  104.             type: "POST",
  105.             url: "bbslink.php?mod=linkregister",
  106.             data: {
  107.                 'nickname':username,
  108.                 'ispop':uels,
  109.                 'cookieispop':iscookie,
  110.                 'step':1
  111.             },
  112.             success: function (res) {
  113.               var res=JSON.parse(res);
  114.                if(res.status==0){
  115.                 jQuery('.warn_tk').text("昵称已存在");
  116.                 jQuery('#subname').attr('disabled',true)
  117.               }else if(res.status==-1){
  118.                 jQuery('.warn_tk').text("已存在对应论坛账号");
  119.                 jQuery('#subname').attr('disabled',true)
  120.               }else if(res.status==-2){
  121.                 jQuery('.warn_tk').text("昵称不符合规则");
  122.                 jQuery('#subname').attr('disabled',true)
  123.               }else if(res.status==-3){
  124.                 jQuery('.warn_tk').text("请求路径非法");
  125.                 jQuery('#subname').attr('disabled',true)
  126.               }else if(res.status==-4){
  127.                  jQuery('.warn_tk').text("昵称长度不符合");
  128.                  jQuery('#subname').attr('disabled',true)
  129.               }else{
  130.                 jQuery('.warn_tk').text("");
  131.                 jQuery('#subname').attr('disabled',false);
  132.                 jQuery('#subname').removeClass('disable');
  133.                 prj.singleWay('subname-key',function(key){
  134.                         var kit = this;
  135.                         jQuery(document).on('click','#subname',function(){
  136.                     var that = jQuery('#subname');
  137.                     if(that.hasClass('disable')){
  138.                             return;
  139.                     }
  140.                         jQuery.ajax({
  141.                     type: "POST",
  142.                     url: "bbslink.php?mod=linkregister",
  143.                     data: {
  144.                         'nickname':username,
  145.                         'ispop':uels,
  146.                         'cookieispop':iscookie,
  147.                         'step':2
  148.                     },
  149.                     success: function (res) {
  150.                        kit.resolve(key);
  151.                        location.href="forum.php"
  152.                        jQuery('#subname').attr('disabled',true);
  153.                     },
  154.                     error:function(){
  155.                       kit.resolve(key);        
  156.                       alert('网络异常,请稍后重试')
  157.                     },
  158.                     beforeSend: function () {
  159. prj.btnloading(that, '');
  160. }
  161.                       })
  162.             });
  163.                 });
  164.               }
  165.             },
  166.             error:function(){
  167.               alert('网络异常,请稍后重试')
  168.             }
  169.         })
  170.     };
  171.     });
  172.     jQuery('.tk_close').on('click',function(){
  173.                    jQuery('.index_tkbg').addClass('hide');
  174.                    jQuery('.login_tkbg').addClass('hide');
  175.     })
  176.           jQuery('#login_bth').on('click',function(){
  177.            if($('ls_username').value == '' || $('ls_password').value == '') {
  178. var urltwo=location.href
  179. var acurl=jQuery('#login_bbslink').text();
  180. if (acurl=='develop') {
  181. window.open('http://t.e03.com/index.htm?returncode='+urltwo+'');
  182. jQuery('.login_tkbg').addClass('hide');
  183. }else if(acurl=='online'){
  184.             window.location.+urltwo+'';
  185. }else{
  186.             window.location.+urltwo+'';
  187. }
  188. } else {
  189. }
  190.           });
  191.     jQuery('#login_know').on('click',function(){        
  192.                     jQuery('.login_tkbg').addClass('hide');
  193.           })
  194. });
  195. </script>
  196. <div id="wp" class="wp">
复制代码
回复 支持 反对

使用道具 举报

7

主题

61

回帖

88

积分

渐入佳境

贡献
0 点
金币
18 个
发表于 2019-7-10 13:09:03 | 显示全部楼层
我不会,但楼下会
http://www.kltcw.com
回复 支持 反对

使用道具 举报

8

主题

52

回帖

108

积分

渐入佳境

贡献
0 点
金币
44 个
发表于 2019-7-10 14:34:22 | 显示全部楼层
小白路过帮你顶。。。
回复 支持 反对

使用道具 举报

8

主题

33

回帖

92

积分

渐入佳境

贡献
0 点
金币
48 个
 楼主| 发表于 2019-7-11 09:59:22 | 显示全部楼层
我不会,但楼下会
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 关注公众号
  • 有偿服务微信
  • 有偿服务QQ

手机版|小黑屋|Discuz! 官方交流社区 ( 皖ICP备16010102号 |皖公网安备34010302002376号 )|网站地图|star

GMT+8, 2024-5-17 11:13 , Processed in 0.042483 second(s), 7 queries , Redis On.

Powered by Discuz! W1.0 Licensed

Cpoyright © 2001-2024 Discuz! Team.

关灯 在本版发帖
有偿服务QQ
有偿服务微信
返回顶部
快速回复 返回顶部 返回列表