|  | @@ -33,96 +33,6 @@ class Applet extends Base
 | 
											
												
													
														|  |          return $data;
 |  |          return $data;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    /**
 |  | 
 | 
											
												
													
														|  | -     * 生成用户,返回uid
 |  | 
 | 
											
												
													
														|  | -     *
 |  | 
 | 
											
												
													
														|  | -     * @return int
 |  | 
 | 
											
												
													
														|  | -     */
 |  | 
 | 
											
												
													
														|  | -    private function create($data)
 |  | 
 | 
											
												
													
														|  | -    {
 |  | 
 | 
											
												
													
														|  | -        $uid = false;
 |  | 
 | 
											
												
													
														|  | -        $system = Dever::input('system', 1);
 |  | 
 | 
											
												
													
														|  | -        $info = Dever::load('passport/wechat-one', array('option_openid' => $data['openid']));
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        if (!$info) {
 |  | 
 | 
											
												
													
														|  | -            if (isset($data['unionid']) && $data['unionid']) {
 |  | 
 | 
											
												
													
														|  | -                $info = Dever::load('passport/wechat-one', array('unionid' => $data['unionid']));
 |  | 
 | 
											
												
													
														|  | -                if (!$info) {
 |  | 
 | 
											
												
													
														|  | -                    $uid = false;
 |  | 
 | 
											
												
													
														|  | -                } else {
 |  | 
 | 
											
												
													
														|  | -                    # 判断用户是否存在,是否需要合并
 |  | 
 | 
											
												
													
														|  | -                    $uid = $this->combine($info['uid'], $data['unionid']);
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -                $wechat['unionid'] = $data['unionid'];
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            if (!$uid) {
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -                if (isset($data['username'])) {
 |  | 
 | 
											
												
													
														|  | -                    $user['bind'] = 2;
 |  | 
 | 
											
												
													
														|  | -                    $user['temp'] = 2;
 |  | 
 | 
											
												
													
														|  | -                    $user['username'] = $data['username'];
 |  | 
 | 
											
												
													
														|  | -                    $user['sex'] = $data['sex'];
 |  | 
 | 
											
												
													
														|  | -                    $user['avatar'] = $data['avatar'];
 |  | 
 | 
											
												
													
														|  | -                    $user['city'] = $data['city'];
 |  | 
 | 
											
												
													
														|  | -                    $user['province'] = $data['province'];
 |  | 
 | 
											
												
													
														|  | -                    $user['country'] = $data['country'];
 |  | 
 | 
											
												
													
														|  | -                    if ($user['country'] && $user['province'] && $user['city']) {
 |  | 
 | 
											
												
													
														|  | -                        $user['set_area'] = $user['country'] .','. $user['province'] .','. $user['city'];
 |  | 
 | 
											
												
													
														|  | -                    }
 |  | 
 | 
											
												
													
														|  | -                    $user['source_type'] = 'applet';
 |  | 
 | 
											
												
													
														|  | -                    $user['system_id'] = $system;
 |  | 
 | 
											
												
													
														|  | -                } else {
 |  | 
 | 
											
												
													
														|  | -                    $user['bind'] = 2;
 |  | 
 | 
											
												
													
														|  | -                    $user['temp'] = 1;
 |  | 
 | 
											
												
													
														|  | -                    $user['username'] = '临时用户';
 |  | 
 | 
											
												
													
														|  | -                    $user['source_type'] = 'applet';
 |  | 
 | 
											
												
													
														|  | -                    $user['system_id'] = $system;
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -                
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -                $uid = Dever::load('passport/user-insert', $user);
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -                Dever::load('passport/lib/base')->createUsername($uid, $user['username'], true);
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -             
 |  | 
 | 
											
												
													
														|  | -            $wechat['openid'] = $data['openid'];
 |  | 
 | 
											
												
													
														|  | -            $wechat['session_key'] = $data['session_key'];
 |  | 
 | 
											
												
													
														|  | -            $wechat['uid'] = $uid;
 |  | 
 | 
											
												
													
														|  | -            $wechat['type'] = 1;
 |  | 
 | 
											
												
													
														|  | -            $wechat['system_id'] = $system;
 |  | 
 | 
											
												
													
														|  | -            $id = Dever::load('passport/wechat-insert', $wechat);
 |  | 
 | 
											
												
													
														|  | -        } else {
 |  | 
 | 
											
												
													
														|  | -            $uid = $info['uid'];
 |  | 
 | 
											
												
													
														|  | -            if (isset($data['unionid']) && $data['unionid']) {
 |  | 
 | 
											
												
													
														|  | -                # 判断用户是否存在,是否需要合并
 |  | 
 | 
											
												
													
														|  | -                $wechat['uid'] = $this->combine($uid, $data['unionid']);
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            $id = $info['id'];
 |  | 
 | 
											
												
													
														|  | -            $wechat['session_key'] = $data['session_key'];
 |  | 
 | 
											
												
													
														|  | -            $wechat['where_id'] = $info['id'];
 |  | 
 | 
											
												
													
														|  | -            
 |  | 
 | 
											
												
													
														|  | -            Dever::load('passport/wechat-update', $wechat);
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        $user = Dever::load('passport/user-one', $uid);
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        $result['vid'] = $id;
 |  | 
 | 
											
												
													
														|  | -        $result['uid'] = $uid;
 |  | 
 | 
											
												
													
														|  | -        $result['signature'] = Dever::login($uid);
 |  | 
 | 
											
												
													
														|  | -      
 |  | 
 | 
											
												
													
														|  | -        if ($user['mobile']) {
 |  | 
 | 
											
												
													
														|  | -            $result['mobile'] = $user['mobile'];
 |  | 
 | 
											
												
													
														|  | -        } else {
 |  | 
 | 
											
												
													
														|  | -            if (function_exists('checkVersion')) {
 |  | 
 | 
											
												
													
														|  | -                if (checkVersion()->mobile == 2) {
 |  | 
 | 
											
												
													
														|  | -                    $result['mobile'] = '101010';
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        return $result;
 |  | 
 | 
											
												
													
														|  | -    }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |      /**
 |  |      /**
 | 
											
												
													
														|  |       * 一次性登录:通过code或者openid、sessionkey来注册用户,此时已经授权,可以直接拿到unioinid
 |  |       * 一次性登录:通过code或者openid、sessionkey来注册用户,此时已经授权,可以直接拿到unioinid
 | 
											
												
													
														|  |       *
 |  |       *
 | 
											
										
											
												
													
														|  | @@ -134,7 +44,7 @@ class Applet extends Base
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          $data += $this->getWechatData($data['session_key']);
 |  |          $data += $this->getWechatData($data['session_key']);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        $data['username'] = Dever::emoji(Dever::input('nickname'));
 |  | 
 | 
											
												
													
														|  | 
 |  | +        $data['username'] = Dever::input('nickname');
 | 
											
												
													
														|  |          $data['avatar'] = Dever::input('avatarurl');
 |  |          $data['avatar'] = Dever::input('avatarurl');
 | 
											
												
													
														|  |          $data['sex'] = Dever::input('gender');
 |  |          $data['sex'] = Dever::input('gender');
 | 
											
												
													
														|  |          $data['city'] = Dever::input('city');
 |  |          $data['city'] = Dever::input('city');
 | 
											
										
											
												
													
														|  | @@ -155,7 +65,7 @@ class Applet extends Base
 | 
											
												
													
														|  |      public function update()
 |  |      public function update()
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          $uid = $this->check();
 |  |          $uid = $this->check();
 | 
											
												
													
														|  | -        $name = Dever::emoji(Dever::input('nickname'));
 |  | 
 | 
											
												
													
														|  | 
 |  | +        $name = Dever::input('nickname');
 | 
											
												
													
														|  |          $pic = Dever::input('avatarurl');
 |  |          $pic = Dever::input('avatarurl');
 | 
											
												
													
														|  |          $sex = Dever::input('gender');
 |  |          $sex = Dever::input('gender');
 | 
											
												
													
														|  |          $city = Dever::input('city');
 |  |          $city = Dever::input('city');
 | 
											
										
											
												
													
														|  | @@ -166,29 +76,35 @@ class Applet extends Base
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          $update['temp'] = 3;
 |  |          $update['temp'] = 3;
 | 
											
												
													
														|  |          if ($vid) {
 |  |          if ($vid) {
 | 
											
												
													
														|  | -            $vinfo = Dever::load('passport/wechat-one', $vid);
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -            $data = $this->getWechatData($vinfo['session_key']);
 |  | 
 | 
											
												
													
														|  | 
 |  | +            $key = 'applet_session_key_' . $uid;
 | 
											
												
													
														|  | 
 |  | +            $session_key = Dever::cache($key);
 | 
											
												
													
														|  | 
 |  | +            if (!$cache) {
 | 
											
												
													
														|  | 
 |  | +                $vinfo = Dever::db('passport/wechat')->one($vid);
 | 
											
												
													
														|  | 
 |  | +                $session_key = $vinfo['session_key'];
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            $data = $this->getWechatData($session_key);
 | 
											
												
													
														|  |              $unionid = $data['unionid'];
 |  |              $unionid = $data['unionid'];
 | 
											
												
													
														|  |              if ($unionid) {
 |  |              if ($unionid) {
 | 
											
												
													
														|  | -                $vinfo = Dever::load('passport/wechat-one', array('option_unionid' => $unionid));
 |  | 
 | 
											
												
													
														|  | 
 |  | +                $vinfo = Dever::db('passport/wechat')->one(array('option_unionid' => $unionid));
 | 
											
												
													
														|  |                  if (!$vinfo) {
 |  |                  if (!$vinfo) {
 | 
											
												
													
														|  |                      $wechat['set_unionid'] = $unionid;
 |  |                      $wechat['set_unionid'] = $unionid;
 | 
											
												
													
														|  |                      $wechat['where_id'] = $vid;
 |  |                      $wechat['where_id'] = $vid;
 | 
											
												
													
														|  | -                    Dever::load('passport/wechat-update', $wechat);
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    Dever::db('passport/wechat')->update($wechat);
 | 
											
												
													
														|  |                  } elseif ($vinfo && $vinfo['id'] != $vid) {
 |  |                  } elseif ($vinfo && $vinfo['id'] != $vid) {
 | 
											
												
													
														|  |                      $wechat['set_unionid'] = $unionid;
 |  |                      $wechat['set_unionid'] = $unionid;
 | 
											
												
													
														|  |                      $uid = $this->combine($uid, $unionid);
 |  |                      $uid = $this->combine($uid, $unionid);
 | 
											
												
													
														|  |                      $wechat['set_uid'] = $uid;
 |  |                      $wechat['set_uid'] = $uid;
 | 
											
												
													
														|  |                      $wechat['where_id'] = $vid;
 |  |                      $wechat['where_id'] = $vid;
 | 
											
												
													
														|  | -                    Dever::load('passport/wechat-update', $wechat);
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    Dever::db('passport/wechat')->update($wechat);
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |                  
 |  |                  
 | 
											
												
													
														|  |                  $update['temp'] = 2;
 |  |                  $update['temp'] = 2;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        $info = Dever::load('passport/user-one', $uid);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        $info = Dever::db('passport/user')->one($uid);
 | 
											
												
													
														|  |          if ($info) {
 |  |          if ($info) {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |              if ($info['temp'] == 1) {
 |  |              if ($info['temp'] == 1) {
 | 
											
										
											
												
													
														|  | @@ -196,7 +112,7 @@ class Applet extends Base
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              $update['temp'] = 2;
 |  |              $update['temp'] = 2;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -            $update['set_username'] = Dever::load('passport/lib/base')->createUsername($uid, $name);
 |  | 
 | 
											
												
													
														|  | 
 |  | +            $update['set_username'] = $this->createUsername($uid, $name);
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  |              if ($sex == 1) {
 |  |              if ($sex == 1) {
 | 
											
												
													
														|  |                  $update['set_sex'] = 1;
 |  |                  $update['set_sex'] = 1;
 | 
											
										
											
												
													
														|  | @@ -219,8 +135,7 @@ class Applet extends Base
 | 
											
												
													
														|  |              if ($city) {
 |  |              if ($city) {
 | 
											
												
													
														|  |                  $update['set_city'] = $city;
 |  |                  $update['set_city'] = $city;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  | -            
 |  | 
 | 
											
												
													
														|  | -            //$update['set_mobile'] = $mobile;
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |              if ($province) {
 |  |              if ($province) {
 | 
											
												
													
														|  |                  $update['set_province'] = $province;
 |  |                  $update['set_province'] = $province;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
										
											
												
													
														|  | @@ -234,7 +149,7 @@ class Applet extends Base
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              if (isset($update) && $update) {
 |  |              if (isset($update) && $update) {
 | 
											
												
													
														|  |                  $update['where_id'] = $uid;
 |  |                  $update['where_id'] = $uid;
 | 
											
												
													
														|  | -                Dever::load('passport/user-update', $update);
 |  | 
 | 
											
												
													
														|  | 
 |  | +                Dever::db('passport/user')->update($update);
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  |          } else {
 |  |          } else {
 | 
											
										
											
												
													
														|  | @@ -264,8 +179,14 @@ class Applet extends Base
 | 
											
												
													
														|  |          $encryptedData = Dever::input('encryptedData');
 |  |          $encryptedData = Dever::input('encryptedData');
 | 
											
												
													
														|  |          
 |  |          
 | 
											
												
													
														|  |          if ($iv && $encryptedData) {
 |  |          if ($iv && $encryptedData) {
 | 
											
												
													
														|  | -            $vinfo = Dever::load('passport/wechat-one', $vid);
 |  | 
 | 
											
												
													
														|  | -            $data = $this->getWechatData($vinfo['session_key']);
 |  | 
 | 
											
												
													
														|  | 
 |  | +            $key = 'applet_session_key_' . $uid;
 | 
											
												
													
														|  | 
 |  | +            $session_key = Dever::cache($key);
 | 
											
												
													
														|  | 
 |  | +            if (!$cache) {
 | 
											
												
													
														|  | 
 |  | +                $vinfo = Dever::db('passport/wechat')->one($vid);
 | 
											
												
													
														|  | 
 |  | +                $session_key = $vinfo['session_key'];
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            
 | 
											
												
													
														|  | 
 |  | +            $data = $this->getWechatData($session_key);
 | 
											
												
													
														|  |              if ($data && $data['mobile']) {
 |  |              if ($data && $data['mobile']) {
 | 
											
												
													
														|  |                  $mobile = $data['mobile'];
 |  |                  $mobile = $data['mobile'];
 | 
											
												
													
														|  |                  $phoneNumber = $data['phone'];
 |  |                  $phoneNumber = $data['phone'];
 | 
											
										
											
												
													
														|  | @@ -297,8 +218,6 @@ class Applet extends Base
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |          $result['vid'] = $vid;
 |  |          $result['vid'] = $vid;
 | 
											
												
													
														|  |          $result['uid'] = $uid;
 |  |          $result['uid'] = $uid;
 | 
											
												
													
														|  |          $result['signature'] = Dever::login($uid);
 |  |          $result['signature'] = Dever::login($uid);
 | 
											
										
											
												
													
														|  | @@ -306,6 +225,100 @@ class Applet extends Base
 | 
											
												
													
														|  |          return $result;
 |  |          return $result;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    /**
 | 
											
												
													
														|  | 
 |  | +     * 生成用户,返回uid
 | 
											
												
													
														|  | 
 |  | +     *
 | 
											
												
													
														|  | 
 |  | +     * @return int
 | 
											
												
													
														|  | 
 |  | +     */
 | 
											
												
													
														|  | 
 |  | +    private function create($data)
 | 
											
												
													
														|  | 
 |  | +    {
 | 
											
												
													
														|  | 
 |  | +        $uid = false;
 | 
											
												
													
														|  | 
 |  | +        $system = Dever::input('system', 1);
 | 
											
												
													
														|  | 
 |  | +        $info = Dever::db('passport/wechat')->one(array('option_openid' => $data['openid']));
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        $key = 'applet_session_key_' . $uid;
 | 
											
												
													
														|  | 
 |  | +        $cache = Dever::cache($key, $data['session_key']);
 | 
											
												
													
														|  | 
 |  | +        $wechat = array();
 | 
											
												
													
														|  | 
 |  | +        if (!$info) {
 | 
											
												
													
														|  | 
 |  | +            if (isset($data['unionid']) && $data['unionid']) {
 | 
											
												
													
														|  | 
 |  | +                $info = Dever::db('passport/wechat')->one(array('unionid' => $data['unionid']));
 | 
											
												
													
														|  | 
 |  | +                if (!$info) {
 | 
											
												
													
														|  | 
 |  | +                    $uid = false;
 | 
											
												
													
														|  | 
 |  | +                } else {
 | 
											
												
													
														|  | 
 |  | +                    # 判断用户是否存在,是否需要合并
 | 
											
												
													
														|  | 
 |  | +                    $uid = $this->combine($info['uid'], $data['unionid']);
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +                $wechat['unionid'] = $data['unionid'];
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            if (!$uid) {
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +                $user['source_type'] = 'applet';
 | 
											
												
													
														|  | 
 |  | +                $user['system_id'] = $system;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +                if (isset($data['username'])) {
 | 
											
												
													
														|  | 
 |  | +                    $user['bind'] = 2;
 | 
											
												
													
														|  | 
 |  | +                    $user['temp'] = 2;
 | 
											
												
													
														|  | 
 |  | +                    $user['username'] = $data['username'];
 | 
											
												
													
														|  | 
 |  | +                    $user['sex'] = $data['sex'];
 | 
											
												
													
														|  | 
 |  | +                    $user['avatar'] = $data['avatar'];
 | 
											
												
													
														|  | 
 |  | +                    $user['city'] = $data['city'];
 | 
											
												
													
														|  | 
 |  | +                    $user['province'] = $data['province'];
 | 
											
												
													
														|  | 
 |  | +                    $user['country'] = $data['country'];
 | 
											
												
													
														|  | 
 |  | +                    if ($user['country'] && $user['province'] && $user['city']) {
 | 
											
												
													
														|  | 
 |  | +                        $user['set_area'] = $user['country'] .','. $user['province'] .','. $user['city'];
 | 
											
												
													
														|  | 
 |  | +                    }
 | 
											
												
													
														|  | 
 |  | +                } else {
 | 
											
												
													
														|  | 
 |  | +                    $user['bind'] = 2;
 | 
											
												
													
														|  | 
 |  | +                    $user['temp'] = 1;
 | 
											
												
													
														|  | 
 |  | +                    $user['username'] = '临时用户';
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +                $uid = Dever::db('passport/user')->insert($user);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +                $this->createUsername($uid, $user['username'], true);
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +             
 | 
											
												
													
														|  | 
 |  | +            $wechat['openid'] = $data['openid'];
 | 
											
												
													
														|  | 
 |  | +            $wechat['session_key'] = $data['session_key'];
 | 
											
												
													
														|  | 
 |  | +            $wechat['uid'] = $uid;
 | 
											
												
													
														|  | 
 |  | +            $wechat['type'] = 1;
 | 
											
												
													
														|  | 
 |  | +            $wechat['system_id'] = $system;
 | 
											
												
													
														|  | 
 |  | +            $id = Dever::db('passport/wechat')->insert($wechat);
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            $uid = $info['uid'];
 | 
											
												
													
														|  | 
 |  | +            $id = $info['id'];
 | 
											
												
													
														|  | 
 |  | +            if (isset($data['unionid']) && $data['unionid']) {
 | 
											
												
													
														|  | 
 |  | +                # 判断用户是否存在,是否需要合并
 | 
											
												
													
														|  | 
 |  | +                $wechat['uid'] = $this->combine($uid, $data['unionid']);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +                if ($wechat['uid'] != $uid) {
 | 
											
												
													
														|  | 
 |  | +                    $uid = $wechat['uid'];
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            if (!$cache) {
 | 
											
												
													
														|  | 
 |  | +                $wechat['session_key'] = $data['session_key'];
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            if ($wechat) {
 | 
											
												
													
														|  | 
 |  | +                $wechat['where_id'] = $info['id'];
 | 
											
												
													
														|  | 
 |  | +                Dever::db('passport/wechat')->update($wechat);
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        $user = Dever::db('passport/user')->one($uid);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        $result['vid'] = $id;
 | 
											
												
													
														|  | 
 |  | +        $result['uid'] = $uid;
 | 
											
												
													
														|  | 
 |  | +        $result['signature'] = Dever::login($uid);
 | 
											
												
													
														|  | 
 |  | +      
 | 
											
												
													
														|  | 
 |  | +        if ($user['mobile']) {
 | 
											
												
													
														|  | 
 |  | +            $result['mobile'] = $user['mobile'];
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        return $result;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      private function unionid($session_key)
 |  |      private function unionid($session_key)
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          $data = $this->decryptData($session_key);
 |  |          $data = $this->decryptData($session_key);
 | 
											
										
											
												
													
														|  | @@ -386,21 +399,20 @@ class Applet extends Base
 | 
											
												
													
														|  |      private function getApplet()
 |  |      private function getApplet()
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          $applet = Dever::config('base', 'project')->applet;
 |  |          $applet = Dever::config('base', 'project')->applet;
 | 
											
												
													
														|  | -        $project = false;
 |  | 
 | 
											
												
													
														|  | -        $system = Dever::input('system', 1);
 |  | 
 | 
											
												
													
														|  |          if (Dever::project('token')) {
 |  |          if (Dever::project('token')) {
 | 
											
												
													
														|  | 
 |  | +            $system = Dever::input('system', 1);
 | 
											
												
													
														|  |              $project = Dever::db('token/project')->one($system);
 |  |              $project = Dever::db('token/project')->one($system);
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        if (!$project) {
 |  | 
 | 
											
												
													
														|  | -            if (isset($applet['project']) && $applet['project']) {
 |  | 
 | 
											
												
													
														|  | -                $project = Dever::db($applet['project'])->one($system);
 |  | 
 | 
											
												
													
														|  | 
 |  | +            if (!$project) {
 | 
											
												
													
														|  | 
 |  | +                if (isset($config['project']) && $config['project']) {
 | 
											
												
													
														|  | 
 |  | +                    $project = Dever::db($config['project'])->one($system);
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        if ($project) {
 |  | 
 | 
											
												
													
														|  | -            $applet['appid'] = $project['appid'];
 |  | 
 | 
											
												
													
														|  | -            $applet['secret'] = $project['secret'];
 |  | 
 | 
											
												
													
														|  | 
 |  | +            if ($project) {
 | 
											
												
													
														|  | 
 |  | +                $applet['appid'] = $project['appid'];
 | 
											
												
													
														|  | 
 |  | +                $applet['secret'] = $project['secret'];
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          if (!$applet || !$applet['appid'] || !$applet['secret']) {
 |  |          if (!$applet || !$applet['appid'] || !$applet['secret']) {
 |