"use strict";(self["webpackChunkvoghion_vue_admin"]=self["webpackChunkvoghion_vue_admin"]||[]).push([[3304],{80923:function(e,n,t){t.r(n),t.d(n,{default:function(){return _}});var i=function(){var e=this,n=e._self._c;return n("div",[n("div",{staticClass:"bind-page g-bg-white"},[e.relationship&&!e.relationship.bindCms?[e.ddLoaded?n("el-button",{staticStyle:{"margin-bottom":"10px"},attrs:{type:"primary"},on:{click:function(n){return e.initDDLogin()}}},[e._v("生成二维码")]):e._e(),n("div",{staticStyle:{"margin-bottom":"10px"}},[n("el-radio-group",{model:{value:e.radio,callback:function(n){e.radio=n},expression:"radio"}},[n("el-radio",{attrs:{label:0}},[e._v(e._s(e.config[0].enterprise))]),n("el-radio",{attrs:{label:1}},[e._v(e._s(e.config[1].enterprise))])],1)],1),n("div",{directives:[{name:"show",rawName:"v-show",value:0===e.radio,expression:"radio === 0"}],staticClass:"self-defined-classname",attrs:{id:"self_defined_element0"}}),n("div",{directives:[{name:"show",rawName:"v-show",value:1===e.radio,expression:"radio === 1"}],staticClass:"self-defined-classname",attrs:{id:"self_defined_element1"}})]:e._e(),e.relationship&&e.relationship.bindCms?[e._m(0),e.ddLoaded?n("el-button",{attrs:{type:"primary"},on:{click:function(n){return e.ddUnbindHandle()}}},[e._v("解绑")]):e._e()]:e._e()],2)])},o=[function(){var e=this,n=e._self._c;return n("div",{staticStyle:{"margin-bottom":"10px"}},[n("p",[e._v("钉钉:已绑定")])])}];t(44114);let s=[];const d=(e,n)=>{const t=document.getElementById(e),i=n||function(){};if(!t){const n=document.createElement("script");n.src=e,n.id=e,document.body.appendChild(n),s.push(i);const t="onload"in n?o:d;t(n)}function o(n){n.onload=function(){this.onerror=this.onload=null;for(const e of s)e(null,n);s=[]},n.onerror=function(){this.onerror=this.onload=null,i(new Error("Failed to load "+e),n)}}function d(e){e.onreadystatechange=function(){if("complete"===this.readyState||"loaded"===this.readyState){this.onreadystatechange=null;for(const n of s)n(null,e);s=[]}}}t&&i&&i(null,t)};var r=d,a=t(89613),l=t(39866);const c=(0,l.zs)();let u=null,h=null;var f={data(){return{radio:0,ddLoaded:!1,code:"",authCode:"",config:c,relationship:null}},computed:{userInfo(){return this.$store.state.user.userInfo}},watch:{radio(e){this.initDDLogin()}},mounted(){this.queryDD(),r("https://g.alicdn.com/dingding/h5-dingtalk-login/0.21.0/ddlogin.js",(e=>{e?this.$message.error(e.message):this.ddLoaded=!0}))},methods:{queryDD(){(0,a.H)().then((e=>{e&&(this.relationship=e)})).finally((()=>{}))},ddbindHandle(e,n){(0,a.gM)({authCode:n,enterprise:this.config[e].enterprise}).then((e=>{e&&window.location.reload()})).finally((()=>{}))},ddUnbindHandle(){(0,a.ZS)().then((e=>{e&&(this.$message.success("unbind success"),this.queryDD())})).finally((()=>{}))},initDDLogin(){const e=this.radio;u=null,h=null,0===e&&(u=(e,n)=>{this.ddbindHandle(e,n),u=null}),1===e&&(h=(e,n)=>{this.ddbindHandle(e,n),h=null}),new window.DTFrameLogin({id:`self_defined_element${e}`,width:300,height:300},{redirect_uri:encodeURIComponent(`${location.origin}/account/ddBind`),client_id:this.config[e].clientId,scope:"openid",response_type:"code",state:"0",prompt:"consent"},(n=>{const{redirectUrl:t,authCode:i,state:o}=n;this.authCode=i,console.log(i),0===e&&u&&u(e,i),1===e&&h&&h(e,i),console.log(e,u),console.log(e,h)}),(e=>{this.$message.error(e),console.error(`errorMsg of errorCbk: ${e}`)}))}}},p=f,m=t(81656),g=(0,m.A)(p,i,o,!1,null,"415888a3",null),_=g.exports}}]);