123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- function getUrlParam(name)
- {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
- var r = window.location.search.substr(1).match(reg); //匹配目标参数
- if (r != null) return unescape(r[2]); return null; //返回参数值
- }
- function login()
- {
- var html = '<div class="form-item"><i class="ico-email"></i><input type="text" placeholder="邮箱" id="email" name="email"></div><div class="form-item"><i class="ico-password"></i><input type="password" placeholder="密码" id="password" name="password"></div><div class="form-links"><a href="javascript:;" onclick="forget()">忘记密码?</a><a href="javascript:;" onclick="reg()">注册用户</a></div><div class="btn-wrap">';
- return layer('login', '登录', html, '登录');
- }
- function reg()
- {
- var html = '<div class="form-item"><i class="ico-email"></i><input type="text" placeholder="邮箱" id="email" name="email"></div><div class="form-item"><i class="ico-password"></i><input type="password" placeholder="密码" id="password" name="password"></div><div class="form-item"><i class="ico-password"></i><input type="password" placeholder="确认密码" id="cpassword" name="cpassword"></div><div class="form-links align-right"><a href="javascript:;" onclick="login()">已有账号?点此登录</a></div>';
- return layer('reg', '注册', html, '注册');
- }
- function forget()
- {
- var html = '<div class="form-item"><i class="ico-email"></i><input type="text" placeholder="邮箱" id="email" name="email"></div><div class="form-links align-right"><a href="javascript:;" onclick="login()">点此登录</a><span>|</span><a href="javascript:;" onclick="reg()">点此注册</a></div>';
- return layer('find_password', '找回密码', html, '确认');
- }
- function edit_password()
- {
- var signature = getUrlParam('signature');
- var email = getUrlParam('email');
- var html = '<div class="form-item"><i class="ico-email"></i><input type="hidden" id="signature" name="signature" value="'+signature+'"><input type="text" placeholder="邮箱" id="email" name="email" value="'+email+'" readonly></div><div class="form-item"><i class="ico-password"></i><input type="password" placeholder="密码" id="password" name="password"></div><div class="form-item"><i class="ico-password"></i><input type="password" placeholder="确认密码" id="cpassword" name="cpassword"></div><div class="form-links align-right"><a href="javascript:;" onclick="login()">已有账号?点此登录</a></div>';
- return layer('edit_password', '密码重置', html, '确认');
- }
- function layer(id, title, content, button)
- {
- var refer = location.href;
- var mask = '<div class="mask">';
- var html = '';
- html += '<div class="layer">';
- html += '<h4><span>'+title+'</span></h4>';
- html += '<form id="layer_form">';
- html += content;
- html += '<div class="btn-wrap"><a href="javascript:;" id="'+id+'" class="btn">'+button+'</a><input type="hidden" id="refer" name="refer" value="'+refer+'"></div>';
- html += '</form>';
- html += '</div>';
- if (!$('.mask').length) {
- $('body').append(mask + html + '</div>');
- } else {
- $('.mask').html(html);
- }
- $('.mask').show();
- Dever.User().Init();
- }
- //定义用户相关的一些信息
- Dever.User().config =
- {
- //初始化,绑定click
- 'click' :
- {
- //登录
- 0 : '#login'
- //注册
- ,1 : '#reg'
- //找回密码
- ,2 : '#find_password'
- //找回密码
- ,3 : '#edit_password'
- }
- //登录信息
- ,0 :
- {
- 'input' :
- {
- 'email' : '#email'
- ,'password' : '#password'
- ,'refer' : '#refer|'
- }
- //错误提示的div
- ,'status' : '#dever_alert'
- //错误提示
- ,'error' : '您的邮箱或密码错误'
- //登录要提交的url
- ,'url' : Dever.Host('passport', 'login.action')
- }
- //注册信息
- ,1 :
- {
- 'input' :
- {
- 'email' : '#email'
- ,'username' : '#email'
- ,'password' : '#password'
- ,'cpassword' : '#cpassword'
- ,'refer' : '#refer|'
- }
- //错误提示的div
- ,'status' : '#dever_alert'
- //错误提示
- ,'error' : '您填写的信息有误'
- //登录要提交的url
- ,'url' : Dever.Host('passport', 'reg.action')
- }
-
- //找回密码发送邮件
- ,2 :
- {
- 'input' :
- {
- 'email' : '#email'
- ,'refer' : '#refer|'
- }
- //错误提示的div
- ,'status' : '#dever_alert'
- //错误提示
- ,'error' : '您填写的信息有误'
- //找回密码发送邮件
- ,'url' : Dever.Host('passport', 'reg.forget_email')
- }
- ,3 :
- {
- 'input' :
- {
- 'email' : '#email'
- ,'password' : '#password'
- ,'cpassword' : '#cpassword'
- ,'signature' : '#signature'
- ,'refer' : '#refer|'
- }
- //错误提示的div
- ,'status' : '#dever_alert'
- //错误提示
- ,'error' : '您填写的信息有误'
- //找回密码操作
- ,'url' : Dever.Host('passport', 'reg.forget')
- }
- };
- $(document).ready(function()
- {
- var html = location.href;
- if (html.indexOf('signature') != -1) {
- edit_password();
- }
- });
|