You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					172 lines
				
				7.1 KiB
			
		
		
			
		
	
	
					172 lines
				
				7.1 KiB
			| 
								 
											3 years ago
										 
									 | 
							
								package wx_menu;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import com.soecode.wxtools.api.IService;
							 | 
						||
| 
								 | 
							
								import com.soecode.wxtools.api.WxConsts;
							 | 
						||
| 
								 | 
							
								import com.soecode.wxtools.api.WxService;
							 | 
						||
| 
								 | 
							
								import com.soecode.wxtools.bean.WxMenu;
							 | 
						||
| 
								 | 
							
								import com.soecode.wxtools.bean.WxMenu.WxMenuButton;
							 | 
						||
| 
								 | 
							
								import com.soecode.wxtools.exception.WxErrorException;
							 | 
						||
| 
								 | 
							
								import com.ynxbd.wx.config.WeChatConfig;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import javax.servlet.ServletException;
							 | 
						||
| 
								 | 
							
								import javax.servlet.http.HttpServlet;
							 | 
						||
| 
								 | 
							
								import javax.servlet.http.HttpServletRequest;
							 | 
						||
| 
								 | 
							
								import javax.servlet.http.HttpServletResponse;
							 | 
						||
| 
								 | 
							
								import java.io.IOException;
							 | 
						||
| 
								 | 
							
								import java.io.PrintWriter;
							 | 
						||
| 
								 | 
							
								import java.util.ArrayList;
							 | 
						||
| 
								 | 
							
								import java.util.List;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								//@WebServlet("/createmenu")
							 | 
						||
