【原创】discuz实现QQ互联弹窗式登陆,免跳转直接登陆 [复制链接]

moqu8 2017-4-11

11161 0
【特别提醒】此教程仅适用于Discuz3.4以下的版本的QQ互联使用,暂时未测试Discuz3.4及以上版本!
【本教程由魔趣建站原创(首发于友站NG编程论坛)】discuz的QQ互联在QQ登陆的时候会跳转到独立页面,对用户很不友好!我们的要求是实现像腾讯相关论坛那样的弹出式登陆,如下图:

【原创】discuz实现QQ互联弹窗式登陆,免跳转直接登陆

这样的交互方式无疑提升了用户体验,增强网站的交互性,增加用户注册几率!那么如何实现呢?魔趣建站独家实现,并分享详细的实现过程!【警告】修改任何文件前请提前备份!
第一步:编写一个html文件,命名为logo2.html ,内容为:

<html>

<body>
<!-- 注意:将下面的域名改成你自己的!-->
<iframe src="http://www.nextgod.com/connect.php?mod=login&op=init&referer=index.php&statfrom=login_simple" frameborder="0" width="430" height="395" scrolling="no" style="position:absolute; top: -75px; left: 0px; bottom:80px" noresize="noresize">

</iframe>
</body>
</html>
将该文件上传到网站根目录!(请不要问我根目录在哪,否则不要继续修改了。。)
第二步:
修改模版文件login.htm,该文件在:template/default/member/ 文件夹中,如果你换了模版,就修改相应的模版里面的login.html,将该文件中的下面一段代码替换为下面的【替换代码】
<!-- 需要删除的代码-->
<div class="c cl">
<input type="hidden" name="formhash" value="{FORMHASH}" />
<input type="hidden" name="referer" value="{echo dreferer()}" />
<!--{if $auth}-->
<input type="hidden" name="auth" value="$auth" />
<!--{/if}-->

<!--{if $invite}-->
<div class="rfm">
<table>
<tr>
<th>{lang register_from}</th>
<td><a href="home.php?mod=space&uid=$invite[uid]" target="_blank">$invite[username]</a></td>
</tr>
</table>
</div>
<!--{/if}-->

<!--{if !$auth}-->
<div class="rfm">
<table>
<tr>
<th>
<!--{if $this->setting['autoidselect']}--><label for="username_$loginhash">{lang login_id}:</label><!--{else}-->
<span class="login_slct">
<select name="loginfield" style="float: left;" width="45" id="loginfield_$loginhash">
<option value="username">{lang username}</option>
<!--{if getglobal('setting/uidlogin')}-->
<option value="uid">{lang uid}</option>
<!--{/if}-->
<option value="email">{lang email}</option>
</select>
</span>
<!--{/if}-->
</th>
<td><input type="text" name="username" id="username_$loginhash" autocomplete="off" size="30" class="px p_fre" tabindex="1" value="$username" /></td>
<td class="tipcol"><a href="member.php?mod={$_G[setting][regname]}">$_G['setting']['reglinkname']</a></td>
</tr>
</table>
</div>
<div class="rfm">
<table>
<tr>
<th><label for="password3_$loginhash">{lang login_password}:</label></th>
<td><input type="password" id="password3_$loginhash" name="password" size="30" class="px p_fre" tabindex="1" /></td>
<td class="tipcol"><a href="javascript:;" title="{lang getpassword}">{lang getpassword}</a></td>
</tr>
</table>
</div>
<!--{/if}-->

<!--{if empty($_GET['auth']) || $questionexist}-->
<div class="rfm">
<table>
<tr>
<th>{lang security_q}:</th>
<td><select id="loginquestionid_$loginhash" width="213" name="questionid"{if !$questionexist}<!--{/if}-->>
<option value="0"><!--{if $questionexist}-->{lang security_question_0}<!--{else}-->{lang security_question}<!--{/if}--></option>
<option value="1">{lang security_question_1}</option>
<option value="2">{lang security_question_2}</option>
<option value="3">{lang security_question_3}</option>
<option value="4">{lang security_question_4}</option>
<option value="5">{lang security_question_5}</option>
<option value="6">{lang security_question_6}</option>
<option value="7">{lang security_question_7}</option>
</select></td>
</tr>
</table>
</div>
<div class="rfm" id="loginanswer_row_$loginhash" {if !$questionexist} style="display:none"{/if}>
<table>
<tr>
<th>{lang security_a}:</th>
<td><input type="text" name="answer" id="loginanswer_$loginhash" autocomplete="off" size="30" class="px p_fre" tabindex="1" /></td>
</tr>
</table>
</div>
<!--{/if}-->

