1 |
- import{a as _,o as le,K as w,e as s,f as m,j as i,L as d,i as r,F as K,n as Z,G as H,t as N,B as J,C as b,m as h,y as A,an as ne,am as ie,Z as x,as as oe,p as ue,l as re}from"./vue-A59npLRR.js";import{F as se}from"./index-r6iTpmP6.js";import{c as E,_ as de,an as ve}from"./index-EwE51S_X.js";import"./index-K8IR974I.js";import"./baTable-MdxYOkAk.js";import"./index-XALue448.js";import"./echarts-cxb9vJr1.js";function ce(){return E({url:"/admin/xmwechat.offiaccount.Menu/getMenu",method:"get"})}function me(M){return E({url:"/admin/xmwechat.offiaccount.Menu/saveMenu",method:"post",data:M},{showSuccessMessage:!0})}function pe(M){return E({url:"/admin/xmwechat.offiaccount.Material/getMenuContent",method:"get",params:M},{CancelDuplicateRequest:!1})}const _e={components:{Icon:ve,FormItem:se},setup(){const M=_("创建自定义菜单后,菜单的刷新策略是,在用户进入公众号会话页或公众号profile页时,如果发现上一次拉取菜单的请求在5分钟以前,就会拉取一下菜单,如果菜单有更新,就会刷新客户端的菜单。测试时可以尝试取消关注公众账号后再次关注,则可以看到创建后的效果。"),c=_(!1),F=_(0),t=_(""),f=_(""),y=_(""),g=_(""),p=_(0),C=_(!0),o=_(0),n=_(-1),k=_(""),P=_(""),V=_(""),I=_(""),a=_([]),S=_("100%"),z=_({});le(()=>{ce().then(l=>{l.code===1&&l.data!==null&&(a.value=l.data,!a.value[0].hasOwnProperty("name")&&a.value[0].sub_button.length===0&&(a.value=[]),R())})});const O=l=>{pe(l).then(e=>{e.code===1&&(e.data!==null?z.value=e.data:z.value={})}).finally(()=>{})},v=()=>{if(a.value.length>0)if(p.value===0){j("menu");for(let l=0;l<a.value.length;l++)l===o.value&&(a.value[l].name=g.value)}else{j("sub_menu");let l=a.value[o.value].sub_button;for(let e=0;e<l.length;e++)n.value===e&&(l[n.value].name=g.value)}},T=l=>{if(t.value=l,f.value="",G(),l==="miniprogram"||l==="view"?y.value=l:y.value="",p.value===0)for(let e=0;e<a.value.length;e++)e===o.value&&(a.value[e].type=y.value,l==="miniprogram"?(k.value=a.value[e].hasOwnProperty("url")?a.value[e].url:"",V.value=a.value[e].hasOwnProperty("appid")?a.value[e].appid:"",I.value=a.value[e].hasOwnProperty("pagepath")?a.value[e].pagepath:""):l==="view"&&(k.value=a.value[e].hasOwnProperty("url")?a.value[e].url:""));else{let e=a.value[o.value].sub_button;for(let u=0;u<e.length;u++)n.value===u&&(e[n.value].type=y.value,l==="miniprogram"?(k.value=e[n.value].hasOwnProperty("url")?e[n.value].url:"",V.value=e[n.value].hasOwnProperty("url")?e[n.value].appid:"",I.value=e[n.value].hasOwnProperty("pagepath")?e[n.value].pagepath:""):l==="view"?k.value=e[n.value].hasOwnProperty("url")?e[n.value].url:"":l==="click"&&(e[n.value].hasOwnProperty("key")&&e[n.value].hasOwnProperty("key")!==""&&O({key:e[n.value].hasOwnProperty("key")?e[n.value].key:""}),e[n.value].hasOwnProperty("media_id")&&e[n.value].hasOwnProperty("media_id")!==""&&O({media_id:e[n.value].hasOwnProperty("media_id")?e[n.value].media_id:""}),e[n.value].hasOwnProperty("article_id")&&e[n.value].hasOwnProperty("article_id")!==""&&O({article_id:e[n.value].hasOwnProperty("article_id")?e[n.value].article_id:""})))}},B=()=>{if(p.value===0)for(let l=0;l<a.value.length;l++)l===o.value&&(a.value[l].type=t.value,a.value[l].url=k.value);else{a.value[o.value].hasOwnProperty("url")&&delete a.value[o.value].url;let l=a.value[o.value].sub_button;for(let e=0;e<l.length;e++)n.value===e&&(l[n.value].type=t.value,l[n.value].url=k.value)}},U=l=>{if(p.value===0)for(let e=0;e<a.value.length;e++)e===o.value&&(a.value[e].type=y.value,f.value==="text"?(a.value[e].key=l,a.value[e].hasOwnProperty("article_id")&&delete a.value[e].article_id,a.value[e].hasOwnProperty("media_id")&&delete a.value[e].media_id):f.value==="news"?(a.value[e].article_id=l,a.value[e].hasOwnProperty("key")&&delete a.value[e].key,a.value[e].hasOwnProperty("media_id")&&delete a.value[e].media_id):(f.value==="image"||f.value==="voice"||f.value==="video")&&(a.value[e].media_id=l,a.value[e].hasOwnProperty("key")&&delete a.value[e].key,a.value[e].hasOwnProperty("article_id")&&delete a.value[e].article_id));else{let e=a.value[o.value].sub_button;for(let u=0;u<e.length;u++)n.value===u&&(e[n.value].type=y.value,a.value[o.value].hasOwnProperty("key")&&delete a.value[o.value].key,a.value[o.value].hasOwnProperty("article_id")&&delete a.value[o.value].article_id,a.value[o.value].hasOwnProperty("media_id")&&delete a.value[o.value].media_id,f.value==="text"?(e[n.value].key=l,e[n.value].hasOwnProperty("article_id")&&delete e[n.value].article_id,e[n.value].hasOwnProperty("media_id")&&delete e[n.value].media_id):f.value==="news"?(e[n.value].article_id=l,e[n.value].hasOwnProperty("key")&&delete e[n.value].key,e[n.value].hasOwnProperty("media_id")&&delete e[n.value].media_id):(f.value==="image"||f.value==="voice"||f.value==="video")&&(e[n.value].media_id=l,e[n.value].hasOwnProperty("key")&&delete e[n.value].key,e[n.value].hasOwnProperty("article_id")&&delete e[n.value].article_id))}},W=l=>{f.value=l,P.value="",l==="news"?y.value="article_id":l==="image"||l==="voice"||l==="video"?y.value="media_id":y.value="click"},Q=()=>{if(p.value===0)for(let l=0;l<a.value.length;l++)l===o.value&&(a.value[l].type=y.value,a.value[l].appid=V.value);else{a.value[o.value].hasOwnProperty("appid")&&delete a.value[o.value].appid;let l=a.value[o.value].sub_button;for(let e=0;e<l.length;e++)n.value===e&&(l[n.value].type=y.value,l[n.value].appid=V.value)}},X=()=>{if(p.value===0)for(let l=0;l<a.value.length;l++)l===o.value&&(a.value[l].type=y.value,a.value[l].pagepath=I.value);else{a.value[o.value].hasOwnProperty("pagepath")&&delete a.value[o.value].pagepath;let l=a.value[o.value].sub_button;for(let e=0;e<l.length;e++)n.value===e&&(l[n.value].type=y.value,l[n.value].pagepath=I.value)}},j=l=>{let e=0;for(let u=0;u<g.value.length;u++)if(/[\u4e00-\u9fa5]/.test(g.value[u])?e+=2:e++,l==="menu"){if(e>8)return g.value=g.value.slice(0,u),x({type:"error",message:"仅支持中英文和数字,字数不超过4个汉字或8个字母"}),!1}else if(l==="sub_menu"){if(e>16)return g.value=g.value.slice(0,u),x({type:"error",message:"仅支持中英文和数字,字数不超过8个汉字或16个字母"}),!1}else return x({type:"error",message:"检查菜单名称字数ERROR"}),!1},Y=()=>{let l={name:"菜单名称"},u=a.value.push(l)-1;R(),D(l,u)},R=()=>{a.value.length<=0?S.value="100%":a.value.length===1?S.value="50%":S.value="33.33%"},D=(l,e)=>{F.value=1,n.value=-1,o.value=e,g.value=l.name,p.value=0,a.value[e].hasOwnProperty("sub_button")&&a.value[e].sub_button.length>0?(C.value=!1,a.value[e].hasOwnProperty("type")&&delete a.value[e].type,a.value[e].hasOwnProperty("url")&&delete a.value[e].url,a.value[e].hasOwnProperty("media_id")&&delete a.value[e].media_id,a.value[e].hasOwnProperty("article_id")&&delete a.value[e].media_id,a.value[e].hasOwnProperty("appid")&&delete a.value[e].media_id,a.value[e].hasOwnProperty("pagepath")&&delete a.value[e].pagepath):(C.value=!0,a.value[e].hasOwnProperty("type")?a.value[e].type==="view"||a.value[e].type==="miniprogram"?t.value=a.value[e].type:t.value="click":t.value="",T(t.value)),t.value==="click"&&(a.value[e].hasOwnProperty("key")&&a.value[e].key!==""&&O({key:a.value[e].key}),a.value[e].hasOwnProperty("media_id")&&a.value[e].media_id!==""&&O({media_id:a.value[e].media_id}),a.value[e].hasOwnProperty("article_id")&&a.value[e].article_id!==""&&O({article_id:a.value[e].article_id}))},$=l=>{if(!a.value[l].hasOwnProperty("sub_button"))a.value[l].sub_button=[];else if(a.value[l].sub_button.length===5)return x({type:"error",message:"子菜单最多添加5个"}),!1;let e={name:"子菜单名称"},te=a.value[l].sub_button.push(e)-1;q(e,te)},q=(l,e)=>{n.value=e,g.value=l.name,p.value=1,C.value=!0;let u=a.value[o.value].sub_button;u[n.value].hasOwnProperty("type")?(u[n.value].type==="view"||u[n.value].type==="miniprogram"?t.value=u[n.value].type:t.value="click",T(t.value)):t.value="",t.value==="click"&&(u[n.value].hasOwnProperty("key")&&u[n.value].hasOwnProperty("key")!==""&&O({key:u[n.value].hasOwnProperty("key")?u[n.value].key:""}),u[n.value].hasOwnProperty("media_id")&&u[n.value].hasOwnProperty("media_id")!==""&&O({media_id:u[n.value].hasOwnProperty("media_id")?u[n.value].media_id:""}),u[n.value].hasOwnProperty("article_id")&&u[n.value].hasOwnProperty("article_id")!==""&&O({article_id:u[n.value].hasOwnProperty("article_id")?u[n.value].article_id:""}))},ee=()=>{oe.confirm("删除后,菜单名菜单下设置的内容全部将被删除","提示",{confirmButtonText:"确认",cancelButtonText:"取消",type:"warning"}).then(()=>{if(p.value===0){for(let l=0;l<a.value.length;l++)l===o.value&&(a.value.splice(l,1),o.value=-1,x({type:"success",message:"删除成功"}));R()}else{let l=a.value[o.value].sub_button;for(let e=0;e<l.length;e++)n.value===e&&(l.splice(e,1),n.value=-1,x({type:"success",message:"删除成功"}))}}).catch(l=>{x({type:"info",message:l})})},ae=()=>{if(a.value.length===0)return x({type:"warning",message:"空菜单,不能保存与发布。停用菜单,请前往微信公众平台操作处理"}),!1;c.value=!0,me({button:a.value}).finally(()=>{c.value=!1})},G=()=>{z.value={}};return{loading:c,showRight:F,activeClass:o,buttonType:t,materialType:f,menuType:y,isShowButtonType:C,addIndex:n,menuName:g,url:k,material:P,appid:V,pagepath:I,menuList:a,menuListWidth:S,isOperateSubMenu:p,warningContent:M,currentMenuContent:z,addMenu:Y,addSubMenu:$,getItem:D,getSubItem:q,clickButtonType:T,clickMaterialType:W,onChangeMaterialType:U,onInputMenuName:v,onInputUrl:B,onInputAppId:Q,onInputPagePath:X,delMenu:ee,submit:ae,reSelectContent:G}}},L=M=>(ue("data-v-e33d0041"),M=M(),re(),M),he={style:{margin:"15px","background-color":"var(--ba-bg-color-overlay)"}},ye={class:"el-card is-always-shadow left-side-card"},fe={style:{display:"block",clear:"both",padding:"15px","margin-bottom":"15px"}},ge=L(()=>r("div",{style:{float:"left"}},"01:21",-1)),we={style:{float:"right"}},be={style:{display:"block",clear:"both","padding-left":"10px","padding-right":"10px"}},ke={style:{float:"left"}},Pe={style:{float:"right"}},Oe={class:"left-side-bottom"},Me={class:"left-side-bottom-menu"},Ce={key:0},Ie=["onClick"],Te=L(()=>r("div",{class:"menu-arrow"},null,-1)),Ve={class:"add-sub"},xe=["onClick"],Le=["onClick"],Se={key:0},ze={key:0},Be={key:1},Ne={style:{display:"flex","margin-top":"15px"}},Ue=L(()=>r("label",{class:"right-side-title"},"菜单名称",-1)),Ae={key:0,style:{color:"#9a8d8d","margin-left":"80px"}},Fe={key:1,style:{color:"#9a8d8d","margin-left":"80px"}},Re={class:"right-side-input"},Ee=L(()=>r("label",{class:"right-side-title"},"消息类型",-1)),We={key:0},je={class:"right-side-input"},De=L(()=>r("label",{class:"right-side-title"},"菜单内容",-1)),qe={style:{"line-height":"34px"}},Ge={key:0,class:"right-select-content"},Ke={key:1},Ze={class:"right-side-input"},He=L(()=>r("label",{class:"right-side-title"},"页面地址",-1)),Je={key:2},Qe={class:"right-side-input"},Xe=L(()=>r("label",{class:"right-side-title"},"AppId",-1)),Ye={class:"right-side-input"},$e=L(()=>r("label",{class:"right-side-title"},"小程序路径",-1)),ea=["src"],aa={style:{"font-size":"16px"}},ta={key:0,class:"card-right-text"},la={key:1,class:"card-right-text"},na={key:2,class:"card-right-text"},ia={key:3,class:"card-right-text"},oa={key:1,style:{"min-height":"200px","text-align":"center","padding-top":"100px"}};function ua(M,c,F,t,f,y){const g=w("el-alert"),p=w("Icon"),C=w("el-col"),o=w("el-text"),n=w("el-button"),k=w("el-input"),P=w("el-radio"),V=w("el-radio-group"),I=w("FormItem"),a=w("el-link"),S=w("el-row"),z=w("el-card"),O=w("el-divider");return s(),m("div",he,[i(S,{span:24,style:{padding:"20px"}},{default:d(()=>[i(g,{title:t.warningContent,type:"warning",style:{"margin-bottom":"10px"}},null,8,["title"]),i(C,{span:7,class:"left-side"},{default:d(()=>[r("div",ye,[r("div",fe,[ge,r("div",we,[i(p,{name:"fa fa-signal",color:"var(--el-text-color-primary)",size:"13"}),i(p,{name:"fa fa-feed",color:"var(--el-text-color-primary)",size:"13",style:{margin:"0 8px"}}),i(p,{name:"fa fa-battery-4",color:"var(--el-text-color-primary)",size:"13"})])]),r("div",be,[r("div",ke,[i(p,{name:"el-icon-ArrowLeft",color:"var(--el-text-color-primary)",size:"20"})]),r("div",Pe,[i(p,{name:"el-icon-User",color:"var(--el-text-color-primary)",size:"20"})])]),r("div",Oe,[i(p,{class:"left-side-bottom-img",name:"fa fa-keyboard-o",color:"#b1b3b8"}),r("div",Me,[(s(!0),m(K,null,J(t.menuList,(v,T)=>(s(),m("div",{class:"menu-li",key:T,style:Z({width:t.menuListWidth})},[t.activeClass===T?(s(),m("div",Ce,[r("div",{class:"sub-menu-add",onClick:B=>t.addSubMenu(T)},[i(p,{name:"el-icon-Plus",color:"#b1b3b8"}),Te],8,Ie),r("div",Ve,[(s(!0),m(K,null,J(v.sub_button,(B,U)=>(s(),m("div",{class:H(["sub-menu-add2",t.addIndex===U?"active":""]),key:U,onClick:W=>t.getSubItem(B,U)},N(B.name),11,xe))),128))])])):b("",!0),r("div",{class:H(["text",t.activeClass===T&&t.addIndex===-1?"active":""]),onClick:B=>t.getItem(v,T)},N(v.name),11,Le)],4))),128)),t.menuList.length<3?(s(),m("div",{key:0,class:"menu-li",style:Z({width:t.menuListWidth})},[r("div",{class:"text",onClick:c[0]||(c[0]=(...v)=>t.addMenu&&t.addMenu(...v)),style:{color:"#b1b3b8"}},[i(p,{name:"el-icon-Plus",color:"#b1b3b8",style:{top:"8%"}})])],4)):b("",!0)])])])]),_:1}),i(C,{span:17},{default:d(()=>[i(z,{class:"box-card right-side"},{default:d(()=>[t.showRight===1?(s(),m("div",Se,[t.menuList.length===0?(s(),m("div",ze,[i(o,{size:"large"},{default:d(()=>[h("你未添加自定义菜单,点击左侧添加菜单为公众号创建菜单栏。")]),_:1})])):(s(),m("div",Be,[i(o,{tag:"b",size:"large"},{default:d(()=>[h(N(t.menuName),1)]),_:1}),i(n,{style:{float:"right",padding:"3px 0"},type:"danger",link:!0,onClick:t.delMenu},{default:d(()=>[h("删除菜单")]),_:1},8,["onClick"]),r("div",Ne,[Ue,i(k,{modelValue:t.menuName,"onUpdate:modelValue":c[1]||(c[1]=v=>t.menuName=v),onInput:t.onInputMenuName,placeholder:"仅支持中英文和数字",style:{width:"70%"}},null,8,["modelValue","onInput"])]),t.isOperateSubMenu===0?(s(),m("p",Ae," 仅支持中英文和数字,字数不超过4个汉字或8个字母 ")):(s(),m("p",Fe,"仅支持中英文和数字,字数不超过8个汉字或16个字母")),ie(r("div",null,[r("div",Re,[Ee,i(V,{modelValue:t.buttonType,"onUpdate:modelValue":c[2]||(c[2]=v=>t.buttonType=v),onChange:t.clickButtonType,style:{"line-height":"45px"}},{default:d(()=>[i(P,{label:"view"},{default:d(()=>[h("跳转网页")]),_:1}),i(P,{label:"miniprogram"},{default:d(()=>[h("跳转小程序")]),_:1}),i(P,{label:"click"},{default:d(()=>[h("发送消息")]),_:1})]),_:1},8,["modelValue","onChange"])]),t.buttonType==="click"&&Object.keys(t.currentMenuContent).length===0?(s(),m("div",We,[r("div",je,[De,r("div",qe,[i(V,{modelValue:t.materialType,"onUpdate:modelValue":c[3]||(c[3]=v=>t.materialType=v),onChange:t.clickMaterialType,style:{"line-height":"45px"}},{default:d(()=>[i(P,{label:"text",border:""},{default:d(()=>[h("文本")]),_:1}),i(P,{label:"news",border:""},{default:d(()=>[h("图文")]),_:1}),i(P,{label:"image",border:""},{default:d(()=>[h("图片")]),_:1}),i(P,{label:"voice",border:""},{default:d(()=>[h("音频")]),_:1}),i(P,{label:"video",border:""},{default:d(()=>[h("视频")]),_:1})]),_:1},8,["modelValue","onChange"])])]),t.materialType!==""?(s(),m("div",Ge,[t.materialType==="text"?(s(),A(I,{type:"remoteSelect",modelValue:t.material,"onUpdate:modelValue":c[4]||(c[4]=v=>t.material=v),key:"text","input-attr":{pk:"event_key",field:"content","remote-url":"/admin/xmwechat.offiaccount.Material/index",placeholder:"点击选择数据",params:{type:t.materialType},onChange:t.onChangeMaterialType}},null,8,["modelValue","input-attr"])):t.materialType==="news"?(s(),A(I,{type:"remoteSelect",modelValue:t.material,"onUpdate:modelValue":c[5]||(c[5]=v=>t.material=v),key:"news","input-attr":{pk:"article_id",field:"title","remote-url":"/admin/xmwechat.offiaccount.Material/index",placeholder:"点击选择数据",params:{type:t.materialType},onChange:t.onChangeMaterialType}},null,8,["modelValue","input-attr"])):t.materialType==="image"||t.materialType==="voice"||t.materialType==="video"?(s(),A(I,{type:"remoteSelect",modelValue:t.material,"onUpdate:modelValue":c[6]||(c[6]=v=>t.material=v),key:t.materialType,"input-attr":{pk:"media_id",field:"name","remote-url":"/admin/xmwechat.offiaccount.Material/index",placeholder:"点击选择数据",params:{type:t.materialType},onChange:t.onChangeMaterialType}},null,8,["modelValue","input-attr"])):b("",!0)])):b("",!0)])):b("",!0),t.buttonType==="view"||t.buttonType==="miniprogram"?(s(),m("div",Ke,[r("div",Ze,[He,i(k,{modelValue:t.url,"onUpdate:modelValue":c[7]||(c[7]=v=>t.url=v),onInput:t.onInputUrl,placeholder:"请输入页面地址",style:{width:"70%"}},null,8,["modelValue","onInput"])])])):b("",!0),t.buttonType==="miniprogram"?(s(),m("div",Je,[r("div",Qe,[Xe,i(k,{modelValue:t.appid,"onUpdate:modelValue":c[8]||(c[8]=v=>t.appid=v),onInput:t.onInputAppId,placeholder:"请输入小程序AppId",style:{width:"70%"}},null,8,["modelValue","onInput"])]),r("div",Ye,[$e,i(k,{modelValue:t.pagepath,"onUpdate:modelValue":c[9]||(c[9]=v=>t.pagepath=v),onInput:t.onInputPagePath,placeholder:"请输入小程序跳转路径",style:{width:"70%"}},null,8,["modelValue","onInput"])])])):b("",!0)],512),[[ne,t.isShowButtonType]]),t.buttonType==="click"&&Object.keys(t.currentMenuContent).length!==0?(s(),A(z,{key:2,shadow:"always",class:"card"},{default:d(()=>[i(S,{class:"card-row"},{default:d(()=>[t.currentMenuContent.hasOwnProperty("image")&&t.currentMenuContent.image!==""?(s(),A(C,{key:0,span:2,class:"card-left"},{default:d(()=>[r("img",{src:t.currentMenuContent.image,class:"image",alt:"image"},null,8,ea)]),_:1})):b("",!0),i(C,{span:10,class:"card-right"},{default:d(()=>[r("div",aa,[t.currentMenuContent.hasOwnProperty("name")&&t.currentMenuContent.name!==""?(s(),m("div",ta," 名称: "+N(t.currentMenuContent.name),1)):b("",!0),t.currentMenuContent.hasOwnProperty("title")&&t.currentMenuContent.title!==""?(s(),m("div",la," 标题: "+N(t.currentMenuContent.title),1)):b("",!0),t.currentMenuContent.hasOwnProperty("url")&&t.currentMenuContent.url!==""?(s(),m("div",na,[h(" 链接: "),i(a,{href:t.currentMenuContent.url,target:"_blank"},{default:d(()=>[h("点击链接")]),_:1},8,["href"])])):b("",!0),t.currentMenuContent.hasOwnProperty("content")&&!t.currentMenuContent.hasOwnProperty("url")?(s(),m("div",ia," 内容: "+N(t.currentMenuContent.content),1)):b("",!0)])]),_:1})]),_:1}),i(n,{type:"primary",round:"",size:"small",onClick:t.reSelectContent},{default:d(()=>[h(" 重新选择 ")]),_:1},8,["onClick"])]),_:1})):b("",!0)])),i(O),i(C,{span:24},{default:d(()=>[i(n,{type:"success",loading:t.loading,size:"large",style:{display:"block",margin:"20px auto 0"},onClick:t.submit},{default:d(()=>[h("保存并发布")]),_:1},8,["loading","onClick"])]),_:1})])):(s(),m("div",oa,[i(o,{size:"large"},{default:d(()=>[h("点击左侧添加菜单为公众号创建菜单栏。")]),_:1})]))]),_:1})]),_:1})]),_:1})])}const ha=de(_e,[["render",ua],["__scopeId","data-v-e33d0041"]]);export{ha as default};
|