"use strict";var e=require("../../common/vendor.js"),c=require("../../api/user.js");require("../../common/request.js");const d=()=>"../components/wxAuth.js",h={components:{wxAuth:d},data(){return{wxShow:!1,isAgreement:!1,code:null}},computed:{},onLoad(t){e.index.$on("refreshLogin",()=>{e.index.navigateBack({delta:1})}),this.getCode()},onUnload(){},mounted(){},methods:{updateUser(){this.wxShow=!1,e.index.$emit("refreshLogin"),e.index.$emit("refreshIM")},wxAuthOpen(){this.wxShow=!0;var t=this;setTimeout(function(){t.$refs.wxauth.getUserInfo()})},wxAuthClose(){this.wxShow=!1},wxLogin(t){var s=this;if(!this.isAgreement)return e.index.showToast({icon:"none",title:"\u8BF7\u5148\u540C\u610F\u534F\u8BAE\u540E\u518D\u767B\u5F55"}),!1;e.index.showLoading({title:"\u5904\u7406\u4E2D..."}),s.$getProvider().then(i=>{console.log("\u5F53\u524D\u7684\u73AF\u5883\u5546",i),i||reject(),e.index.login({provider:i,success:async a=>{console.log(111),console.log(t),console.log(a)}})}).catch(i=>{e.index.showToast({icon:"none",title:i})})},handleAgree(){this.isAgreement||e.index.showToast({icon:"none",title:"\u8BF7\u5148\u540C\u610F\u534F\u8BAE\u540E\u518D\u767B\u5F55"})},openContent(t){console.log(t),e.index.navigateTo({url:"/pages_user/agreement?type="+t})},handleAgreement(){this.isAgreement=!this.isAgreement},getCode(){var t=this;t.$getProvider().then(s=>{s||reject(),e.index.login({provider:s,success:async i=>{t.code=i.code}})}).catch(s=>{})},phoneLogin(t){var s=this;e.index.showLoading({title:"\u5904\u7406\u4E2D"}),console.log(t),t.detail.errMsg=="getPhoneNumber:ok"?this.$getProvider().then(i=>{console.log("\u5F53\u524D\u7684\u73AF\u5883\u5546",i),i||reject(),e.index.login({provider:i,success:async a=>{console.log(a);let r=a.code;var o=e.index.getStorageSync("tuiUserId");c.wxLogin({encryptedData:t.detail.encryptedData,iv:t.detail.iv,code:r,tuiUserId:o}).then(n=>{e.index.hideLoading(),n.code==200?(e.index.showToast({icon:"none",title:"\u767B\u5F55\u6210\u529F"}),e.index.setStorageSync("userHistoryApp",n.user.historyApp),e.index.setStorageSync("AppToken",n.token),e.index.setStorageSync("userId",n.user.userId),e.index.setStorageSync("avatar",n.user.avatar),e.index.setStorageSync("nickName",n.user.nickName),n.user.isWeixinAuth==0?s.wxAuthOpen():(e.index.$emit("refreshLogin"),e.index.$emit("refreshIM"))):e.index.showToast({icon:"none",title:"\u6388\u6743\u767B\u5F55\u5931\u8D25,\u8BF7\u91CD\u65B0\u767B\u5F55"})}).catch(n=>{console.log(n),e.index.hideLoading(),e.index.showToast({icon:"none",title:"\u6388\u6743\u767B\u5F55\u5931\u8D25,\u8BF7\u91CD\u65B0\u767B\u5F55"})})}})}).catch(i=>{}):e.index.showToast({title:"\u5DF2\u62D2\u7EDD\u6388\u6743",icon:"none",duration:2e3})},back(){e.index.reLaunch({url:"/pages/index/index",animationType:"pop-in",animationDuration:100})}}};if(!Array){const t=e.resolveComponent("wx-auth"),s=e.resolveComponent("u-popup");(t+s)()}const u=()=>"../../uni_modules/uview-plus/components/u-popup/u-popup.js";Math||u();function l(t,s,i,a,r,o){return e.e({a:e.o((...n)=>o.phoneLogin&&o.phoneLogin(...n)),b:r.isAgreement==!1},r.isAgreement==!1?{c:e.o(n=>o.handleAgree())}:{},{d:e.o((...n)=>o.back&&o.back(...n)),e:r.isAgreement,f:e.o(n=>o.handleAgreement()),g:e.o(n=>o.handleAgreement()),h:e.o(n=>o.openContent("userRegister")),i:e.o(n=>o.openContent("userPrivacy")),j:e.sr("wxauth","1e427071-1,1e427071-0"),k:e.o(n=>o.updateUser()),l:e.o(o.wxAuthClose),m:e.o(o.wxAuthOpen),n:e.p({bgColor:"#f6f6f6",safeAreaInsetBottom:!1,round:15,mode:"bottom",show:r.wxShow})})}var g=e._export_sfc(h,[["render",l],["__file","E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages/auth/login.vue"]]);wx.createPage(g);
