diff --git a/application/api/controller/User.php b/application/api/controller/User.php index a13ac3c80..74cbcd6b3 100755 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -544,10 +544,6 @@ class User extends Common 'avatar' => $this->user['avatar'], 'nickname' => $this->user['nickname'], 'username' => $this->user['username'], - // 'customer_service_tel' => MyC('common_app_customer_service_tel', null, true), - // 'common_user_center_notice' => MyC('common_user_center_notice', null, true), - // 'common_app_is_online_service' => (int) MyC('common_app_is_online_service', 0), - // 'common_app_is_head_vice_nav' => (int) MyC('common_app_is_head_vice_nav', 0), 'user_order_status' => $user_order_status['data'], 'user_order_count' => $user_order_count, 'user_goods_favor_count' => $user_goods_favor_count, @@ -557,15 +553,75 @@ class User extends Common 'common_cart_total' => BuyService::UserCartTotal(['user'=>$this->user]), ); - // 支付宝小程序在线客服 - // if(APPLICATION_CLIENT_TYPE == 'alipay') - // { - // $result['common_app_mini_alipay_tnt_inst_id'] = MyC('common_app_mini_alipay_tnt_inst_id', null, true); - // $result['common_app_mini_alipay_scene'] = MyC('common_app_mini_alipay_scene', null, true); - // } - // 返回数据 return DataReturn('success', 0, $result); } + + /** + * 百度小程序用户手机绑定 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-09-20 + * @desc description + */ + public function BaiduUserMobileBind() + { + // 参数校验 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'openid', + 'error_msg' => 'openid为空', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'encrypted_data', + 'error_msg' => '解密数据为空', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'iv', + 'error_msg' => 'iv为空,请重试', + ] + ]; + $ret = ParamsChecked($this->data_post, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 先从数据库获取用户信息 + $user = UserService::AppUserInfoHandle(null, 'baidu_openid', $this->data_post['openid']); + if(empty($user)) + { + $config = [ + 'appid' => MyC('common_app_mini_baidu_appid'), + 'key' => MyC('common_app_mini_baidu_appkey'), + 'secret' => MyC('common_app_mini_baidu_appsecret'), + ]; + $result = (new \base\Baidu($config))->DecryptData($this->data_post['encrypted_data'], $this->data_post['iv'], $this->data_post['openid'], 'mobile_bind'); + if($result['status'] == 0 && !empty($result['data'])) + { + $data = [ + 'openid' => $this->data_post['openid'], + 'mobile' => $result['data']['mobile'], + 'nickname' => isset($this->data_post['nickname']) ? $this->data_post['nickname'] : '', + 'avatar' => isset($this->data_post['avatar']) ? $this->data_post['avatar'] : '', + 'province' => isset($this->data_post['province']) ? $this->data_post['province'] : '', + 'city' => isset($this->data_post['city']) ? $this->data_post['city'] : '', + 'gender' => isset($this->data_post['gender']) ? intval($this->data_post['gender']) : '', + 'referrer' => isset($this->data_post['referrer']) ? intval($this->data_post['referrer']) : 0, + 'is_onekey_mobile_bind' => 1, + ]; + return UserService::AuthUserProgram($data, 'baidu_openid'); + } else { + return DataReturn($result['msg'], -1); + } + } else { + return DataReturn('授权成功', 0, $user); + } + return DataReturn(empty($result) ? '获取用户手机号码失败' : $result, -100); + } } ?> \ No newline at end of file diff --git a/application/service/UserService.php b/application/service/UserService.php index b39dbd91a..e2ce16571 100755 --- a/application/service/UserService.php +++ b/application/service/UserService.php @@ -1704,6 +1704,7 @@ class UserService 'gender' => empty($params['gender']) ? 0 : intval($params['gender']), 'province' => empty($params['province']) ? '' : $params['province'], 'city' => empty($params['city']) ? '' : $params['city'], + 'mobile' => empty($params['mobile']) ? '' : $params['mobile'], 'referrer' => isset($params['referrer']) ? $params['referrer'] : 0, ]; @@ -1718,7 +1719,7 @@ class UserService if(!empty($unionid['field']) && !empty($unionid['value'])) { // unionid字段是否存在用户 - $user_unionid = UserService::AppUserInfoHandle(null, $unionid['field'], $unionid['value']); + $user_unionid = self::AppUserInfoHandle(null, $unionid['field'], $unionid['value']); if(!empty($user_unionid)) { // openid绑定 @@ -1744,6 +1745,33 @@ class UserService } else { return $ret; } + } else { + // 强制绑定手机号码、是否一键获取操作绑定 + if(isset($params['is_onekey_mobile_bind']) && $params['is_onekey_mobile_bind'] == 1 && !empty($data['mobile'])) + { + // 如果手机号码存在则直接绑定openid + // 不存在添加,存在更新openid + $user = self::AppUserInfoHandle(null, 'mobile', $data['mobile']); + if(!empty($user)) + { + $upd_data = [ + $field => $params['openid'], + 'upd_time' => time(), + ]; + if(Db::name('User')->where(['id'=>$user['id']])->update($upd_data)) + { + return DataReturn('绑定成功', 0, self::AppUserInfoHandle($user['id'])); + } + } else { + $ret = self::UserInsert($data, $params); + if($ret['code'] == 0) + { + return DataReturn('绑定成功', 0, self::AppUserInfoHandle($ret['data']['user_id'])); + } else { + return $ret; + } + } + } } } return DataReturn('授权成功', 0, self::AppUserInfoHandle(null, null, null, $data)); diff --git a/changelog.txt b/changelog.txt index 973929682..aaf535183 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,23 @@ ++=========================================================+ + ShopXO 1.9.1 Release --- http://shopxo.net ++=========================================================+ +全局 + 1. 支持货币功能 + 2. 新增快捷导航 + 3. 新增商品属性参数 + 4. 新增附件、css/js静态可配置CDN域名 + 5. 网站首页可后台控制配置 + +web端 + 1. + +小程序 + 1. QQ小程序支持微信支付 + +插件 + 1. 汇率插件支持货币自由切换 + + +=========================================================+ ShopXO 1.9.0 Release 20200818 http://shopxo.net +=========================================================+ diff --git a/extend/base/Baidu.php b/extend/base/Baidu.php index df9776cc4..2fc047c4e 100755 --- a/extend/base/Baidu.php +++ b/extend/base/Baidu.php @@ -50,9 +50,10 @@ class Baidu * @param [string] $encrypted_data [加密的用户数据] * @param [string] $iv [与用户数据一同返回的初始向量] * @param [string] $openid [解密后的原文] + * @param [string] $key [当时业务key] * @return [array|string] [成功返回用户信息数组, 失败返回错误信息] */ - public function DecryptData($encrypted_data, $iv, $openid) + public function DecryptData($encrypted_data, $iv, $openid, $key = 'user_info') { // 登录授权session $login_key = 'baidu_user_login_'.$openid; @@ -111,7 +112,7 @@ class Baidu } // 缓存存储 - $data_key = 'baidu_user_info_'.$openid; + $data_key = 'baidu_'.$key.'_'.$openid; cache($data_key, $data); return ['status'=>0, 'data'=>$data]; diff --git a/sourcecode/baidu/app.js b/sourcecode/baidu/app.js index 3095ee1b4..a69f95e5b 100755 --- a/sourcecode/baidu/app.js +++ b/sourcecode/baidu/app.js @@ -70,8 +70,8 @@ App({ // 请求地址 request_url: "{{request_url}}", - // request_url: 'http://shopxo.com/', - request_url: 'https://dev.shopxo.net/', + request_url: 'http://shopxo.com/', + // request_url: 'https://dev.shopxo.net/', // 基础信息 application_title: "{{application_title}}", diff --git a/sourcecode/baidu/app.json b/sourcecode/baidu/app.json index b15ce9bc5..1ff142845 100755 --- a/sourcecode/baidu/app.json +++ b/sourcecode/baidu/app.json @@ -1,11 +1,12 @@ { "pages": [ + "pages/login/login", "pages/index/index", "pages/goods-category/goods-category", "pages/cart/cart", "pages/user/user", "pages/web-view/web-view", - "pages/login/login", + "pages/paytips/paytips", "pages/goods-search/goods-search", "pages/goods-detail/goods-detail", diff --git a/sourcecode/baidu/pages/login/login.css b/sourcecode/baidu/pages/login/login.css index c899160a2..0ef5555ea 100755 --- a/sourcecode/baidu/pages/login/login.css +++ b/sourcecode/baidu/pages/login/login.css @@ -17,7 +17,7 @@ page{ .content input{ font-size: 28rpx; color: #4e4e4e; - height: 40px; + height: 40px; line-height: 40px; } .content .code{ @@ -26,13 +26,13 @@ page{ position: relative; } .content .code .verify{ - width: 63%; + width: 63%; } .content .code .verify-sub{ - border: solid 1px #ff6482; + border: solid 1px #ff6482; color: #ff6482; width: 35%; - height: 35px; + height: 35px; line-height: 35px; border-radius: 10rpx; position: absolute; @@ -40,7 +40,7 @@ page{ right: 0; } .content .code .verify-sub.sub-disabled{ - border: solid 1px #eee; + border: solid 1px #eee; color: #a6a6a6 } .content .submit{ @@ -60,4 +60,19 @@ page{ } .user-login button { margin-top: 30rpx; +} + +/** + * 登录确认 + */ +.login-logo { + width: 200rpx; + height: 200rpx; + margin: 0 auto; +} +.submit-list { + margin-top: 100rpx; +} +.submit-list button:not(:last-child) { + margin-bottom: 40rpx; } \ No newline at end of file diff --git a/sourcecode/baidu/pages/login/login.js b/sourcecode/baidu/pages/login/login.js index e24b441b9..306f0a5a8 100755 --- a/sourcecode/baidu/pages/login/login.js +++ b/sourcecode/baidu/pages/login/login.js @@ -9,7 +9,9 @@ Page({ verify_disabled: false, form_submit_loading: false, verify_time_total: 60, - temp_clear_time: null + temp_clear_time: null, + // 0确认页面, 1验证码绑定, 2一键获取绑定 + login_status: 2, }, /** @@ -97,14 +99,12 @@ Page({ }, 1000); } else { this.setData({ verify_submit_text: '获取验证码', verify_loading: false, verify_disabled: false }); - app.showToast(res.data.msg); } }, fail: () => { swan.hideLoading(); this.setData({ verify_submit_text: '获取验证码', verify_loading: false, verify_disabled: false }); - app.showToast("服务器请求出错"); } }); @@ -161,18 +161,80 @@ Page({ }, 1000); } else { this.setData({ form_submit_loading: false }); - app.showToast(res.data.msg); } }, fail: () => { swan.hideLoading(); this.setData({ form_submit_loading: false }); - app.showToast("服务器请求出错"); } }); } - } + }, + + // 获取手机号码一键登录 + confirm_phone_number_event(e) { + var encrypted_data = e.detail.encryptedData || null; + var iv = e.detail.iv || null; + if(encrypted_data != null && iv != null) { + // 邀请人参数 + var params = swan.getStorageSync(this.data.cache_launch_info_key) || null; + var referrer = (params == null) ? 0 : (params.referrer || 0); + + // 解密数据并绑定手机 + var data = { + "encrypted_data": encrypted_data, + "iv": iv, + "openid": this.data.user.baidu_openid, + "nickname": this.data.user.nickname, + "avatar": this.data.user.avatar, + "province": this.data.user.province, + "city": this.data.user.city, + "gender": this.data.user.gender, + "referrer": referrer + }; + swan.showLoading({ title: "处理中..." }); + var self = this; + swan.request({ + url: app.get_request_url('baiduusermobilebind', 'user'), + method: 'POST', + data: data, + dataType: 'json', + header: { 'content-type': 'application/x-www-form-urlencoded' }, + success: (res) => { + swan.hideLoading(); + if (res.data.code == 0 && (res.data.data || null) != null) { + app.showToast(res.data.msg, 'success'); + + swan.setStorage({ + key: app.data.cache_user_info_key, + data: res.data.data + }); + + var event_callback = this.data.params.event_callback || null; + setTimeout(function () { + // 触发回调函数 + if (event_callback != null) { + getCurrentPages()[getCurrentPages().length - 2][event_callback](); + } + swan.navigateBack(); + }, 1000); + } else { + app.showToast(res.data.msg); + } + }, + fail: () => { + swan.hideLoading(); + self.showToast('服务器请求出错'); + }, + }); + } + }, + + // 确认使用验证码 + confirm_verify_event(e) { + this.setData({login_status: 1}); + }, }); \ No newline at end of file diff --git a/sourcecode/baidu/pages/login/login.swan b/sourcecode/baidu/pages/login/login.swan index 63222135b..ebf75a925 100755 --- a/sourcecode/baidu/pages/login/login.swan +++ b/sourcecode/baidu/pages/login/login.swan @@ -1,5 +1,6 @@ -
+ + @@ -7,8 +8,18 @@
+ + + + + + + + +
+ 确认登录授权,为您提供更优质的服务