Authored by xuqi

build login

1 -alert('I am test');  
  1 +/**
  2 + * 国际账号登录
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + * @date: 2015/10/8
  5 + */
  6 +var $ = require('yoho.jquery');
  7 +
  8 +var $phoneNum = $('#phone-num'),
  9 + $countrySelect = $('#country-select'),
  10 + $countryCode = $('#country-code'),
  11 + $pwd = $('#pwd'),
  12 + $loginBtn = $('#btn-login'),
  13 +
  14 + pnPass = false,
  15 + pwdPass = false;
  16 +
  17 +var api = require('../api');
  18 +
  19 +var trim = $.trim;
  20 +var showErrTip = api.showErrTip;
  21 +
  22 +//登录按钮状态切换
  23 +function switchLoginBtnStatus() {
  24 + if (pnPass && pwdPass) {
  25 + $loginBtn.removeClass('disable');
  26 + } else {
  27 + $loginBtn.addClass('disable');
  28 + }
  29 +}
  30 +
  31 +//Android-UC下显示select的direction:rtl无效的临时解决办法
  32 +api.selectCssHack($countrySelect);
  33 +
  34 +//初始化ErrTip
  35 +api.initErrTip();
  36 +
  37 +//显示隐藏密码
  38 +api.bindEyesEvt();
  39 +
  40 +//清空手机号码
  41 +api.bindClearEvt();
  42 +
  43 +$phoneNum.bind('input', function() {
  44 + if (trim($phoneNum.val()) === '') {
  45 + pnPass = false;
  46 + } else {
  47 + pnPass = true;
  48 + }
  49 +
  50 + switchLoginBtnStatus();
  51 +});
  52 +
  53 +$pwd.bind('input', function() {
  54 + var pwd = trim($pwd.val());
  55 +
  56 + if (pwd === '') {
  57 + pwdPass = false;
  58 + } else {
  59 + pwdPass = true;
  60 + }
  61 +
  62 + switchLoginBtnStatus();
  63 +});
  64 +
  65 +$countrySelect.change(function() {
  66 + $countryCode.text($countrySelect.val());
  67 +});
  68 +
  69 +$loginBtn.on('touchstart', function() {
  70 + var pn = trim($phoneNum.val()),
  71 + country = $countrySelect.val(),
  72 + pwd = trim($pwd.val());
  73 +
  74 + if ($loginBtn.hasClass('disable')) {
  75 + return;
  76 + }
  77 +
  78 + if (api.phoneRegx[country].test(pn) && api.pwdValidate(pwd)) {
  79 + $.ajax({
  80 + type: 'POST',
  81 + url: '/passport/signin/auth',
  82 + data: {
  83 + area: country.split('+')[1],
  84 + account: pn,
  85 + pwd: pwd
  86 + }
  87 + }).then(function(data) {
  88 + if (data.code === 200) {
  89 + showErrTip('登录成功');
  90 +
  91 + //1000ms后跳转页面
  92 + setTimeout(function() {
  93 + location.href = data.data;
  94 + }, 1000);
  95 + } else {
  96 + showErrTip(data.message);
  97 + }
  98 + }, function() {
  99 + showErrTip('网络断开连接啦~');
  100 + });
  101 + } else {
  102 + showErrTip('账号或密码有错误,请重新输入');
  103 + }
  104 +});
  105 +
  106 +//对初始有默认值的情况去初始化登录按钮状态
  107 +$phoneNum.trigger('input');
  108 +$pwd.trigger('input');
  1 +/**
  2 + * 登录
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + * @date: 2015/9/30
  5 + */
  6 +var $ = require('yoho.jquery');
  7 +
  8 +var $account = $('#account'),
  9 + $pwd = $('#pwd'),
  10 + $loginBtn = $('#btn-login'),
  11 +
  12 + $mask = $('#retrive-pwd-mask'),
  13 + $ways = $('#retrive-ways'),
  14 +
  15 + accPass = false,
  16 + pwdPass = false;
  17 +
  18 +var api = require('../api');
  19 +
  20 +var trim = $.trim;
  21 +var showErrTip = api.showErrTip;
  22 +
  23 +//登录按钮状态切换
  24 +function switchLoginBtnStatus() {
  25 + if (accPass && pwdPass) {
  26 + $loginBtn.removeClass('disable');
  27 + } else {
  28 + $loginBtn.addClass('disable');
  29 + }
  30 +}
  31 +
  32 +//显示找回密码面板
  33 +function showRetrivePanel() {
  34 + $mask.show();
  35 + $ways.slideDown();
  36 +}
  37 +
  38 +//隐藏找回密码面板
  39 +function hideRetrivePanel() {
  40 + $mask.hide();
  41 + $ways.slideUp();
  42 +}
  43 +
  44 +//初始化ErrTip
  45 +api.initErrTip();
  46 +
  47 +//密码显示与隐藏
  48 +api.bindEyesEvt();
  49 +
  50 +//清空账号输入框
  51 +api.bindClearEvt();
  52 +
  53 +$account.bind('input', function() {
  54 + if (trim($account.val()) !== '') {
  55 + accPass = true;
  56 + } else {
  57 + accPass = false;
  58 + }
  59 + switchLoginBtnStatus();
  60 +});
  61 +
  62 +$pwd.bind('input', function() {
  63 + if (trim($pwd.val()) === '') {
  64 + pwdPass = false;
  65 + } else {
  66 + pwdPass = true;
  67 + }
  68 + switchLoginBtnStatus();
  69 +});
  70 +
  71 +
  72 +// Login
  73 +$loginBtn.on('touchstart', function() {
  74 + var acc = trim($account.val()),
  75 + pwd = trim($pwd.val());
  76 +
  77 + if ($loginBtn.hasClass('disable')) {
  78 + return;
  79 + }
  80 +
  81 + //验证账号(数字或者邮箱)和密码合理性
  82 + if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {
  83 + $.ajax({
  84 + type: 'POST',
  85 + url: '/passport/signin/auth',
  86 + data: {
  87 + account: acc,
  88 + pwd: pwd
  89 + }
  90 + }).then(function(data) {
  91 + if (data.code === 200) {
  92 + showErrTip('登录成功');
  93 +
  94 + //1s后跳转页面
  95 + setTimeout(function() {
  96 + location.href = data.data;
  97 + }, 1000);
  98 + } else {
  99 + showErrTip(data.message);
  100 + }
  101 + }, function() {
  102 + showErrTip('网络断开连接啦~');
  103 + });
  104 + } else {
  105 + showErrTip('账号或密码有错误,请重新输入');
  106 + }
  107 +});
  108 +
  109 +
  110 +$('#forget-pwd').on('touchstart', function() {
  111 + showRetrivePanel();
  112 +});
  113 +
  114 +$mask.on('touchstart', function() {
  115 + hideRetrivePanel();
  116 +});
  117 +
  118 +$('#cancel-retrive').on('touchstart', function(e) {
  119 + e.preventDefault();
  120 + hideRetrivePanel();
  121 +});
  122 +
  123 +//对初始有默认值的情况去初始化登录按钮状态
  124 +$account.trigger('input');
  125 +$pwd.trigger('input');
  1 +.login-page {
  2 + .yoho-log {
  3 + position: absolute;
  4 + height: 31px;
  5 + width: 26px;
  6 + background: image-url('yohofamily/yoho.png');
  7 + background-size: 100% 100%;
  8 + top: 10px;
  9 + left: 15px;
  10 + }
  11 +
  12 + .op-container {
  13 + position: relative;
  14 + width: 100%;
  15 + margin: 20px 0;
  16 + text-align: left;
  17 + font-size: 16px;
  18 +
  19 + .go-register {
  20 + text-decoration: underline;
  21 + color: #858585;
  22 + }
  23 +
  24 + .forget-pwd {
  25 + position: absolute;
  26 + right: 0;
  27 + text-decoration: underline;
  28 + color: #858585;
  29 + }
  30 + }
  31 +
  32 + .third-party-login {
  33 + text-align: left;
  34 +
  35 + > span {
  36 + font-size: 16px;
  37 + color: #858585;
  38 + }
  39 +
  40 + .tp-link {
  41 + text-align: center;
  42 + padding: 20px 0;
  43 +
  44 + > a {
  45 + display: inline-block;
  46 + width: 44px;
  47 + height: 44px;
  48 + margin: 0 7px;
  49 + @include border-radius(50%);
  50 + background-color: #333;
  51 + background-repeat: no-repeat;
  52 + background-size: 100% 100%;
  53 + }
  54 +
  55 + .alipay {
  56 + background-image: image-url('yohofamily/alipay.png');
  57 + }
  58 +
  59 + .weibo {
  60 + background-image: image-url('yohofamily/weibo.png');
  61 + }
  62 +
  63 + .weixin {
  64 + background-image: image-url('yohofamily/weixin.png');
  65 + }
  66 +
  67 + .qq {
  68 + background-image: image-url('yohofamily/qq.png');
  69 + }
  70 + }
  71 + }
  72 +
  73 + .interational {
  74 + display: block;
  75 + width: 200px;
  76 + padding: 5px 10px;
  77 + background-color: #333;
  78 + border: none;
  79 + border-radius: 20px;
  80 + margin: 0 auto;
  81 + font-size: 16px;
  82 + color: #d8d8d8;
  83 + }
  84 +
  85 + .login-tip {
  86 + font-size: 16px;
  87 + position: relative;
  88 + color: #d8d8d8;
  89 + margin: 15px 0;
  90 +
  91 + .info {
  92 + display: inline-block;
  93 + height: 12px;
  94 + width: 12px;
  95 + background-image: image-url('yohofamily/info.png');
  96 + background-size: 100% 100%;
  97 + }
  98 + }
  99 +
  100 + .mask {
  101 + position: fixed;
  102 + display: none;
  103 + top: 0;
  104 + bottom: 0;
  105 + right: 0;
  106 + left: 0;
  107 + background-color: rgba(0,0,0,.5);
  108 + }
  109 +
  110 + .retrive-pwd-ways {
  111 + position: fixed;
  112 + display: none;
  113 + bottom: 5px;
  114 + left: 10px;
  115 + right: 10px;
  116 + font-size: 16px;
  117 +
  118 + li {
  119 + background-color: #fff;
  120 + width: 100%;
  121 + height: 40px;
  122 + line-height: 40px;
  123 + text-align: center;
  124 +
  125 + &:nth-child(1) {
  126 + @include border-top-left-radius(5px);
  127 + @include border-top-right-radius(5px);
  128 + border-bottom: 1px solid #9f9f9f;
  129 + }
  130 +
  131 + &:nth-child(2) {
  132 + @include border-bottom-left-radius(5px);
  133 + @include border-bottom-right-radius(5px);
  134 + }
  135 +
  136 + &:last-child {
  137 + margin-top: 10px;
  138 + @include border-radius(5px);
  139 + }
  140 + }
  141 + }
  142 +
  143 +}
