Exemplo n.º 1
0
 /**
  * 验证表单
  * */
 public function actiongetlogin()
 {
     $ret = array('status' => 1, 'msg' => '', 'data' => 10);
     try {
         $unmae = trim(urldecode(Yii::app()->request->getParam("unmae")));
         $upwo = Yii::app()->request->getParam('upwo');
         $code = Yii::app()->request->getParam('code');
         if (!$this->login_type && $code != $_SESSION['Checknum']) {
             $ret['data'] = 1;
             //验证码错误
             throw new Exception('验证码错误');
         }
         $ret = permission::userLogin($unmae, $upwo);
         if ($this->login_type) {
             //C# 软件登录
             $ret['msg'] = $ret['data'];
             $ret['data'] = array();
             if ($ret['msg'] == 4) {
                 //获取用户访问权限
                 $user = WebUser::getusersById($_SESSION['user_id']);
                 if ($user['status'] == 0) {
                     throw new Exception(2);
                 }
                 if (empty($user['data']->touchid)) {
                     throw new Exception(6);
                 }
                 $touch_arr = json_decode($user['data']->touchid, true);
                 //用户绑定的搭配屏
                 $touch_ret = Touch::touchSelectById($touch_arr[0]);
                 //根据搭配屏获取品牌
                 if ($touch_ret['status'] == 0 || empty($touch_ret['data']['brandid'])) {
                     throw new Exception(6);
                 }
                 try {
                     $brand_ret = Brand::brandSelectById($touch_ret['data']['brandid']);
                     if (count($brand_ret) == 0) {
                         throw new Exception('');
                     }
                     $qiniu = new erp_qiniu();
                     //七牛的接口类
                     $brand_qiniu_account = $qiniu->getAccountByBrand($touch_ret['data']['brandid']);
                     //获取品牌的七牛子账号信息
                     if (count($brand_qiniu_account) == 0) {
                         throw new Exception('品牌暂未绑定七牛帐号');
                     }
                     $ret['data']['domain'] = $brand_qiniu_account[0]['domain'];
                     $ret['data']['brandname'] = $brand_ret[0]['name'];
                     $ret['data']['erpak'] = empty($brand_ret[0]['erpak']) ? '' : $brand_ret[0]['erpak'];
                     $ret['data']['erpsk'] = empty($brand_ret[0]['erpsk']) ? '' : $brand_ret[0]['erpsk'];
                     $ret['data']['code_start'] = $brand_ret[0]['code_start'];
                     $ret['data']['code_end'] = $brand_ret[0]['code_end'];
                 } catch (Exception $e) {
                     throw new Exception(6);
                 }
                 $ret['data']['brandid'] = $touch_ret['data']['brandid'];
                 $ret['data']['type'] = $_SESSION['type'];
             }
         } else {
             $ret['href'] = '/erp/manage';
         }
         $ret['status'] = 1;
     } catch (Exception $e) {
         $ret['mag'] = $e->getMessage();
     }
     echo json_encode($ret);
 }