edit修改相关信息
This commit is contained in:
parent
6044f3b915
commit
ca9ffdc2c2
@ -29,6 +29,9 @@ class SiteController extends Controller
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$code = $this->request->get('code');
|
||||
echo($code);
|
||||
exit();
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ use app\modules\api\behaviors\LoginBehavior;
|
||||
use app\models\PageForm;
|
||||
use app\components\SiteHelper;
|
||||
use app\modules\api\components\ApiHelper;
|
||||
use app\modules\api\models\WxmpAuthMobileForm;
|
||||
use Wechat\Wechat;
|
||||
|
||||
class DefaultController extends Controller
|
||||
@ -281,6 +282,9 @@ class DefaultController extends Controller
|
||||
* @ 获取js-sdk前端所需参数
|
||||
*/
|
||||
public function actionGetJssdk(){
|
||||
return $this->responseHandler($this->wechat_mp->jsapi);
|
||||
$obj = new WxmpAuthMobileForm();
|
||||
$obj->url = $this->request->get('url');
|
||||
$obj->wechat_mp = $this->wechat_mp;
|
||||
return $this->responseHandler($obj->actionGetJssdk());
|
||||
}
|
||||
}
|
||||
@ -32,6 +32,7 @@ class WxmpAuthMobileForm extends ApiModel
|
||||
|
||||
public $wechat_mp;
|
||||
public $cx_mch_id;
|
||||
public $url;
|
||||
|
||||
|
||||
public function rules()
|
||||
@ -121,5 +122,36 @@ class WxmpAuthMobileForm extends ApiModel
|
||||
'data' => $res
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @ 获取js-sdk前端所需参数
|
||||
*/
|
||||
public function actionGetJssdk(){
|
||||
$redis_name = "api:{$this->wechat_mp->appId}:actionGetJssdk_1";
|
||||
$get = \Yii::$app->redis->get($redis_name);
|
||||
if(empty($get)){
|
||||
$accessToken = $this->wechat_mp->getAccessToken();
|
||||
// $url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=$accessToken";
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=".$accessToken;
|
||||
$this->wechat_mp->curl->get($url);
|
||||
$res = json_decode($this->wechat_mp->curl->response);
|
||||
$get = $res->ticket;
|
||||
\Yii::$app->redis->setex($redis_name,6800,$get);
|
||||
}
|
||||
$uniq = uniqid();
|
||||
$time = time();
|
||||
$str = "jsapi_ticket={$get}&noncestr={$uniq}×tamp={$time}&url={$this->url}";
|
||||
$sign = sha1($str);
|
||||
$return = [
|
||||
'appId' => $this->wechat_mp->appId,
|
||||
'timestamp' => $time,
|
||||
'nonceStr' => $uniq,
|
||||
'signature' => $sign,
|
||||
'jsApiList' => [
|
||||
'scanQRCode',
|
||||
],
|
||||
];
|
||||
return $this->apiReturnSuccess('ok',$return);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user