예제 #1
0
파일: WXHelp.cs 프로젝트: jaysue/zyweb
        public Senparc.Weixin.QY.Entities.Menu.BaseButton GetButton(string type, string menuname, string url, string key)
        {
            Senparc.Weixin.QY.Entities.Menu.BaseButton bb = new Senparc.Weixin.QY.Entities.Menu.BaseButton();
            switch (type)
            {
            case "1":     //跳转URL
                Senparc.Weixin.QY.Entities.Menu.SingleViewButton svb = new Senparc.Weixin.QY.Entities.Menu.SingleViewButton();
                svb.name = menuname;
                svb.type = "view";
                svb.url  = url;

                bb = svb;
                break;

            case "2":     //点击推事件
                Senparc.Weixin.QY.Entities.Menu.SingleClickButton scb = new Senparc.Weixin.QY.Entities.Menu.SingleClickButton();
                scb.name = menuname;
                scb.type = "click";
                scb.key  = key;

                bb = scb;
                break;

            case "3":    //扫码推事件
                Senparc.Weixin.QY.Entities.Menu.SingleScancodePushButton spb = new Senparc.Weixin.QY.Entities.Menu.SingleScancodePushButton();
                spb.name = menuname;
                spb.type = "scancode_push";
                spb.key  = key;

                bb = spb;
                break;

            case "4":    //扫码推事件且弹出“消息接收中”提示框
                Senparc.Weixin.QY.Entities.Menu.SingleScancodeWaitmsgButton swb = new Senparc.Weixin.QY.Entities.Menu.SingleScancodeWaitmsgButton();
                swb.name = menuname;
                swb.type = "scancode_waitmsg";
                swb.key  = key;

                bb = swb;
                break;

            case "5":    //弹出系统拍照发图
                Senparc.Weixin.QY.Entities.Menu.SinglePicSysphotoButton ssb = new Senparc.Weixin.QY.Entities.Menu.SinglePicSysphotoButton();
                ssb.name = menuname;
                ssb.type = "pic_sysphoto";
                ssb.key  = key;

                bb = ssb;
                break;

            case "6":    //弹出拍照或者相册发图
                Senparc.Weixin.QY.Entities.Menu.SinglePicPhotoOrAlbumButton sab = new Senparc.Weixin.QY.Entities.Menu.SinglePicPhotoOrAlbumButton();
                sab.name = menuname;
                sab.type = "pic_photo_or_album";
                sab.key  = key;

                bb = sab;
                break;

            case "7":    //弹出微信相册发图器
                Senparc.Weixin.QY.Entities.Menu.SinglePicWeixinButton sxb = new Senparc.Weixin.QY.Entities.Menu.SinglePicWeixinButton();
                sxb.name = menuname;
                sxb.type = "pic_weixin";
                sxb.key  = key;

                bb = sxb;
                break;

            case "8":    //弹出地理位置选择器
                Senparc.Weixin.QY.Entities.Menu.SingleLocationSelectButton slb = new Senparc.Weixin.QY.Entities.Menu.SingleLocationSelectButton();
                slb.name = menuname;
                slb.type = "location_select";
                slb.key  = key;

                bb = slb;
                break;
            }
            return(bb);
        }
