iws登录
This commit is contained in:
parent
36988d6dde
commit
36300fa7e9
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<!-- 登录页面 -->
|
<!-- 登录页面 -->
|
||||||
<view class="login">
|
<view class="login" v-if="origin.indexOf('ticket') == -1">
|
||||||
<uni-forms :modelValue="loginForm" label-position="top" class="login-form">
|
<uni-forms :modelValue="loginForm" label-position="top" class="login-form">
|
||||||
<h1>用户登录</h1>
|
<h1>用户登录</h1>
|
||||||
<uni-forms-item required label="用户名">
|
<uni-forms-item required label="用户名">
|
||||||
|
|
@ -21,10 +21,10 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
import { appLoginAPI, getUserInfoAPI } from '@/services/index.js'
|
import { appLoginAPI, getUserInfoAPI, iwsLoginAPI } from '@/services/index.js'
|
||||||
import { useMemberStore } from '@/stores'
|
import { useMemberStore } from '@/stores'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
|
||||||
const memberStore = useMemberStore()
|
const memberStore = useMemberStore()
|
||||||
|
const origin = window.location.href
|
||||||
|
|
||||||
// 登录参数
|
// 登录参数
|
||||||
const loginForm = reactive({
|
const loginForm = reactive({
|
||||||
|
|
@ -37,6 +37,43 @@ const loginForm = reactive({
|
||||||
verificationCode: '',
|
verificationCode: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
console.log('🚀 ~ onMounted ~ origin:', origin)
|
||||||
|
// uni.showToast({
|
||||||
|
// title: origin,
|
||||||
|
// icon: 'none',
|
||||||
|
// duration: 5000,
|
||||||
|
// })
|
||||||
|
if (origin.indexOf('ticket') != -1) {
|
||||||
|
try {
|
||||||
|
uni.showLoading({ title: '登录中' })
|
||||||
|
|
||||||
|
const { data: result } = await iwsLoginAPI({
|
||||||
|
ticket: origin.split('ticket=')[1].split('#/')[0],
|
||||||
|
sysType: 1,
|
||||||
|
})
|
||||||
|
|
||||||
|
// 1. 获取 token 并存储
|
||||||
|
memberStore.setToken(result.access_token)
|
||||||
|
// 2 . 获取用户信息并存储
|
||||||
|
const res = await getUserInfoAPI()
|
||||||
|
memberStore.setUserInfo(res.user)
|
||||||
|
uni.showToast({ title: '登录成功!', icon: 'none' })
|
||||||
|
uni.setStorageSync('username', loginForm.username)
|
||||||
|
uni.setStorageSync('password', loginForm.password)
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.switchTab({
|
||||||
|
url: '/pages/index/index',
|
||||||
|
})
|
||||||
|
}, 500)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
uni.hideLoading()
|
||||||
|
showToast('登录失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// 登录按钮
|
// 登录按钮
|
||||||
const onHandleLogin = async () => {
|
const onHandleLogin = async () => {
|
||||||
const res = await appLoginAPI(loginForm)
|
const res = await appLoginAPI(loginForm)
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,13 @@ export const getMaCodeByQrCodeApi = (data) => {
|
||||||
url: '/material/bm_qrcode_box/get_ma_info_by_qrcode',
|
url: '/material/bm_qrcode_box/get_ma_info_by_qrcode',
|
||||||
data,
|
data,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// iws登录接口
|
||||||
|
export const iwsLoginAPI = (data) => {
|
||||||
|
return http({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/auth/iwsLogin',
|
||||||
|
data,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue