diff --git a/app/admin/controller/Wxserve.php b/app/admin/controller/Wxserve.php index ec802f44..5ab8ed96 100644 --- a/app/admin/controller/Wxserve.php +++ b/app/admin/controller/Wxserve.php @@ -12,6 +12,15 @@ use think\response\Json; class Wxserve extends Controller { + public function index(): Json + { + $appid = ['wxd87b1a7332d974d0', 'wxe3ed157849bd07b5', 'wx896520d9d03f108f', 'wx35f6c598106b9149', 'wx3f8c109fa934324f']; + $appid = array_merge($appid, ['wx1814307a39775007', 'wx74c7a92ae5ffbcb6', 'wx50b90d4df20da3ec', 'wxe843b6d7a4bd3389']); + $obj = new Server(); + $data = $obj->applySetOrderPathInfo($appid); + return $this->renderSuccess(['result' => $data]); + } + /** * @notes:生成授权二维码 * @return Json diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index 56d9f68d..48ac28b0 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -132,6 +132,26 @@ class Server return $url; } + /** + * @notes:申请设置订单页path信息 + * @param array $appid + * @param string $path + * @return mixed + * @author: wanghousheng + */ + public function applySetOrderPathInfo(array $appid, string $path = 'pages/order/index') + { + $token = $this->getComponentAccessToken(); + $data['access_token'] = $token; + $data['batch_req'] = [ + 'path' => $path, + 'appid_list' => $appid, + ]; + $url = "https://api.weixin.qq.com/wxa/security/applysetorderpathinfo?component_access_token=$token"; + $result = $this->curlPost($url, json_encode($data)); + return json_decode($result, true); + } + /** * @notes:获取预授权码 * @return false|mixed @@ -626,6 +646,8 @@ class Server if ($this->modifyJumpDomain($appid)) { $up['jump_domain_status'] = 1; } + //设置订单页path信息 + $this->applySetOrderPathInfo([$appid]); if ($up) { $model = new WxserverAccount(); $model->update($up, ['appid' => $appid]);