"use strict";var i=require("../common/vendor.js"),e=require("../api/user.js"),n=require("../api/companyUser.js");require("../common/request.js");const s={data:()=>({isBind:!1,msg:"绑定中...",baseUrl:i.index.getStorageSync("requestPath"),btnLodaing:!1,companyUserId:""}),onLoad(i){let e={};if(i.q){let n=decodeURIComponent(i.q);e=this.$urlToObj(n)}this.companyUserId=e.companyUserId||i.companyUserId},onShow(){if(this.isBind)this.msg="已绑定或已经存在绑定关系";else{i.index.getStorageSync("historyApp")||""?this.handleBind():this.getUser()}},methods:{getUser(){i.index.showLoading({title:"绑定中..."}),e.getUserInfo().then((e=>{200==e.code?null!=e.user?e.user.historyApp?(i.index.setStorageSync("historyApp",e.user.historyApp),this.handleBind()):(i.index.hideLoading(),i.index.redirectTo({url:"/pages_user/downApp"})):(i.index.hideLoading(),this.utils.loginOut()):(i.index.hideLoading(),i.index.showToast({icon:"none",title:"请求失败"}))}),(i=>{})).catch((()=>{i.index.hideLoading()}))},handleBind(){i.index.showLoading({title:"绑定中..."}),this.msg="绑定中...",this.$isLogin().then((e=>{e?this.submit():(i.index.hideLoading(),i.index.navigateTo({url:"/pages/auth/login"}))})).catch((()=>{this.msg="绑定失败",i.index.hideLoading()}))},submit(){this.btnLodaing=!0,i.index.showLoading({title:"绑定中..."}),n.bindCompanyFsUser(this.companyUserId).then((e=>{this.btnLodaing=!1,i.index.hideLoading(),200==e.code?(this.isBind=!0,this.msg="绑定成功",i.index.showToast({title:e.msg,icon:"none"})):"已存在绑定关系"==e.msg?(this.isBind=!0,this.msg="绑定成功",i.index.showToast({title:"绑定成功",icon:"none"})):(this.msg=e.msg,this.isBind=!1,i.index.showToast({title:e.msg,icon:"none"}))})).catch((()=>{this.msg="绑定失败",this.isBind=!1,this.btnLodaing=!1,i.index.hideLoading()}))}}};var t=i._export_sfc(s,[["render",function(e,n,s,t,d,o){return i.e({a:d.isBind},(d.isBind,{}),{b:!d.isBind},d.isBind?{}:{c:i.t(d.msg)})}],["__scopeId","data-v-5a674f0a"]]);wx.createPage(t);
