shish %!s(int64=6) %!d(string=hai) anos
pai
achega
34ff9598c7

+ 6 - 4
app/shop/controllers/WxMenuController.php

@@ -17,9 +17,11 @@ class WxMenuController extends BaseController
 	{
 		$menu = Yii::$app->request->post();
 
+		util::fail('即将开通');
+
 		//删除原有菜单
 		xhWxMenuService::delMenuList($this->merchantId);
-
+		
 		$date = date("Y-m-d H:i:s");
 		foreach ($menu as $key => $val) {//一级菜单数据整理
 			$parentOrder = $val['menuOrder'];
@@ -44,7 +46,7 @@ class WxMenuController extends BaseController
 			$parentId = $return['id'];
 			if (isset($val['children']) && !empty($val['children'])) {
 				foreach ($val['children'] as $childKey => $childValue) {
-					if(isset($childValue['menuOrder']) == false){
+					if (isset($childValue['menuOrder']) == false) {
 						print_r($childValue);
 						print_r($val);
 						die;
@@ -105,12 +107,12 @@ class WxMenuController extends BaseController
 		}
 		util::fail('提交失败');
 	}
-
+	
 	//微信菜单 shish 2019.12.19
 	public function actionTree()
 	{
 		$list = WxMenuService::getMenuTree($this->merchantId);
 		util::success($list);
 	}
-
+	
 }

+ 2 - 1
common/components/configDict.php

@@ -53,11 +53,12 @@ class configDict
 		'goodsDelStatusName' => [0 => '正常,未删除', 1 => '删除'],
 		'goodsDelStatus' => ['normal' => 0, 'del' => 1],
 		
-		'wxMenuOption' => ['redirectToCommonUseUrl' => 0, 'redirectToCustomUrl' => 1, 'showText' => 2, 'redirectToActive' => 3],
+		'wxMenuOption' => ['redirectToCommonUseUrl' => 0, 'redirectToCustomUrl' => 1, 'showText' => 2, 'redirectToMiniProgram' => 3],
 		'wxMenuOptionName' => [
 			0 => ['name' => '跳转到-常用链接', 'key' => 0, 'replyType' => 0],//replyType 回复类型
 			1 => ['name' => '跳转到-自定义网址', 'key' => 1, 'replyType' => 0],
 			2 => ['name' => '跳转到-文字', 'key' => 2, 'replyType' => 1],
+			3 => ['name' => '跳转到-小程序', 'key' => 3, 'replyType' => 0],
 		],
 		
 		'reachPeriodName' => [0 => '上午', 1 => '下午', 2 => '晚上'],

+ 20 - 6
common/services/xhWxMenuService.php

@@ -28,17 +28,27 @@ class xhWxMenuService
 			$mallDomain = str_replace('http', 'https', $mallDomain);
 			$shopDomain = str_replace('http', 'https', $shopDomain);
 		}
+//		$button = [
+//			["type" => 'view', "name" => "鲜花速递", "menuOption" => $menuOption['redirectToCommonUseUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
+//			["type" => 'view', "name" => "会员服务", "menuOption" => $menuOption['redirectToCommonUseUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
+//			["type" => 'view', "name" => "我的订单", "menuOption" => $menuOption['redirectToCommonUseUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
+//		];
 		$button = [
-			["type" => 'view', "name" => "鲜花速递", "menuOption" => $menuOption['redirectToCommonUseUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
-			["type" => 'view', "name" => "会员服务", "menuOption" => $menuOption['redirectToCommonUseUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
-			["type" => 'view', "name" => "我的订单", "menuOption" => $menuOption['redirectToCommonUseUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
+			["type" => 'miniprogram', "name" => "鲜花速递", "appid" => $merchant['miniAppId'], "pagepath" => "pages/home/index", "url" => $mallDomain . '/#/?account=' . $merchantId,],
+			["type" => 'miniprogram', "name" => "会员服务", "appid" => $merchant['miniAppId'], "pagepath" => "pages/home/user", "url" => $mallDomain . '/#/?account=' . $merchantId,],
+			["type" => 'miniprogram', "name" => "我的订单", "appid" => $merchant['miniAppId'], "pagepath" => "pages/order/list", "url" => $mallDomain . '/#/?account=' . $merchantId,],
 		];
 		$open = WxOpenService::getById(1);
 		//平台使用的公众号菜单与花店公众号菜单不一样
 		if (isset($open['merchantId']) && $open['merchantId'] == $merchantId) {
+//			$button = [
+//				["type" => "view", "name" => "官网", "menuOption" => $menuOption['redirectToCustomUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
+//				["type" => "view", "name" => "后台", "menuOption" => $menuOption['redirectToCustomUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
+//			];
 			$button = [
-				["type" => "view", "name" => "官网", "menuOption" => $menuOption['redirectToCustomUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
-				["type" => "view", "name" => "后台", "menuOption" => $menuOption['redirectToCustomUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
+				["type" => 'miniprogram', "name" => "官网", "appid" => $merchant['miniAppId'], "pagepath" => "", "url" => $mallDomain . '/#/?account=' . $merchantId,],
+				["type" => 'miniprogram', "name" => "申请", "appid" => $merchant['miniAppId'], "pagepath" => "", "url" => $mallDomain . '/#/?account=' . $merchantId,],
+				["type" => 'miniprogram', "name" => "后台", "appid" => $merchant['miniAppId'], "pagepath" => "", "url" => $mallDomain . '/#/?account=' . $merchantId,],
 			];
 		}
 		$wxUtil = new wxUtil($merchant);
@@ -49,6 +59,10 @@ class xhWxMenuService
 		$menu['button'] = $button;
 		$info = $wxUtil->userMenuToWeiXin($menu);
 		$info = json_decode($info, true);
+
+		print_r($info);
+		die;
+
 		xhMerchantExtendService::updateByMerchantId($merchantId, ['wxMenuInit' => 1]);
 		$now = time();
 		$date = date("Y-m-d H:i:s", $now);
@@ -83,7 +97,7 @@ class xhWxMenuService
 					$sonAddData['menuKey'] = $merchantId . '_' . $key . '_' . $sonKey;
 					$sonAddData['createTime'] = $date;
 					$sonAddData['replyType'] = $redirectUrl;//回复类型:常用链接、自定义网址、文字、报名类活动
-					$sonAddData['targetId'] = isset($sonVal['keyName']) ? $mapped[$sonVal['keyName']] : 0;//常用链接的链接选项id;活动id等
+					$sonAddData['targetId'] = isset($sonVal['keyName']) ? $mapped[$sonVal['keyName']] : 0;//常用链接选项id、活动id
 					$sonAddData['replyUrl'] = isset($sonVal['url']) ? $sonVal['url'] : '';
 					self::add($sonAddData);
 				}