| | |
| | | <div class="sign_in"> |
| | | <i class="ywifont ywicon-guanbi closes" @click="handleClose"></i> |
| | | <h1><span>登录 WI 水务智能</span></h1> |
| | | <el-tabs v-model="state.activeLoginName" class="mt-[24px]" @tab-change="handleTabChange"> |
| | | <el-tabs v-model="state.activeLoginName" class="w-full mt-[24px]" @tab-change="handleTabChange"> |
| | | <el-tab-pane label="账户密码登录" name="accountUser"> |
| | | <el-form |
| | | ref="loginFormRef" |
| | |
| | | </el-form> |
| | | </el-tab-pane> |
| | | <el-tab-pane label="微信登录" name="wechat"> |
| | | <div id="wechat-login"></div> |
| | | <!-- <div id="wechat-login"></div> --> |
| | | <div id="wechat-login" class="flex justify-center items-center"> |
| | | <iframe |
| | | ref="wechatQrRef" |
| | | sandbox="allow-top-navigation allow-scripts" |
| | | style="width: 300px; height: 232px; overflow: hidden" |
| | | frameborder="0" |
| | | ></iframe> |
| | | </div> |
| | | </el-tab-pane> |
| | | </el-tabs> |
| | | |
| | | <div class="mt-[24px]"> |
| | | <div class="mt-[24px]" v-if="state.activeLoginName !== 'wechat'"> |
| | | <el-button type="primary" @click="onSubmit" class="set-login_btn">登录</el-button> |
| | | |
| | | <!-- <el-button type="primary" @click="loginByWechat">微信登录</el-button> --> |
| | |
| | | const state = (new Date().getTime() / 1000).toString(); |
| | | // JJJHHH 表示#号 |
| | | const url = `${SERVE_URL}JJJHHH/home?isWxLogin=Y`; |
| | | |
| | | const base64 = |
| | | 'LmltcG93ZXJCb3ggLnRpdGxlIHtkaXNwbGF5Om5vbmU7fQoKLmltcG93ZXJCb3ggLnN0YXR1cy5zdGF0dXNfYnJvd3NlciAgcDpudGgtb2YtdHlwZSgyKXsKICAgIGRpc3BsYXk6IG5vbmU7Cn0='; |
| | | const obj = new window.WxLogin({ |
| | | id: 'wechat-login', |
| | | appid: 'wx4ea2dca37170074c', |
| | | scope: 'snsapi_login', |
| | | redirect_uri: encodeURIComponent(`http://apiv3.xpump.net/User/wxUserLoginCB.html?from=wi&url=${url}`), |
| | | state: state, |
| | | href: `data:text/css;base64,${base64}`, |
| | | }); |
| | | }; |
| | | |
| | | const wechatQrRef = ref<HTMLIFrameElement>(); |
| | | |
| | | const openWechatLogin = () => { |
| | | if (!wechatQrRef.value) return; |
| | | const url = `${SERVE_URL}JJJHHH/home?isWxLogin=Y`; |
| | | const appid = 'wx4ea2dca37170074c'; |
| | | const state = (new Date().getTime() / 1000).toString(); |
| | | const base64 = btoa(` |
| | | .impowerBox .title {display:none;} |
| | | |
| | | .impowerBox .status.status_browser p:nth-of-type(2){ |
| | | display: none; |
| | | } |
| | | |
| | | .impowerBox .qrcode { |
| | | width: 160px; |
| | | margin-top:0; |
| | | |
| | | } |
| | | .impowerBox .status{ |
| | | } |
| | | #tpl_for_iframe{ |
| | | height:100%; |
| | | overflow: hidden; |
| | | |
| | | display: flex; |
| | | flex-direction: column; |
| | | align-items: center; |
| | | justify-content: center; |
| | | } |
| | | |
| | | `); |
| | | const wechatAuthUrl = `https://open.weixin.qq.com/connect/qrconnect?appid=${appid}&redirect_uri=${encodeURIComponent( |
| | | `http://apiv3.xpump.net/User/wxUserLoginCB.html?from=wi&url=${url}` |
| | | )}&response_type=code&scope=snsapi_login&state=${state}&href=data:text/css;base64,${base64}#wechat_redirect`; |
| | | wechatQrRef.value.src = wechatAuthUrl; |
| | | }; |
| | | |
| | | //切换用户登录页面 |
| | |
| | | state.activeLoginName = item; |
| | | switch (item) { |
| | | case 'wechat': |
| | | getWechartQrCode(); |
| | | // getWechartQrCode(); |
| | | openWechatLogin(); |
| | | break; |
| | | case 'accountUser': |
| | | break; |
| | |
| | | (val) => { |
| | | if (val && state.activeLoginName === 'wechat') { |
| | | nextTick(() => { |
| | | getWechartQrCode(); |
| | | openWechatLogin(); |
| | | }); |
| | | } |
| | | } |