| 
								 | 
							
								public class 元谋县人民医院 extends HttpServlet {
							 | 
						||
| 
								 | 
							
								    private static final long serialVersionUID = 1L;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    protected void doGet(HttpServletRequest request, HttpServletResponse response)
							 | 
						||
| 
								 | 
							
								            throws ServletException, IOException {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        // 实例化 统一业务API入口
							 | 
						||
| 
								 | 
							
								        IService iService = new WxService();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        // 验证服务器的有效性
							 | 
						||
| 
								 | 
							
								        PrintWriter out = response.getWriter();
							 | 
						||
| 
								 | 
							
								        String signature = request.getParameter("signature");
							 | 
						||
| 
								 | 
							
								        String timestamp = request.getParameter("timestamp");
							 | 
						||
| 
								 | 
							
								        String nonce = request.getParameter("nonce");
							 | 
						||
| 
								 | 
							
								        String echostr = request.getParameter("echostr");
							 | 
						||
| 
								 | 
							
								        if (iService.checkSignature(signature, timestamp, nonce, echostr)) {
							 | 
						||
| 
								 | 
							
								            out.print(echostr);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        WxMenu menu = new WxMenu();
							 | 
						||
| 
								 | 
							
								        List<WxMenuButton> btnList = new ArrayList<>();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn1 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn1.setType(WxConsts.MENU_BUTTON_CLICK);
							 | 
						||
| 
								 | 
							
								        btn1.setKey("l1");
							 | 
						||
| 
								 | 
							
								        btn1.setName("医院概况");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn2 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn2.setType(WxConsts.MENU_BUTTON_CLICK);
							 | 
						||
| 
								 | 
							
								        btn2.setKey("l2");
							 | 
						||
| 
								 | 
							
								        btn2.setName("诊疗咨询");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn3 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn3.setType(WxConsts.MENU_BUTTON_CLICK);
							 | 
						||
| 
								 | 
							
								        btn3.setKey("l3");
							 | 
						||
| 
								 | 
							
								        btn3.setName("微信支付");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        List<WxMenuButton> subList = new ArrayList<>();
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn1_1 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn1_1.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn1_1.setName("医院简介");
							 | 
						||
| 
								 | 
							
								        btn1_1.setUrl("http://mp.weixin.qq.com/s/tHdmAYJqVQCAlAOO2bZjtQ");
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn1_2 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn1_2.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn1_2.setName("科室简介");
							 | 
						||
| 
								 | 
							
								        btn1_2.setUrl("http://mp.weixin.qq.com/s/-BoYKwDDH2bNnsVZXV1GaA");
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn1_3 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn1_3.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn1_3.setName("本院专家");
							 | 
						||
| 
								 | 
							
								        btn1_3.setUrl("https://mp.weixin.qq.com/s?__biz=MzIwNDQ4NDM4Mw==&mid=100000048&idx=1&sn=353de94747c5e9c52b1ddde2258f6d7d&chksm=173e3b402049b256eb7eece9166136f292877108bde4759ccfc02c8c7b29c0696f8da95add8d&scene=0#rd");
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn1_3_2 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn1_3_2.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn1_3_2.setName("州医院专家");
							 | 
						||
| 
								 | 
							
								        btn1_3_2.setUrl("https://mp.weixin.qq.com/s?__biz=MzIwNDQ4NDM4Mw==&mid=100000763&idx=1&sn=2f05dd94ebd0e3f970d865208d20adf4&chksm=173e398b2049b09da47023177d4c14e523a5f7dbbcff22f0f2d46e061afd2268fbc3b3b14b5a&scene=0#rd");
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn1_4 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn1_4.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn1_4.setName("先进设备");
							 | 
						||
| 
								 | 
							
								        btn1_4.setUrl("http://mp.weixin.qq.com/s/W8SEevTAlqWU8slrPa9eDQ");
							 | 
						||
| 
								 | 
							
								        subList.add(btn1_1);
							 | 
						||
| 
								 | 
							
								        subList.add(btn1_2);
							 | 
						||
| 
								 | 
							
								        subList.add(btn1_3);
							 | 
						||
| 
								 | 
							
								        subList.add(btn1_3_2);
							 | 
						||
| 
								 | 
							
								        subList.add(btn1_4);
							 | 
						||
| 
								 | 
							
								        btn1.setSub_button(subList);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        List<WxMenuButton> subList2 = new ArrayList<>();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn2_1 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn2_1.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn2_1.setName("自助核酸检测");
							 | 
						||
| 
								 | 
							
								        btn2_1.setUrl(WeChatConfig.getBaseUrl() + "pay-nuclein.html");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn2_2 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn2_2.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn2_2.setName("新冠肺炎自诊");
							 | 
						||
| 
								 | 
							
								        btn2_2.setUrl("http://zz.chuanhai.net/default/cn/Index/Selfdiagnosis/index/hospitalCode/元谋县人民医院");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn2_3 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn2_3.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn2_3.setName("农合医保政策");
							 | 
						||
| 
								 | 
							
								        btn2_3.setUrl("https://mp.weixin.qq.com/s?__biz=MzIwNDQ4NDM4Mw==&mid=100000034&idx=1&sn=b5d7aa6a70734a82aad7e3dacbb38eaa&chksm=173e3b522049b2444e6b9e6c67c48dad67a637891da7471bb7bf671f13eb482a7452a2c34820&scene=0#rd");
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn2_4 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn2_4.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn2_4.setName("医疗小知识");
							 | 
						||
| 
								 | 
							
								        btn2_4.setUrl("http://mp.weixin.qq.com/s/MhaL5l8kbTJ6H0R2hBwqFQ");
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn2_5 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn2_5.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn2_5.setName("医院地图");
							 | 
						||
| 
								 | 
							
								        btn2_5.setUrl("http://mp.weixin.qq.com/s/BwCI7bSzN1KZ05196WXe0g");
							 | 
						||
| 
								 | 
							
								        subList2.add(btn2_1);
							 | 
						||
| 
								 | 
							
								        subList2.add(btn2_2);
							 | 
						||
| 
								 | 
							
								        subList2.add(btn2_3);
							 | 
						||
| 
								 | 
							
								        subList2.add(btn2_4);
							 | 
						||
| 
								 | 
							
								        subList2.add(btn2_5);
							 | 
						||
| 
								 | 
							
								        btn2.setSub_button(subList2);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        List<WxMenuButton> subList3 = new ArrayList<>();
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn3_1 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn3_1.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn3_1.setName("今日挂号");
							 | 
						||
| 
								 | 
							
								        btn3_1.setUrl(WeChatConfig.getBaseUrl() + "reg-site.html");
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn3_2 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn3_2.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn3_2.setName("我的账单");
							 | 
						||
| 
								 | 
							
								        btn3_2.setUrl(WeChatConfig.getBaseUrl() + "pay-info.html");
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn3_3 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn3_3.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn3_3.setName("报告单");
							 | 
						||
| 
								 | 
							
								        btn3_3.setUrl(WeChatConfig.getBaseUrl() + "all-result.html");
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn3_4 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn3_4.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn3_4.setName("身份绑定");
							 | 
						||
| 
								 | 
							
								        btn3_4.setUrl(WeChatConfig.getBaseUrl() + "my-info.html");
							 | 
						||
| 
								 | 
							
								        WxMenuButton btn3_5 = new WxMenuButton();
							 | 
						||
| 
								 | 
							
								        btn3_5.setType(WxConsts.MENU_BUTTON_VIEW);
							 | 
						||
| 
								 | 
							
								        btn3_5.setName("电子健康卡");
							 | 
						||
| 
								 | 
							
								        btn3_5.setUrl(WeChatConfig.getBaseUrl() + "health-card.html");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        subList3.add(btn3_1);
							 | 
						||
| 
								 | 
							
								        subList3.add(btn3_3);
							 | 
						||
| 
								 | 
							
								        subList3.add(btn3_2);
							 | 
						||
| 
								 | 
							
								        subList3.add(btn3_4);
							 | 
						||
| 
								 | 
							
								        subList3.add(btn3_5);
							 | 
						||
| 
								 | 
							
								        btn3.setSub_button(subList3);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        // 将三个按钮设置进btnList
							 | 
						||
| 
								 | 
							
								        btnList.add(btn1);
							 | 
						||
| 
								 | 
							
								        btnList.add(btn2);
							 | 
						||
| 
								 | 
							
								        btnList.add(btn3);    // 微信支付菜单
							 | 
						||
| 
								 | 
							
								        // 设置进菜单类
							 | 
						||
| 
								 | 
							
								        menu.setButton(btnList);
							 | 
						||
| 
								 | 
							
								        // 调用API即可
							 | 
						||
| 
								 | 
							
								        try {
							 | 
						||
| 
								 | 
							
								            // 参数1--menu ,参数2--是否是个性化定制。如果是个性化菜单栏,需要设置MenuRule
							 | 
						||
| 
								 | 
							
								            iService.createMenu(menu, false);
							 | 
						||
| 
								 | 
							
								        } catch (WxErrorException e) {
							 | 
						||
| 
								 | 
							
								            // TODO Auto-generated catch block
							 | 
						||
| 
								 | 
							
								            e.printStackTrace();
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    protected void doPost(HttpServletRequest request, HttpServletResponse response)
							 | 
						||
| 
								 | 
							
								            throws ServletException, IOException {
							 | 
						||
| 
								 | 
							
								        // TODO Auto-generated method stub
							 | 
						||
| 
								 | 
							
								        doGet(request, response);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 |