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.
162 lines
6.6 KiB
162 lines
6.6 KiB
2 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 {
|
||
|
|
||
|
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(WeChatConfig.getBaseUrl() + "index.html");
|
||
|
WxMenuButton btn1_2 = new WxMenuButton();
|
||
|
btn1_2.setType(WxConsts.MENU_BUTTON_VIEW);
|
||
|
btn1_2.setName("今日挂号");
|
||
|
btn1_2.setUrl(WeChatConfig.getBaseUrl() + "reg-index.html");
|
||
|
subList.add(btn1_1);
|
||
|
subList.add(btn1_2);
|
||
|
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("https://mp.weixin.qq.com/s?__biz=MzA5NTU3MjU0OQ==&mid=503143948&idx=1&sn=b22e44c4b157438a7253fe1652d4bbdf&chksm=08b4b9263fc3303044c91ed0c23a497cbb815b62427cbc95a13e85f87182bcbd21f5dc64fab5&scene=0#rd");
|
||
|
WxMenuButton btn2_2 = new WxMenuButton();
|
||
|
btn2_2.setType(WxConsts.MENU_BUTTON_VIEW);
|
||
|
btn2_2.setName("新一批上海专家到");
|
||
|
btn2_2.setUrl("https://mp.weixin.qq.com/s?__biz=MzA5NTU3MjU0OQ==&mid=503143304&idx=1&sn=8d96cb289e6d2bb8b2c9e04318dceee2&chksm=08b4bca23fc335b4170288f8a041b41c07ecb61ead9cc602653811495e654e1c75bb5e8b2204&scene=0#rd");
|
||
|
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=MzA5NTU3MjU0OQ==&mid=503143252&idx=1&sn=b21622ccfc616ff2aae934a7e63a102a&chksm=08b4bc7e3fc33568f0e549b11ee2a90820434679762194ecac20a187ab93aa8f1a199b827835&scene=0#rd");
|
||
|
WxMenuButton btn2_4 = new WxMenuButton();
|
||
|
btn2_4.setType(WxConsts.MENU_BUTTON_VIEW);
|
||
|
btn2_4.setName("电话预约");
|
||
|
btn2_4.setUrl("https://mp.weixin.qq.com/s?__biz=MzA5NTU3MjU0OQ==&mid=503144505&idx=1&sn=dea1f6426ca43c5337c3c6595d276114&chksm=08b487133fc30e05f65e27af22c966f5aac4c3dac7bfecc8d58a8289a42ca7011eb67e97f78e&scene=18#rd");
|
||
|
|
||
|
WxMenuButton btn2_5 = new WxMenuButton();
|
||
|
btn2_5.setType(WxConsts.MENU_BUTTON_VIEW);
|
||
|
btn2_5.setName("健康体检");
|
||
|
btn2_5.setUrl("http://weixin.kktijian.com/?orgid=YY201906182006170001");
|
||
|
|
||
|
|
||
|
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_0 = new WxMenuButton();
|
||
|
// btn3_0.setType(WxConsts.MENU_BUTTON_VIEW);
|
||
|
// btn3_0.setName("今日挂号");
|
||
|
// btn3_0.setUrl(WxConfig.getBaseURL() + "reg-index.html");
|
||
|
WxMenuButton btn3_1 = new WxMenuButton();
|
||
|
btn3_1.setType(WxConsts.MENU_BUTTON_VIEW);
|
||
|
btn3_1.setName("我的账单");
|
||
|
btn3_1.setUrl(WeChatConfig.getBaseUrl() + "my-pay.jsp");
|
||
|
WxMenuButton btn3_2 = new WxMenuButton();
|
||
|
btn3_2.setType(WxConsts.MENU_BUTTON_VIEW);
|
||
|
btn3_2.setName("检查结果");
|
||
|
btn3_2.setUrl(WeChatConfig.getBaseUrl() + "check.jsp");
|
||
|
WxMenuButton btn3_3 = new WxMenuButton();
|
||
|
btn3_3.setType(WxConsts.MENU_BUTTON_VIEW);
|
||
|
btn3_3.setName("化验结果");
|
||
|
btn3_3.setUrl(WeChatConfig.getBaseUrl() + "inspection.jsp");
|
||
|
WxMenuButton btn3_4 = new WxMenuButton();
|
||
|
btn3_4.setType(WxConsts.MENU_BUTTON_VIEW);
|
||
|
btn3_4.setName("身份绑定");
|
||
|
btn3_4.setUrl(WeChatConfig.getBaseUrl() + "my.jsp");
|
||
|
|
||
|
|
||
|
// WxMenuButton btn3_3 = new WxMenuButton();
|
||
|
// btn3_2.setType(WxConsts.MENU_BUTTON_VIEW);
|
||
|
// btn3_2.setName("发消息给我");
|
||
|
// btn3_2.setUrl("http://wsxrmyy.s1.natapp.cc/wx/sendmessage.jsp");
|
||
|
// subList3.add(btn3_0);
|
||
|
subList3.add(btn3_1);
|
||
|
subList3.add(btn3_3);
|
||
|
subList3.add(btn3_2);
|
||
|
subList3.add(btn3_4);
|
||
|
btn3.setSub_button(subList3);
|
||
|
|
||
|
// 将三个按钮设置进btnList
|
||
|
btnList.add(btn1);
|
||
|
btnList.add(btn2);
|
||
|
btnList.add(btn3); // 微信支付菜单
|
||
|
// btnList.add(btn3_1);
|
||
|
// btnList.add(btn3_3);
|
||
|
// btnList.add(btn3_2);
|
||
|
// 设置进菜单类
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
}
|