1 -<?php  
2 -  
3 -/*  
4 - * To change this license header, choose License Headers in Project Properties.  
5 - * To change this template file, choose Tools | Templates  
6 - * and open the template in the editor.  
7 - */  
8 -  
  1 +<div class="login-page passport-page yoho-page">
  2 + {{> passport/header}}
  3 + <div class="content">
  4 + <div class="acc-container input-container row has-clear">
  5 + <div class="yoho-logo"></div>
  6 + <input id="account" class="input account" type="text" placeholder="手机号/邮箱" autocomplete="off" value={{defAccount}}>
  7 + </div>
  8 + <div class="input-container row has-eye">
  9 + <input id="pwd" class="pwd input" type="password" placeholder="密码">
  10 + </div>
  11 + <span id="btn-login" class="btn btn-login disable">登录</span>
  12 + <p class="op-container">
  13 + <a class="go-register" href={{registerUrl}}>免费注册</a>
  14 + <span id="forget-pwd" class="forget-pwd">忘记密码</span>
  15 + </p>
  16 + <div class="third-party-login">
  17 + <span>其他登录方式</span>
  18 + <div class="tp-link">
  19 + <a class="alipay" href={{aliLoginUrl}}></a>
  20 + <a class="weibo" href={{weiboLoginUrl}}></a>
  21 + <a class="qq" href={{qqLoginUrl}}></a>
  22 + </div>
  23 + </div>
  24 + <a class="interational" href={{interationalUrl}}>Interational Customer</a>
  25 + <div class="login-tip">
  26 + <div class="info-icon"></div>
  27 + Yoho!Family账号可登录YOHO!有货
  28 + </div>
  29 + <div id="retrive-pwd-mask" class="mask"></div>
  30 + <ul id="retrive-pwd-ways" class="retrive-pwd-ways">
  31 + <li>
  32 + <a href={{phoneRetriveUrl}}>通过手机找回密码</a>
  33 + </li>
  34 + <li>
  35 + <a href={{emailRetriveUrl}}>通过邮箱找回密码</a>
  36 + </li>
  37 + <li id="cancel-retrive">
  38 + 取消
  39 + </li>
  40 + </ul>
  41 + </div>
  42 +</div>
  1 +<div class="login-interational-page passport-page yoho-page">
  2 + {{> passport/header}}
  3 + <div class="content">
  4 + {{> passport/country_list}}
  5 + <div class="input-container phone-container row has-clear">
  6 + <span id="country-code" class="country-code">{{countryCode}}</span>
  7 + <input id="phone-num" class="input phone-num" type="text" placeholder="手机号" value={{phoneNum}}>
  8 + </div>
  9 + <div class="input-container row has-eye">
  10 + <input id="pwd" class="pwd input" type="password" placeholder="密码">
  11 + </div>
  12 + <span id="btn-login" class="btn btn-login disble row">登录</span>
  13 + </div>
  14 +</div>