<!--{if $seccodecheck}-->
<!--{block sectpl}--><div class="rfm"><table><tr><th><sec>: </th><td><sec><br /><sec></td></tr></table></div><!--{/block}-->
<!--{subtemplate common/seccheck}-->
<!--{/if}-->

<!--{hook/logging_input}-->

<div class="rfm {if !empty($_GET['infloat'])} bw0{/if}">
<table>
<tr>
<th></th>
<td><label for="cookietime_$loginhash"><input type="checkbox" class="pc" name="cookietime" id="cookietime_$loginhash" tabindex="1" value="2592000" $cookietimecheck />{lang login_permanent}</label></td>
</tr>
</table>
</div>

<div class="rfm mbw bw0">
<table width="100%">
<tr>
<th> </th>
<td>
<button class="pn pnc" type="submit" name="loginsubmit" value="true" tabindex="1"><strong>{lang login}</strong></button>
</td>
<td>
<!--{if $this->setting['sitemessage'][login] && empty($_GET['infloat'])}--><a href="javascript:;" id="custominfo_login_$loginhash" class="y"> </a><!--{/if}-->
<!--{if !$this->setting['bbclosed'] && empty($_GET['infloat'])}--><a href="javascript:;" title="{lang login_clearcookies}" class="y">{lang login_clearcookies}</a><!--{/if}-->
</td>
</tr>
</table>
</div>

<!--{if !empty($_G['setting']['pluginhooks']['logging_method'])}-->
<div class="rfm bw0 {if empty($_GET['infloat'])} mbw{/if}">
<hr class="l" />
<table>
<tr>
<th>{lang login_method}:</th>
<td><!--{hook/logging_method}--></td>
</tr>
</table>
</div>
<!--{/if}-->
</div>
【替换代码+实现教程】
<!-- 替换代码-->
<iframe src="../logo2.html" width="430" height="330" frameborder="0" scrolling="no" noresize="noresize">
</iframe>
如果你是默认模版,可以下载这个修改好的login.htm文件直接替换!
点击下载 【原创】discuz实现QQ互联弹窗式登陆,免跳转直接登陆(大小:6.22K)

第三步:
到这里,你网站的默认按钮就已经可以执行QQ弹出式登陆了,但是还有QQ互联自带的按钮需要修改,修改的方法是这样的:下载文件source/plugin/qqconnect/template/module.htm,用Notepad编辑器打开该文件,查找并替换:$_G[connect][login_url]&statfrom=login_simple 为
【原创】discuz实现QQ互联弹窗式登陆,免跳转直接登陆
member.php?mod=logging&amp;action=login" onclick="showWindow('login', this.href)



【注意】这里有一个问题,就是上述方法屏蔽了自带的弹出式,如果想既保留自带的弹出式登陆又实现QQ互联弹窗式,则忽略本教程的【第二步】,不对login.htm做修改,但是你需要复制一份login.htm,改为其他名字,比如loginqq.htm,然后对loginqq.htm做【第二步】的处理,处理后上传到login.htm所在的文件夹。接着下载source/module/member/member_logging.php ,并将该文件命名为:member_loggingqq.php ,然后修改重命名后的member_loggingqq.php文件,将里面的 $ctl_obj->template = 'member/login'; 为 $ctl_obj->template = 'member/loginqq'; 保存并上传到:source/module/member/ 。接着执行【第三步】,但是第三步需要将source/plugin/qqconnect/template/module.htm里面的$_G[connect][login_url]&statfrom=login_simple 修改为为【原创】discuz实现QQ互联弹窗式登陆,免跳转直接登陆
member.php?mod=logging&amp;action=login" onclick="showWindow('login', this.href)



【修改全部按钮】查找source/plugin/qqconnect/template/module.htmz中的qq_login.gif,然后将该字符串前面的<a href="链接">中的链接全部按照第三步修改,那么任何地方的QQ登陆都将弹窗式展现!

【最后实现的效果如下】

【原创】discuz实现QQ互联弹窗式登陆,免跳转直接登陆

【原创】discuz实现QQ互联弹窗式登陆,免跳转直接登陆


最新回复 (0)
返回
支持中心
邮箱:winkill2012@qqcom
新站优化中!部分功能尚未完善,敬请谅解!
支持中心