Files
2026-09-10 15:23:03 +08:00

2 lines
7.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{o as L,ap as A,aq as H,q as u,r as m,v as s,D as t,b9 as J,b6 as X,s as i,b7 as G,O as Q,F as B,br as Y,w as Z,u as V,at as $,L as p,T as ee,K as oe,d5 as se,P as ae,bg as te,b5 as re,bt as ne,M as w,ba as q,n as D,E as v}from"./.pnpm-BHOjf1ZS.js";import{_ as le}from"./index-BKuK5cAm.js";import{_ as de}from"./picker-DY0rRn6Q.js";import{u as ie,a as ce,j as c,N as ue,b as _e,O as me,_ as pe}from"./index-B31vLELt.js";import{a as we}from"./wecomOauthPostMessage-C_e6VGrO.js";import"./index-Dt_C33Jx.js";import"./index-Mwguss-B.js";import"./index.vue_vue_type_script_setup_true_lang-CDLrQsa9.js";import"./index-Btk0rgzN.js";import"./index-BXyqGAss.js";import"./file-DFj3ko4j.js";import"./index.vue_vue_type_script_setup_true_lang-BBhGStE3.js";import"./usePaging-oaNM6A9T.js";const fe={class:"user-setting"},ge={class:"w-80"},be={class:"w-80"},ke={class:"flex items-center gap-3"},ve={class:"w-80"},ye={class:"w-80"},he={class:"w-80"},xe={class:"bind-qrcode-wrap"},Ve={key:0,class:"text-center py-8"},Ue={key:1,id:"bind_wxwork_qrcode",class:"bind-qrcode"},Ee=L({name:"userSetting"}),Ie=L({...Ee,setup(Ce){const U=w(),f=ie(),o=q({avatar:"",account:"",name:"",work_wechat_userid:"",password_old:"",password:"",password_confirm:""}),M=q({avatar:[{required:!0,message:"头像不能为空",trigger:["change"]}],name:[{required:!0,message:"请输入名称",trigger:["blur"]}]}),g="like_admin_wx_bind_oauth",E=w(!1),y=w({corp_id:"",agent_id:""}),b=w(!1),k=w(!1);let l=null;const S=async()=>{const a=f.userInfo;for(const e in o)a[e]!==void 0&&(o[e]=a[e])},W=async()=>{if(o.password_old||o.password||o.password_confirm){if(!o.password_old)return c.msgError("请输入当前密码");if(!o.password)return c.msgError("请输入新的密码");if(!o.password_confirm)return c.msgError("请输入确定密码");if(o.password_confirm!=o.password)return c.msgError("两次输入的密码不一样")}if(o.password_old&&o.password&&o.password_confirm){if(o.password_old.length<6||o.password_old.length>32)return c.msgError("密码长度在6到32之间");if(o.password.length<6||o.password.length>32)return c.msgError("密码长度在6到32之间");if(o.password_confirm.length<6||o.password_confirm.length>32)return c.msgError("密码长度在6到32之间")}const{work_wechat_userid:a,...e}=o;await me(e),f.getUserInfo()},N=async()=>{var a;await((a=U.value)==null?void 0:a.validate()),W()},O=()=>window.location.origin+window.location.pathname+"?bind_wxwork=1",R=async()=>{b.value=!0,k.value=!0,window.WwLogin||await new Promise((e,_)=>{const r=document.createElement("script");r.src="https://wwcdn.weixin.qq.com/node/wework/wwopen/js/wwLogin-1.2.7.js",r.onload=()=>e(),r.onerror=()=>_(new Error("加载企业微信JS失败")),document.head.appendChild(r)}),await D(),k.value=!1,await D(),l==null||l(),l=we({pathIncludes:"user/setting",lockKey:g,wxBindState:"bind_wxwork",onCode:e=>I(e)});const a=encodeURIComponent(O());new window.WwLogin({id:"bind_wxwork_qrcode",appid:y.value.corp_id,agentid:y.value.agent_id,redirect_uri:a,lang:"zh",state:"bind_wxwork",href:"",self_redirect:!1})},T=()=>{k.value=!1,l==null||l(),l=null},z=async()=>{await c.confirm("确定要解绑企业微信吗?解绑后将无法使用企业微信扫码登录。");try{await ue(),o.work_wechat_userid="",v.success("解绑成功"),f.getUserInfo()}catch(a){v.error((a==null?void 0:a.msg)||"解绑失败")}},I=async a=>{try{const e=await _e({code:a});o.work_wechat_userid=(e==null?void 0:e.work_wechat_userid)||"",b.value=!1,v.success("企业微信绑定成功"),f.getUserInfo()}catch(e){v.error((e==null?void 0:e.msg)||(e==null?void 0:e.message)||"绑定失败")}finally{const e=window.location.pathname;window.history.replaceState({},"",e)}};return A(async()=>{try{const d=await ce();d!=null&&d.enabled&&(E.value=!0,y.value={corp_id:d.corp_id,agent_id:d.agent_id})}catch{}const a=new URLSearchParams(window.location.search),e=a.get("code"),_=a.get("state"),r=a.get("bind_wxwork");if(e&&(_==="bind_wxwork"||r==="1")){if(sessionStorage.getItem(g)===e)return;sessionStorage.setItem(g,e),I(e).finally(()=>{sessionStorage.removeItem(g)})}}),S(),H(()=>{l==null||l(),l=null}),(a,e)=>{const _=de,r=X,d=G,h=Z,C=Y,x=oe,F=J,P=te,j=le,K=ne;return u(),m("div",fe,[s(P,{class:"!border-none",shadow:"never"},{default:t(()=>[s(F,{ref_key:"formRef",ref:U,class:"ls-form",model:o,rules:M,"label-width":"100px"},{default:t(()=>[s(r,{label:"头像:",prop:"avatar"},{default:t(()=>[s(_,{modelValue:o.avatar,"onUpdate:modelValue":e[0]||(e[0]=n=>o.avatar=n),limit:1},null,8,["modelValue"])]),_:1}),s(r,{label:"账号:",prop:"account"},{default:t(()=>[i("div",ge,[s(d,{modelValue:o.account,"onUpdate:modelValue":e[1]||(e[1]=n=>o.account=n),disabled:""},null,8,["modelValue"])])]),_:1}),s(r,{label:"名称:",prop:"name"},{default:t(()=>[i("div",be,[s(d,{modelValue:o.name,"onUpdate:modelValue":e[2]||(e[2]=n=>o.name=n),placeholder:"请输入名称"},null,8,["modelValue"])])]),_:1}),E.value?(u(),Q(r,{key:0,label:"企业微信:"},{default:t(()=>[i("div",ke,[o.work_wechat_userid?(u(),m(B,{key:0},[s(C,{type:"success",size:"large"},{default:t(()=>[s(h,{class:"mr-1"},{default:t(()=>[s(V($))]),_:1}),p(" 已绑定("+ee(o.work_wechat_userid)+" ",1)]),_:1}),s(x,{type:"danger",link:"",onClick:z},{default:t(()=>[...e[7]||(e[7]=[p("解绑",-1)])]),_:1})],64)):(u(),m(B,{key:1},[s(C,{type:"info",size:"large"},{default:t(()=>[...e[8]||(e[8]=[p("未绑定",-1)])]),_:1}),s(x,{type:"primary",onClick:R},{default:t(()=>[s(h,{class:"mr-1"},{default:t(()=>[s(V(se))]),_:1}),e[9]||(e[9]=p(" 扫码绑定 ",-1))]),_:1})],64))])]),_:1})):ae("",!0),s(r,{label:"当前密码:",prop:"password_old"},{default:t(()=>[i("div",ve,[s(d,{modelValue:o.password_old,"onUpdate:modelValue":e[3]||(e[3]=n=>o.password_old=n),modelModifiers:{trim:!0},placeholder:"修改密码时必填, 不修改密码时留空",type:"password","show-password":""},null,8,["modelValue"])])]),_:1}),s(r,{label:"新的密码:",prop:"password"},{default:t(()=>[i("div",ye,[s(d,{modelValue:o.password,"onUpdate:modelValue":e[4]||(e[4]=n=>o.password=n),modelModifiers:{trim:!0},placeholder:"修改密码时必填, 不修改密码时留空",type:"password","show-password":""},null,8,["modelValue"])])]),_:1}),s(r,{label:"确定密码:",prop:"password_confirm"},{default:t(()=>[i("div",he,[s(d,{modelValue:o.password_confirm,"onUpdate:modelValue":e[5]||(e[5]=n=>o.password_confirm=n),modelModifiers:{trim:!0},placeholder:"修改密码时必填, 不修改密码时留空",type:"password","show-password":""},null,8,["modelValue"])])]),_:1})]),_:1},8,["model","rules"])]),_:1}),s(j,null,{default:t(()=>[s(x,{type:"primary",onClick:N},{default:t(()=>[...e[10]||(e[10]=[p("保存",-1)])]),_:1})]),_:1}),s(K,{modelValue:b.value,"onUpdate:modelValue":e[6]||(e[6]=n=>b.value=n),title:"扫码绑定企业微信",width:"440px","close-on-click-modal":!1,onClose:T},{default:t(()=>[i("div",xe,[k.value?(u(),m("div",Ve,[s(h,{class:"is-loading",size:36,color:"var(--el-color-primary)"},{default:t(()=>[s(V(re))]),_:1}),e[11]||(e[11]=i("div",{class:"mt-3 text-gray-400"},"加载企业微信扫码...",-1))])):(u(),m("div",Ue))]),e[12]||(e[12]=i("div",{class:"text-center text-sm text-gray-400 mt-2 mb-2"}," 请使用企业微信扫描二维码完成绑定 ",-1))]),_:1},8,["modelValue"])])}}}),Pe=pe(Ie,[["__scopeId","data-v-e7afb159"]]);export{Pe as default};