Browse Source

login js function update

master
filesite 7 months ago
parent
commit
b437e3082a
  1. 13
      plugins/Common.php
  2. 37
      themes/tajian/controller/FrontapiController.php
  3. 5
      www/js/tajian.js

13
plugins/Common.php

@ -26,13 +26,13 @@ Class Common {
//初始化用户数据目录 //初始化用户数据目录
public static function initUserData($cellphone, $friends_code = '') { public static function initUserData($cellphone, $friends_code = '') {
$rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory']; $userDir = self::getUserDataDir($cellphone);
$userDir = "{$rootDir}{$cellphone}"; if (!empty($userDir)) {
if (is_dir($userDir)) {
return true; return true;
} }
try { try {
$rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory'];
mkdir("{$userDir}/data/", 0755, true); //分享视频目录 mkdir("{$userDir}/data/", 0755, true); //分享视频目录
mkdir("{$userDir}/tags/", 0700, true); //分类目录 mkdir("{$userDir}/tags/", 0700, true); //分类目录
copy("{$rootDir}README.md", "{$userDir}/README.md"); copy("{$rootDir}README.md", "{$userDir}/README.md");
@ -48,6 +48,13 @@ Class Common {
return true; return true;
} }
//判断用户数据目录是否存在
public static function getUserDataDir($cellphone) {
$rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory'];
$userDir = "{$rootDir}{$cellphone}";
return is_dir($userDir) ? $userDir : false;
}
//检查朋友的邀请码是否存在 //检查朋友的邀请码是否存在
public static function existFriendsCode($code) { public static function existFriendsCode($code) {
if (self::isFriendsCode($code) == false) {return false;} if (self::isFriendsCode($code) == false) {return false;}

37
themes/tajian/controller/FrontapiController.php

@ -473,14 +473,24 @@ eof;
//TODO: 验证短信验证码是否正确 //TODO: 验证短信验证码是否正确
if (empty($err)) { //如果数据检查通过,尝试注册新用户 if (empty($err)) { //如果数据检查通过,尝试注册新用户
$newUser = Common::saveUserIntoSession($cellphone, $friends_code); $userDataDir = Common::getUserDataDir($cellphone);
if (!empty($newUser)) { if (empty($userDataDir)) {
Common::saveFriendsCode($cellphone); $newUser = Common::saveUserIntoSession($cellphone, $friends_code);
Common::initUserData($cellphone, $friends_code); if (!empty($newUser)) {
Common::saveFriendsCode($cellphone);
Common::initUserData($cellphone, $friends_code);
$shareUrl = "/{$cellphone}/";
$msg = "注册完成,开始收藏你喜欢的视频吧,正在为你跳转到专属网址...";
$code = 1;
}else {
$err = '注册失败,请稍后再试';
}
}else {
$shareUrl = "/{$cellphone}/"; $shareUrl = "/{$cellphone}/";
$msg = "已注册,正在为你跳转到专属网址...";
$code = 1;
} }
$msg = "注册完成,开始收藏你喜欢的视频吧,正在为你跳转到专属网址...";
$code = 1;
} }
} }
@ -503,6 +513,7 @@ eof;
$code = 0; $code = 0;
$msg = ''; $msg = '';
$err = ''; $err = '';
$shareUrl = '';
//用户提交的数据检查 //用户提交的数据检查
$postParams = $this->post(); $postParams = $this->post();
@ -514,18 +525,26 @@ eof;
$err = "请填写注册邀请码、手机号码和短信验证码哦"; $err = "请填写注册邀请码、手机号码和短信验证码哦";
}else if (Common::isCellphoneNumber($cellphone) == false) { }else if (Common::isCellphoneNumber($cellphone) == false) {
$err = "手机号码格式错误,请填写正确的手机号码"; $err = "手机号码格式错误,请填写正确的手机号码";
}else if (Common::getUserDataDir($cellphone) == false) {
$err = "{$cellphone}还没注册哦,先去注册吧";
} }
//TODO: 验证短信验证码是否正确 //TODO: 验证短信验证码是否正确
if (empty($err)) { //如果数据检查通过,尝试登录 if (empty($err)) { //如果数据检查通过,尝试登录
$newUser = Common::saveUserIntoSession($cellphone); $newUser = Common::saveUserIntoSession($cellphone);
$msg = "登录成功,开始收藏你喜欢的视频吧"; if (!empty($newUser)) {
$code = 1; $shareUrl = "/{$cellphone}/";
$msg = "登录成功,开始收藏你喜欢的视频吧";
$code = 1;
}else {
$err = '登录失败,请稍后重试';
}
} }
} }
return $this->renderJson(compact('code', 'msg', 'err')); return $this->renderJson(compact('code', 'msg', 'err', 'shareUrl'));
} }
} }

5
www/js/tajian.js

@ -288,9 +288,12 @@ if ($('#login_form').get(0)) {
}; };
publicAjax(taJian.apis.login, 'POST', datas, function (data) { publicAjax(taJian.apis.login, 'POST', datas, function (data) {
btLoading.addClass('elementNone'); btLoading.addClass('elementNone');
if (data.code == 1) { if (data.code == 1 && data.shareUrl) {
btText.text('完成'); btText.text('完成');
alert(data.msg); alert(data.msg);
setTimeout(function() {
location.href = data.shareUrl;
}, 100);
} else { } else {
btText.text('登录'); btText.text('登录');
bt.prop('disabled', false); bt.prop('disabled', false);

Loading…
Cancel
Save