error(__('User center already closed')); } } ////////////////////////////////////////////////////// //手机号登录/注册 public function mobileloginregister() { $user_token = input('user_token', '', 'trim'); if (!$user_token) { $this->error('参数缺失'); } $url = 'http://' . config('pingtai_ip') . ':8081/bussiness/1.0/hdc/svc/sso/loginUserInfo/cmtokenid/' . $user_token; //获取鉴权token $sign_bytes = '/1.0/hdc/svc/sso/loginUserInfo/cmtokenid/' . $user_token; $hdc_token = base64_encode(hash_hmac('sha256', $sign_bytes, config('pingtai_appkey'), true)); $header = [ 'Host:' . config('pingtai_ip') . ':8081', 'Content-Type:application/json', 'Authorization: HDCAUTH appid="' . config('pingtai_appid') . '",token="' . $hdc_token . '"' ]; $user_info = httpRequest($url, 'GET', '', $header); file_put_contents('chen.txt', $user_info, FILE_APPEND); $user_info = simplexml_load_string($user_info, 'SimpleXMLElement', LIBXML_NOCDATA); $user_info = (array)$user_info; if (!$user_info) { $this->error('您的网络开小差了~'); } $mobile = isset($user_info['phoneNum']) ? $user_info['phoneNum'] : ''; if (!$mobile) { $mobile = $this->request->post('mobile'); } if (!$mobile) { $this->error(__('Invalid parameters')); } /*$mobile = $this->request->post('mobile'); if (!$mobile) { $this->error(__('Invalid parameters')); } if (!Validate::regex($mobile, "^1\d{10}$")) { $this->error(__('Mobile is incorrect')); }*/ $user = \app\common\model\User::getByMobile($mobile); if ($user) { if ($user->status != 1) { $this->error(__('Account is locked')); } //如果已经有账号则直接登录 $ret = $this->auth->direct($user->id); } else { $ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, []); } if ($ret) { // $data = ['userinfo' => $this->auth->getUserinfo()]; $data = $this->auth->getUserinfo(); $data['hw_ip'] = explode(',', config('site.hw_ip')); //华为播放视频ip $data['zx_ip'] = explode(',', config('site.zx_ip')); //中兴播放视频ip $data['display'] = '';//不要删 备用字段 $this->success(__('Logged in successful'), $data); } else { $this->error($this->auth->getError()); } } //查询我的信息 public function getmyinfo() { $user = Db::name('user')->find($this->auth->id); $data['nickname'] = $user['nickname']; //姓名 $data['username'] = $user['username']; //UID $data['avatar'] = cdnurl($user['avatar']); //头像 $data['mobile'] = $user['mobile']; //手机号 $data['money'] = $user['money']; //余额 $data['realname'] = $user['realname']; //真实姓名 $data['gender'] = $user['gender']; //性别:1=男,2=女 $data['birthday'] = date('Y-m-d', $user['birthday']); //生日 $data['is_vip'] = 0; //vip是否到期:0到期 1未到期 $data['is_my_vip'] = 0; //健康E家的vip是否到期:0到期 1未到期 //查询vip是否到期 $url = 'http://' . config('pay_ip') . '/HDC/bizauth/phone/auth'; //产品编码集合 $product_codes = [config('product_code') ]; $vip_jifei = Db::name('vip_jifei')->where('user_switch',1)->where('deletetime',NULL)->column('productcode'); $product_codes = array_merge($product_codes,$vip_jifei); $product_codes_count = count($product_codes); $i_max = ceil($product_codes_count / 6); for ($i = 0; $i < $i_max; $i++) { $post_product_codes = array_slice($product_codes, $i * 6, 6); $post_data = [ 'phoneNumber' => $this->auth->mobile, 'productCodes' => $post_product_codes, 'channel' => '01' ]; $post_data = json_encode($post_data, 320); //获取鉴权token $sign_bytes = '/bizauth/phone/auth' . $this->base16_encode(md5($post_data)); // $hdc_token = base64_encode(hash_hmac('sha256', $sign_bytes, config('pay_appkey'), true)); $hdc_token = hash_hmac('sha256', $sign_bytes, base64_decode(config('pay_appkey')), false); $header = [ 'Host:' . config('pay_ip'), 'Content-Type:application/json', 'Authorization: HDCAUTH appid="' . config('pay_appid') . '",token="' . $hdc_token . '"' ]; $rs = httpRequest($url, 'POST', $post_data, $header); // file_put_contents('chen.txt', $user_info, FILE_APPEND); if ($rs) { $rs = json_decode($rs, true); if ($rs['code'] == '00') { foreach ($rs['result'] as &$v) { if ($v['isOrder'] == true) { $data['is_vip'] = 1; if($v['productCode'] == config('product_code')){ $data['is_my_vip'] = 1; //因为自己的产品码在第一个,所以不用担心被break掉 } break 2;//跳出二重循环 } } } } } $update = ['updatetime'=>time()]; if ($this->auth->is_vip != $data['is_vip']) { $update['is_vip'] = $data['is_vip']; } if ($this->auth->is_my_vip != $data['is_my_vip']) { $update['is_my_vip'] = $data['is_my_vip']; } Db::name('user')->where(['id' => $this->auth->id])->update($update); $this->success('信息', $data); } //关于我们/免责协议/用户协议/隐私政策/段位介绍 public function getagreement() { $type = input('type', 0, 'intval'); if (!in_array($type, [1, 2, 3, 4, 5, 6, 7, 8, 9])) { $this->error('参数错误'); } $info = Db::name('platform_info')->field('title, content')->where(['type' => $type])->find(); $this->success('协议', $info); } }