Commit 4fff4973 by pangchong

feat: 接入amms

parent eedbab76
...@@ -2,10 +2,11 @@ import { ref, reactive } from 'vue' ...@@ -2,10 +2,11 @@ import { ref, reactive } from 'vue'
export const loginFormRef = ref() export const loginFormRef = ref()
//表单数据 //表单数据
export const loginForm = reactive({ export const loginForm = reactive({
username: 'devzj3', username: '', //devzj3
password: 'Ifar_9527008', password: '', //Ifar_9527008
verifyCode: '' verifyCode: ''
}) })
export const showLoad = ref(false)
export const loginCode = ref('') export const loginCode = ref('')
//表单规则 //表单规则
export const rules = reactive({ export const rules = reactive({
......
import { loginCode, loginForm } from './index.compositions' import { loginCode, loginForm, showLoad } from './index.compositions'
import { getGifCaptchaApi } from 'mocp/api/user' import { getGifCaptchaApi } from 'mocp/api/user'
//获取验证码 //获取验证码
...@@ -11,3 +11,31 @@ export const getGifCaptcha = async () => { ...@@ -11,3 +11,31 @@ export const getGifCaptcha = async () => {
loginCode.value = 'data:image/png;base64,' + uni.arrayBufferToBase64(res) loginCode.value = 'data:image/png;base64,' + uni.arrayBufferToBase64(res)
} }
} }
//接入amms
export const loginAmms = () => {
const ammsToken = uni.getStorageSync('access_token')
if (ammsToken) {
showLoad.value = true
uni.request({
url: `http://10.72.63.191:8080/mroapi/auth/oauth/check_token?token=${ammsToken}`,
method: 'GET',
header: {
Authorization: 'Basic YXBwOmVraW5n'
}
})
.then(function (res) {
showLoad.value = false
if (res.username) {
loginForm.username = res.username
loginForm.verifyCode = 'Mocp_DebuG_9527_8341'
loginForm.password = 'Ifar2016_0525'
handleLogin()
}
})
.catch(function (reason) {
showLoad.value = false
console.log('AMMS跳转登录出现错误', reason)
})
}
}
<template> <template>
<global-page :showNavbar="false"> <up-loading-page :loading="showLoad" loading-text="跳转中,请耐心等待..." font-size="14"></up-loading-page>
<global-page :showNavbar="false" v-if="!showLoad">
<view class="login-wrap"> <view class="login-wrap">
<view class="login-header"> <view class="login-header">
<image src="/static/mocp/image/login/Vector.png" /> <image src="/static/mocp/image/login/Vector.png" />
...@@ -39,8 +40,8 @@ ...@@ -39,8 +40,8 @@
<script setup> <script setup>
import { debounce } from 'lodash' import { debounce } from 'lodash'
import { loginCode, loginForm, rules, loginFormRef } from './constants/index.compositions' import { loginCode, loginForm, rules, loginFormRef, showLoad } from './constants/index.compositions'
import { getGifCaptcha } from './constants/index.functionals' import { getGifCaptcha, loginAmms } from './constants/index.functionals'
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import { ref, toRaw, watch } from 'vue' import { ref, toRaw, watch } from 'vue'
import useUserStore from 'mocp/store/user' import useUserStore from 'mocp/store/user'
...@@ -54,9 +55,11 @@ watch( ...@@ -54,9 +55,11 @@ watch(
} }
}, 500) }, 500)
) )
onLoad(() => { onLoad(() => {
loginForm.verifyCode = '' loginForm.verifyCode = ''
getGifCaptcha() getGifCaptcha()
loginAmms()
}) })
//登录 //登录
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment