|
@@ -3,13 +3,15 @@
|
|
|
namespace app\mobile\controller;
|
|
|
|
|
|
use app\common\model\User;
|
|
|
-use app\common\model\UserAuths;
|
|
|
+use app\common\model\UserAuths as UserAuthsModel;
|
|
|
use app\common\model\Sinpage as SinpageModel;
|
|
|
use app\common\model\User as UserModel;
|
|
|
use app\common\model\RensheCode as RensheCodeModel;
|
|
|
use app\common\model\ComjobsCate as ComjobsCateModel;
|
|
|
use app\common\model\UserWill as UserWillModel;
|
|
|
use app\common\model\Worker as WorkerModel;
|
|
|
+use app\common\service\SmsService;
|
|
|
+use think\facade\Session;
|
|
|
|
|
|
class Login
|
|
|
{
|
|
@@ -36,23 +38,13 @@ class Login
|
|
|
$open_id = $param['openid'];
|
|
|
|
|
|
//登录
|
|
|
- $auth = UserAuths::where(['identitytype' => 'weixin', 'identifier' => $open_id])->find();
|
|
|
+ $auth = UserAuthsModel::where(['identitytype' => 'weixin', 'identifier' => $open_id])->find();
|
|
|
if (empty($auth)) {
|
|
|
- $user = User::create([
|
|
|
- 'username' => $param['nickname'],
|
|
|
- 'avatar' => $param['headimgurl'],
|
|
|
- 'emp_time' => [],
|
|
|
- 'user_tags' => [],
|
|
|
- 'com_cate' => [],
|
|
|
- 'work_place' => [],
|
|
|
- ]);
|
|
|
- $auth = UserAuths::create([
|
|
|
- 'userid' => $user['id'],
|
|
|
- 'identitytype' => 'weixin',
|
|
|
- 'identifier' => $open_id,
|
|
|
- 'logintime' => time(),
|
|
|
- 'loginip' => request()->ip(),
|
|
|
- ]);
|
|
|
+ session('user.open_id', $open_id);
|
|
|
+ session('user.nickname', $param['nickname']);
|
|
|
+ session('user.headimgurl', $param['headimgurl']);
|
|
|
+
|
|
|
+ my_redirect('/login/mobile');
|
|
|
} else {
|
|
|
$auth->logintime = time();
|
|
|
$auth->loginip = request()->ip();
|
|
@@ -168,6 +160,97 @@ class Login
|
|
|
page_result(0, '操作成功');
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 手机登录
|
|
|
+ */
|
|
|
+ public function mobile()
|
|
|
+ {
|
|
|
+ return view('login/mobile');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function mobilePost()
|
|
|
+ {
|
|
|
+ $mobile = input('mobile/s', '');
|
|
|
+ $verify = input('verify/s', '');
|
|
|
+
|
|
|
+ $session_verify = session('verify');
|
|
|
+ if ($verify != $session_verify) {
|
|
|
+ page_result(1, '验证码错误!');
|
|
|
+ }
|
|
|
+
|
|
|
+ $auth = UserAuthsModel::where(['identitytype' => 'mobile', 'identifier' => $mobile])->find();
|
|
|
+ if (empty($auth)) {
|
|
|
+ $open_id = session('user.open_id');
|
|
|
+ $nickname = session('user.nickname');
|
|
|
+ $headimgurl = session('user.headimgurl');
|
|
|
+ $user = User::create([
|
|
|
+ 'nickname' => $nickname,
|
|
|
+ 'avatar' => $headimgurl ?? '',
|
|
|
+ 'mobile' => $mobile,
|
|
|
+ 'groupsid' => 7,
|
|
|
+ 'education' => 7,
|
|
|
+ 'emp_time' => [],
|
|
|
+ 'user_tags' => [],
|
|
|
+ 'com_cate' => [],
|
|
|
+ 'work_place' => [],
|
|
|
+ 'createtime' => time(),
|
|
|
+ ]);
|
|
|
+ $auth = UserAuthsModel::create([
|
|
|
+ 'userid' => $user['id'],
|
|
|
+ 'identitytype' => 'weixin',
|
|
|
+ 'identifier' => $open_id,
|
|
|
+ 'logintime' => time(),
|
|
|
+ 'loginip' => request()->ip(),
|
|
|
+ ]);
|
|
|
+ UserAuthsModel::create([
|
|
|
+ 'userid' => $user['id'],
|
|
|
+ 'identitytype' => 'mobile',
|
|
|
+ 'identifier' => $mobile,
|
|
|
+ 'logintime' => time(),
|
|
|
+ 'loginip' => request()->ip(),
|
|
|
+ ]);
|
|
|
+ } else {
|
|
|
+ $auth->logintime = time();
|
|
|
+ $auth->loginip = request()->ip();
|
|
|
+ $auth->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ session('user.id', $auth['userid']);
|
|
|
+
|
|
|
+ page_result();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function sendSms()
|
|
|
+ {
|
|
|
+ Session::delete('verify');
|
|
|
+
|
|
|
+ $rand = rand(100000, 999999);
|
|
|
+ $mobile = trim(input('post.mobile'));
|
|
|
+ $preg_phone = '/^1[34578]\d{9}$/ims';
|
|
|
+
|
|
|
+ $rtn = [];
|
|
|
+
|
|
|
+ if (!$mobile) {
|
|
|
+ page_result(1, '手机号为空');
|
|
|
+ } else {
|
|
|
+ if (preg_match($preg_phone, $mobile)) {
|
|
|
+ $sms = new SmsService();
|
|
|
+ $res = $sms->send($mobile, 'verification', [$rand]);
|
|
|
+
|
|
|
+ if ($res['code'] == 0) {
|
|
|
+ $rtn['code'] = 0;
|
|
|
+ Session::set('verify', $rand);
|
|
|
+ } else {
|
|
|
+ page_result(1, '网络故障,请重试');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ page_result(1, '手机号格式不正确');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ page_result();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 雇主注册
|
|
|
*/
|