diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 792de4684c46af3252345edf62256a397b79c3c9..8885e1a527f849f21956af816f4131bd753b7555 100755 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -124,7 +124,7 @@ class User extends Common } // 先从数据库获取用户信息 - $user = UserService::AppUserInfoHandle('alipay_openid', $this->data_post['openid']); + $user = UserService::AppUserInfoHandle(null, 'alipay_openid', $this->data_post['openid']); if(empty($user)) { $this->data_post['nick_name'] = isset($this->data_post['nickName']) ? $this->data_post['nickName'] : ''; @@ -196,7 +196,7 @@ class User extends Common } // 先从数据库获取用户信息 - $user = UserService::AppUserInfoHandle('weixin_openid', $this->data_post['openid']); + $user = UserService::AppUserInfoHandle(null, 'weixin_openid', $this->data_post['openid']); if(empty($user)) { $result = (new \base\Wechat(MyC('common_app_mini_weixin_appid'), MyC('common_app_mini_weixin_appsecret')))->DecryptData($this->data_post['encrypted_data'], $this->data_post['iv'], $this->data_post['openid']); diff --git a/application/service/UserService.php b/application/service/UserService.php index 0a05032b2b7653f5c34a0818267d9a198a483197..f78e13c914e530d36e2b2076d1850644a429fb53 100755 --- a/application/service/UserService.php +++ b/application/service/UserService.php @@ -1596,11 +1596,10 @@ class UserService 'city' => empty($params['city']) ? '' : $params['city'], 'referrer' => isset($params['referrer']) ? $params['referrer'] : 0, ]; - $select_field = 'id,username,nickname,mobile,email,avatar'; - $user = self::UserInfo($field, $params['openid'], $select_field); + $user = self::AppUserInfoHandle(null, $field, $params['openid']); if(!empty($user)) { - $data = $user; + return DataReturn('授权成功', 0, $user); } else { // 不强制绑定手机则写入用户信息 if(intval(MyC('common_user_is_mandatory_bind_mobile')) != 1) @@ -1608,15 +1607,13 @@ class UserService $ret = self::UserInsert($data, $params); if($ret['code'] == 0) { - $data = self::UserInfo('id', $ret['data']['user_id'], $select_field); + return DataReturn('授权成功', 0, self::AppUserInfoHandle($ret['data']['user_id'])); } else { return $ret; } } } - - // 返回成功 - return DataReturn('授权成功', 0, self::AppUserInfoHandle(null, null, $data)); + return DataReturn('授权成功', 0, self::AppUserInfoHandle(null, null, null, $data)); } /** @@ -1626,16 +1623,21 @@ class UserService * @version 1.0.0 * @date 2018-11-06 * @desc description + * @param [int] $user_id [指定用户id] * @param [string] $where_field [字段名称] * @param [string] $where_value [字段值] * @param [array] $user [用户信息] */ - public static function AppUserInfoHandle($where_field = null, $where_value = null, $user = []) + public static function AppUserInfoHandle($user_id = null, $where_field = null, $where_value = null, $user = []) { // 获取用户信息 - if(!empty($where_field) && !empty($where_value) && empty($user)) + $field = 'id,username,nickname,mobile,email,avatar'; + if(!empty($user_id)) { - $user = self::UserInfo($where_field, $where_value, 'id,username,nickname,mobile,email,avatar'); + $user = self::UserInfo('id', $user_id, $field); + } elseif(!empty($where_field) && !empty($where_value) && empty($user)) + { + $user = self::UserInfo($where_field, $where_value, $field); } if(!empty($user)) @@ -1884,7 +1886,10 @@ class UserService // 清除验证码 $obj->Remove(); - return DataReturn('绑定成功', 0, self::UserLoginRecord($user_id, true)); + // 用户登录纪录处理 + self::UserLoginRecord($user_id, true) + + return DataReturn('绑定成功', 0, self::AppUserInfoHandle($user_id)); } else { return DataReturn('绑定失败', -100); } diff --git a/public/appmini/old/alipay/pages/login/login.js b/public/appmini/old/alipay/pages/login/login.js index 3936d7d7cf3a57a32a59b8752c82dc023c54a5ea..bb75571574e1230a566c544292dbb4c792ee38b4 100644 --- a/public/appmini/old/alipay/pages/login/login.js +++ b/public/appmini/old/alipay/pages/login/login.js @@ -135,7 +135,7 @@ Page({ formSubmit(e) { // 邀请人参数 - var params = my.getStorageSync({key: this.data.cache_launch_info_key}); + var params = my.getStorageSync({key: app.data.cache_launch_info_key}); // 数据验证 var validation = [ diff --git a/public/appmini/old/weixin/app.js b/public/appmini/old/weixin/app.js index d9d7b71dd9b1879b5db6cb9d85022c48d14053ba..79cf57fbffce841efdec17c8a30392bdf3309b3c 100755 --- a/public/appmini/old/weixin/app.js +++ b/public/appmini/old/weixin/app.js @@ -132,11 +132,11 @@ App({ * 获取设备信息 */ get_system_info() { - let system_info = wx.getStorageSync(this.data.cache_system_info_key); - if ((system_info.data || null) == null) { + let system_info = wx.getStorageSync(this.data.cache_system_info_key) || null; + if (system_info == null) { return this.set_system_info(); } - return system_info.data; + return system_info; }, /** @@ -182,8 +182,8 @@ App({ * 从缓存获取用户信息 */ get_user_cache_info() { - let user = wx.getStorageSync(this.data.cache_user_info_key); - if ((user || null) == null) { + let user = wx.getStorageSync(this.data.cache_user_info_key) || null; + if (user == null) { return false; } return user; @@ -200,8 +200,8 @@ App({ var $this = this; wx.checkSession({ success: function () { - var openid = wx.getStorageSync($this.data.cache_user_login_key); - if ((openid || null) == null) + var openid = wx.getStorageSync($this.data.cache_user_login_key) || null; + if (openid == null) { $this.user_login(object, method, auth_data); } else { @@ -266,8 +266,8 @@ App({ */ get_user_login_info(object, method, openid, auth_data) { // 邀请人参数 - var params = wx.getStorageSync(this.data.cache_launch_info_key); - var referrer = (params.data == null) ? 0 : (params.data.referrer || 0); + var params = wx.getStorageSync(this.data.cache_launch_info_key) || null; + var referrer = (params == null) ? 0 : (params.data.referrer || 0); // 远程解密数据 var $this = this; diff --git a/public/appmini/old/weixin/pages/login/login.js b/public/appmini/old/weixin/pages/login/login.js index df0981f7d75386aaff37cc4a892f75a6cac15af9..851e9273ad958fe67edf5c267622dd661712c02e 100755 --- a/public/appmini/old/weixin/pages/login/login.js +++ b/public/appmini/old/weixin/pages/login/login.js @@ -135,8 +135,8 @@ Page({ formSubmit(e) { // 邀请人参数 - var params = wx.getStorageSync(this.data.cache_launch_info_key); - + var params = wx.getStorageSync(app.data.cache_launch_info_key) || null; + console.log(params) // 数据验证 var validation = [ {fields: 'mobile', msg: '请填写手机号码'}, @@ -150,7 +150,7 @@ Page({ e.detail.value['city'] = this.data.user.city; e.detail.value['gender'] = this.data.user.gender; e.detail.value['app_type'] = 'weixin'; - e.detail.value['referrer'] = (params.data == null) ? (this.data.user.referrer || 0) : (params.data.referrer || 0); + e.detail.value['referrer'] = (params == null) ? (this.data.user.referrer || 0) : (params.data.referrer || 0); if(app.fields_check(e.detail.value, validation)) { wx.showLoading({title: '处理中...'});