Example #1
0
 private function init()
 {
     $apiUser = new api_userMod();
     $cur_action = $_GET['_action'];
     if ($cur_action != 'suss') {
         if (isset($_GET['code'])) {
             $code = $this->in_get('code', None, 2, 'True');
             $flag = $apiUser->login($code);
             if ($flag) {
                 $this->p_id = $flag;
             } else {
                 # 此用户没注册,跳转到注册页面
                 $this->redirect(__ROOT__ . '/register');
             }
         } else {
             $check_res = $apiUser->check_login_normal();
             if (!$check_res) {
                 ##################
                 echo "cookie 已过期需要重新登陆";
                 $this->redirect(__ROOT__ . '/index');
                 exit;
             } else {
                 $this->p_id = $check_res;
             }
         }
         $this->apiUser = $apiUser;
     }
 }
Example #2
0
 public function reg()
 {
     $state = $this->in_get('state', None, 2, 'True');
     $wx_data = base64_decode($state);
     $code = $this->in_get('code', None, 2, 'True');
     $wx_data_arr = explode('@@', $wx_data);
     $schId = intval($wx_data_arr[0]);
     $room = in($wx_data_arr[1]);
     $phone = in($wx_data_arr[2]);
     $msg = Check::rule(array(check::mobile($phone), '手机电话号码格式不对'));
     if ($msg != 1) {
         $this->alert('您的手机号码不正确');
     }
     $r = connectRedis($this->config['RD_HOST'], $this->config['RD_PORT'], $this->config['RD_PWD']);
     $apiUser = new api_userMod();
     $wx_res = $apiUser->get_info_user_weixin($code, $r);
     if (!$wx_res) {
         $this->alert('请用微信登陆');
     }
     $check_con['openid'] = $wx_res['openid'];
     $field = 'p_id';
     $check_res = $this->model->table($this->config['info_person'])->field($field)->where($check_con)->find();
     if ($check_res) {
         // 如果此微信号已经存在,直接登陆
         $apiUser->set_login_mark($check_res['p_id'], $code, $r);
         disconnect($r);
         $this->redirect(__ROOT__ . '/order/water');
     } else {
         // 否则插入数据
         $data['s_id'] = $schId;
         $res = $this->model->table($this->config['school'])->where($data)->find();
         if ($res) {
             $data['name'] = $wx_res['nickname'];
             $data['addr'] = $room;
             $data['phone'] = $phone;
             $data['openid'] = $wx_res['openid'];
             $data['pic'] = $wx_res['headimgurl'];
             $data['s_name'] = $res['name'];
             $data['sex'] = $wx_res['sex'];
             $data['city'] = $wx_res['city'];
             $data['province'] = $wx_res['province'];
             $data['point'] = 100;
             $res = $this->model->table($this->config['info_person'])->data($data)->insert();
             if ($res) {
                 $apiUser->set_login_mark($res, $code, $r);
                 disconnect($r);
                 setcookie('susCode', time(), time() + EX_TIME_COOKIE, __ROOT__);
                 $this->redirect(__URL__ . '/suss');
             } else {
                 disconnect($r);
                 $this->alert('对不起,网络暂时出了点小问题');
             }
         } else {
             disconnect($r);
             $this->alert('对不起,贵校暂时没有开通此服务');
         }
     }
 }
Example #3
0
 public function index()
 {
     $code = $this->in_get('code', '', 2, 'True');
     $apiUser = new api_userMod();
     $res = $apiUser->login($code);
     if ($res) {
         $this->redirect(__ROOT__ . '/order/water');
     } else {
         $this->redirect(__ROOT__ . '/register');
     }
 }
Example #4
0
 public function history()
 {
     $apiUser = new api_userMod();
     $p_id = $this->in_cookie('pId', None, 1, 'True');
     // 获取用户订单信息
     $url = __URL__ . '/history?p={page}';
     $info = $apiUser->get_info_order_mysql($p_id, $url);
     if ($info) {
         $this->assign("info", $info['data']);
         $this->assign("page", $info['page']);
     } else {
         $info = '';
     }
     $this->display('person/history');
 }