Ejemplo n.º 1
0
 public function actionLogin()
 {
     $data = array();
     $params = Yii::$app->request->getBodyParams();
     if (isset($params['acc_device_token'])) {
         $devisetoken = $params['acc_device_token'];
     } else {
         $devisetoken = "";
     }
     $sms = new Sms();
     $vcode = $sms->checkVerifyCode($params['mobile'], $params['code'])['error'];
     if ($vcode == 0) {
         $userdata = Accounts::get_user_by_mobile($params['mobile']);
         if (empty($userdata)) {
             $access_token = Yii::$app->security->generateRandomString();
             $this->userReg($params['mobile'], $devisetoken, $access_token);
             $userdata = Accounts::get_user_by_mobile($params['mobile']);
             if (!$userdata) {
                 return Message::say(Message::E_ERROR, null, "登录错误");
             }
         }
         return Message::say(Message::E_OK, $userdata, "登录成功");
     } else {
         return Message::say(Message::E_ERROR, null, "验证码错误");
     }
 }