예제 #2
0
파일: WXHelp.cs 프로젝트: jaysue/zyweb
        public QyJsonResult WX_WxCreateMenuNew(int agentId, string ModelCode, ref List <Senparc.Weixin.QY.Entities.Menu.BaseButton> lm)
        {
            string       strMenuURL = Qyinfo.WXUrl.TrimEnd('/') + "/View_Mobile/UI/UI_COMMON.html";
            QyJsonResult Ret        = new QyJsonResult();

            if (Qyinfo.IsUseWX == "Y")
            {
                var list = new JH_Auth_CommonB().GetEntities(p => p.ModelCode == ModelCode && p.TopID == 0 && p.Type == "1").OrderBy(p => p.Sort);

                foreach (var l in list)
                {
                    string url = string.Empty;
                    string key = string.Empty;
                    if (string.IsNullOrEmpty(l.MenuCode))
                    {
                        url = strMenuURL + "?funcode=" + l.ModelCode + "&corpId=" + Qyinfo.corpId;
                        key = l.ModelCode;
                    }
                    else
                    {
                        url = strMenuURL + "?funcode=" + l.ModelCode + "_" + l.MenuCode + "&corpId=" + Qyinfo.corpId;
                        key = l.ModelCode + "_" + l.MenuCode;
                    }

                    var list1 = new JH_Auth_CommonB().GetEntities(p => p.ModelCode == ModelCode && p.TopID == l.ID && p.Type == "1").OrderBy(p => p.Sort);
                    if (list1.Count() == 0)
                    {
                        lm.Add(GetButton(l.Type, l.MenuName, url, key));
                    }
                    else
                    {
                        Senparc.Weixin.QY.Entities.Menu.SubButton scb = new Senparc.Weixin.QY.Entities.Menu.SubButton();
                        scb.name = l.MenuName;

                        foreach (var l1 in list1)
                        {
                            string url1 = string.Empty;
                            string key1 = string.Empty;
                            if (string.IsNullOrEmpty(l1.MenuCode))
                            {
                                url1 = strMenuURL + "?funcode=" + l1.ModelCode + "&corpId=" + Qyinfo.corpId;
                                key1 = l1.ModelCode;
                            }
                            else
                            {
                                url1 = strMenuURL + "?funcode=" + l1.ModelCode + "_" + l1.MenuCode + "&corpId=" + Qyinfo.corpId;
                                key1 = l1.ModelCode + "_" + l1.MenuCode;
                            }

                            switch (l1.Type)
                            {
                            case "1":     //跳转URL
                                Senparc.Weixin.QY.Entities.Menu.SingleViewButton svb = new Senparc.Weixin.QY.Entities.Menu.SingleViewButton();
                                svb.name = l1.MenuName;
                                svb.type = "view";
                                svb.url  = url1;

                                scb.sub_button.Add(svb);
                                break;

                            case "2":     //点击推事件
                                Senparc.Weixin.QY.Entities.Menu.SingleClickButton skb = new Senparc.Weixin.QY.Entities.Menu.SingleClickButton();
                                skb.name = l1.MenuName;
                                skb.type = "click";
                                skb.key  = key1;

                                scb.sub_button.Add(skb);
                                break;

                            case "3":    //扫码推事件
                                Senparc.Weixin.QY.Entities.Menu.SingleScancodePushButton spb = new Senparc.Weixin.QY.Entities.Menu.SingleScancodePushButton();
                                spb.name = l1.MenuName;
                                spb.type = "scancode_push";
                                spb.key  = key1;

                                scb.sub_button.Add(spb);
                                break;

                            case "4":    //扫码推事件且弹出“消息接收中”提示框
                                Senparc.Weixin.QY.Entities.Menu.SingleScancodeWaitmsgButton swb = new Senparc.Weixin.QY.Entities.Menu.SingleScancodeWaitmsgButton();
                                swb.name = l1.MenuName;
                                swb.type = "scancode_waitmsg";
                                swb.key  = key1;

                                scb.sub_button.Add(swb);
                                break;

                            case "5":    //弹出系统拍照发图
                                Senparc.Weixin.QY.Entities.Menu.SinglePicSysphotoButton ssb = new Senparc.Weixin.QY.Entities.Menu.SinglePicSysphotoButton();
                                ssb.name = l1.MenuName;
                                ssb.type = "pic_sysphoto";
                                ssb.key  = key1;

                                scb.sub_button.Add(ssb);
                                break;

                            case "6":    //弹出拍照或者相册发图
                                Senparc.Weixin.QY.Entities.Menu.SinglePicPhotoOrAlbumButton sab = new Senparc.Weixin.QY.Entities.Menu.SinglePicPhotoOrAlbumButton();
                                sab.name = l1.MenuName;
                                sab.type = "pic_photo_or_album";
                                sab.key  = key1;

                                scb.sub_button.Add(sab);
                                break;

                            case "7":    //弹出微信相册发图器
                                Senparc.Weixin.QY.Entities.Menu.SinglePicWeixinButton sxb = new Senparc.Weixin.QY.Entities.Menu.SinglePicWeixinButton();
                                sxb.name = l1.MenuName;
                                sxb.type = "pic_weixin";
                                sxb.key  = key1;

                                scb.sub_button.Add(sxb);
                                break;

                            case "8":    //弹出地理位置选择器
                                Senparc.Weixin.QY.Entities.Menu.SingleLocationSelectButton slb = new Senparc.Weixin.QY.Entities.Menu.SingleLocationSelectButton();
                                slb.name = l1.MenuName;
                                slb.type = "location_select";
                                slb.key  = key1;

                                scb.sub_button.Add(slb);
                                break;
                            }
                        }

                        lm.Add(scb);
                    }
                }
                if (lm.Count > 0)
                {
                    Senparc.Weixin.QY.Entities.Menu.ButtonGroup buttonData = new Senparc.Weixin.QY.Entities.Menu.ButtonGroup();
                    buttonData.button = lm;

                    //Ret = CommonApi.CreateMenu(accesstoken, agentId, buttonData);
                    Ret = WX_CreateMenu(agentId, buttonData);
                }
            }
            return(Ret);
        }