shish 4 лет назад
Родитель
Сommit
2a00947711
2 измененных файлов с 59 добавлено и 1 удалено
  1. 5 1
      app-pt/controllers/WxOpenController.php
  2. 54 0
      common/components/wxUtil.php

+ 5 - 1
app-pt/controllers/WxOpenController.php

@@ -445,6 +445,11 @@ class WxOpenController extends PublicController
             wxUtil::generateMemberCode($merchant, $isOpen);
         }
 
+        //完善隐私协议
+        if ($id == 17) {
+            wxUtil::privacySetting($merchant, $isOpen);
+        }
+
         Yii::$app->end();
 
         $r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true, $isOpen);
@@ -469,7 +474,6 @@ class WxOpenController extends PublicController
         print_r($return);
     }
 
-
     public function actionResult()
     {
         $get = Yii::$app->request->get();

+ 54 - 0
common/components/wxUtil.php

@@ -1579,6 +1579,60 @@ class wxUtil
         return $behind . $fileName;
     }
 
+    //隐私协议设置 shish 20211213
+    //接口说明 https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/privacy_config/set_privacy_setting.html
+    public static function privacySetting($merchant, $isOpen = 0)
+    {
+        $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
+        $url = "https://api.weixin.qq.com/cgi-bin/component/setprivacysetting?access_token={$accessToken}";
+        $curl = new curl\Curl();
+        $data = [
+            "owner_setting" => [
+                "contact_email" => "479439056@qq.com",
+                "notice_method" => "弹窗",
+            ],
+            "setting_list" => [
+                [
+                    "privacy_key" => "UserInfo",
+                    "privacy_text" => "开店时完善店铺信息和方便店铺管理"
+                ],
+                [
+                    "privacy_key" => "Location",
+                    "privacy_text" => "开店时完善店铺信息和方便店铺管理"
+                ],
+                [
+                    "privacy_key" => "PhoneNumber",
+                    "privacy_text" => "开店时完善店铺信息和方便店铺管理"
+                ],
+                [
+                    "privacy_key" => "Album",
+                    "privacy_text" => "开店时完善店铺信息和方便店铺管理"
+                ],
+                [
+                    "privacy_key" => "Camera",
+                    "privacy_text" => "开店时完善店铺信息和方便店铺管理"
+                ],
+                [
+                    "privacy_key" => "Record",
+                    "privacy_text" => "开店时完善店铺信息和方便店铺管理"
+                ],
+                [
+                    "privacy_key" => "AlbumWriteOnly",
+                    "privacy_text" => "开店时完善店铺信息和方便店铺管理"
+                ],
+                [
+                    "privacy_key" => "BlueTooth",
+                    "privacy_text" => "开店时完善店铺信息和方便店铺管理"
+                ],
+            ],
+            "privacy_ver" => 2,
+        ];
+        $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
+        $respond = Json::decode($result);
+        echo "<pre>";
+        print_r($respond);
+    }
+
     //收款小程序码
     public static function generateGatheringMiniCode($merchant, $shopId, $isOpen = 0)
     {