edit修改相关信息

This commit is contained in:
admin 2023-10-27 15:46:13 +08:00
parent 6044f3b915
commit ca9ffdc2c2
3 changed files with 41 additions and 2 deletions

View File

@ -29,6 +29,9 @@ class SiteController extends Controller
*/
public function actionIndex()
{
$code = $this->request->get('code');
echo($code);
exit();
return $this->render('index');
}

View File

@ -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());
}
}

View File

@ -32,6 +32,7 @@ class WxmpAuthMobileForm extends ApiModel
public $wechat_mp;
public $cx_mch_id;
public $url;
public function rules()
@ -120,6 +121,37 @@ class WxmpAuthMobileForm extends ApiModel
'msg' => 'ok',
'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}&timestamp={$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);
}
}