Commit 89e23453 by 冷斌

fix bug

parent 481257ac
......@@ -5,11 +5,11 @@ class PayController extends Controller {
public function index(){
return;
}
public function wxLogin(){
//$roomnum=I('roomnum');
$configpri=getConfigPri();
$AppID = $configpri['login_wx_appid'];
$callback = get_upload_path('/wxshare/index.php/Pay/wxLoginCallback'); //回调地址
//微信登录
......@@ -20,16 +20,16 @@ class PayController extends Controller {
$callback = urlencode($callback);
//snsapi_base 静默 snsapi_userinfo 授权
$wxurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$AppID}&redirect_uri={$callback}&response_type=code&scope=snsapi_userinfo&state={$state}#wechat_redirect ";
header("Location: $wxurl");
}
public function wxLoginCallback(){
$code=I('code');
//$roomnum=I('roomnum');
if($code){
$configpri=getConfigPri();
$AppID = $configpri['login_wx_appid'];
$AppSecret = $configpri['login_wx_appsecret'];
/* 获取token */
......@@ -41,12 +41,12 @@ class PayController extends Controller {
$json = curl_exec($ch);
curl_close($ch);
$arr=json_decode($json,1);
if(isset($arr['errcode'])){
echo $arr['errmsg'];
exit;
}
/* 刷新token 有效期为30天 */
$url="https://api.weixin.qq.com/sns/oauth2/refresh_token?appid={$AppID}&grant_type=refresh_token&refresh_token={$arr['refresh_token']}";
$ch = curl_init();
......@@ -55,7 +55,7 @@ class PayController extends Controller {
curl_setopt($ch, CURLOPT_URL, $url);
$json = curl_exec($ch);
curl_close($ch);
$url="https://api.weixin.qq.com/sns/userinfo?access_token={$arr['access_token']}&openid={$arr['openid']}&lang=zh_CN";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
......@@ -74,19 +74,19 @@ class PayController extends Controller {
$authcode='rCt52pF2cnnKNB3Hkp';
$uuid = md5(md5($authcode.'123456'));
session('uuid',$uuid);
$href='http://'.$_SERVER['HTTP_HOST'].'/wxshare/index.php/Pay/pay';
header("Location: $href");
}else{
}
}
public function Post($curlPost,$url){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
......@@ -121,14 +121,14 @@ class PayController extends Controller {
$uuid=session('uuid');
//$userinfo=M("users")->field("id,user_nicename,avatar_thumb,coin")->where("id='{$uid}'")->find();
$this->assign('uuid',$uuid);
$chargelist=M('charge_rules')->field('id,coin,money,money_ios,product_id,give')->order('orderno asc')->select();
$this->assign('chargelist',$chargelist);
$this->display();
}
/* 获取用户信息 */
......@@ -140,6 +140,10 @@ class PayController extends Controller {
'data'=>array(),
'msg'=>'',
);
$liang = M('liang')->where("name='$uid'")->getField("uid");
if ($liang > 0) {
$uid = $liang;
}
$userinfo=M("users")->field("id,user_nicename,avatar_thumb,coin")->where("id='{$uid}'")->find();
if($userinfo){
$rs['data'] = $userinfo;
......@@ -196,17 +200,17 @@ class PayController extends Controller {
}else{
$rs['code']=1002;
$rs['msg']='订单信息错误';
}
}
}
echo json_encode($rs);
exit;
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment