feat:测试登陆页面

This commit is contained in:
dzc committed 2024-11-26 16:37:55 +08:00
1 parent 27f5a5fb8e
commit fa76e2c072
6 files changed
+159 -49

No files matched your search

+1 -2
View File
@@ -1,7 +1,6 @@
# ******************** start 开发环境 start ********************
#VITE_APP_DEV_SERVICE =http://localhost:48080/app-api
VITE_APP_DEV_SERVICE =https://stgl.pj.gov.cn/app-api
VITE_APP_DEV_SERVICE =http://localhost:48080/app-api
# VITE_APP_DEV_SERVICE =http://123.156.228.134:48080/app-api
# ******************** end 开发环境 end ********************
+12
View File
@@ -178,6 +178,18 @@
}
]
},
{
"root": "pages/test",
"pages": [
{
"path": "login",
"style": {
"navigationBarTitleText": "",
"disableScroll": true
}
}
]
},
{
"root": "pages/wallet",
"pages": [
+38 -37
View File
@@ -13,6 +13,7 @@ const data = {
// { text: '车牌管理', icon: '/static/icon/service_2.png', router: '/pages/user/diff-price' },
{ text: '外来人员就餐', icon: '/static/icon/service_1.png', router: '/pages/apply/foreign-list' },
{ text: '跨单位就餐', icon: '/static/icon/service_1.png', router: '/pages/apply/stride-list' },
{ text: '测试登陆', icon: '/static/icon/login.png', router: '/pages/test/login' },
]
};
@@ -23,29 +24,29 @@ const state = reactive<any>({
onLoad((options) => {
window.CP2.getAppInfo().then((res) => {
console.log(res);
if (res.code==1){
//诗画
console.log("诗画环境")
window.CP2.getUserInfo().then((res) => {
let accountId=res.data.accountId;
let sessionId=res.sessionId;
doLogin(1,null,accountId,sessionId)
});
}else {
//浙政钉或者h5
const url = window.location.href;
const params = new URL(url).searchParams;
const token = params.get('uabaseToken'); // 获取 uabaseToken 参数值
console.log('Token:', token);
if (null!=token){
//浙政钉
doLogin(2,token,null,null)
}
(window as any).CP2.getAppInfo().then((res) => {
console.log(res);
if (res.code == 1) {
//诗画
console.log("诗画环境");
(window as any).CP2.getUserInfo().then((res) => {
let accountId = res.data.accountId;
let sessionId = res.sessionId;
doLogin(1, null, accountId, sessionId)
});
} else {
//浙政钉或者h5
const url = window.location.href;
const params = new URL(url).searchParams;
const token = params.get('uabaseToken'); // 获取 uabaseToken 参数值
console.log('Token:', token);
if (null != token) {
//浙政钉
doLogin(2, token, null, null)
}
}
});
}
});
});
onShow(() => {
getUserInfo()
@@ -59,7 +60,7 @@ const getUserInfo = () => {
}
}
const doLogin = async (loginType,token, accountId, sessionId) => {
const doLogin = async (loginType, token, accountId, sessionId) => {
const tokenKey = constant.storageConstant.TOKEN
const userInfoKey = constant.storageConstant.USERINFO
const tokenStorage = uni.getStorageSync(tokenKey)
@@ -70,20 +71,20 @@ const doLogin = async (loginType,token, accountId, sessionId) => {
mask: true
});
let authData;
if (loginType==1){
// 诗画
const params = {
accountId:accountId,
sessionId:sessionId
}
const response = await userApi.authsh(params);
authData = response.data;
}else if (loginType==2){
//浙政钉
const response = await userApi.auth(token);
authData = response.data;
}else {
//后期手机号+验证码登录
if (loginType == 1) {
// 诗画
const params = {
accountId: accountId,
sessionId: sessionId
}
const response = await userApi.authsh(params);
authData = response.data;
} else if (loginType == 2) {
//浙政钉
const response = await userApi.auth(token);
authData = response.data;
} else {
//后期手机号+验证码登录
}
// const {data: authData} = await userApi.auth(token);
uni.setStorageSync(tokenKey, authData)
+89
View File
@@ -0,0 +1,89 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { hooks, constant, router } from "@@/index"
import { userApi } from "@@/api"
const data = {
}
const state = reactive<any>({
userInfo: null,
})
const applyForm = reactive<any>({
username: "",
password: "",
})
const applyFormRules = reactive<any>({
username: [
{ required: true, message: '请输入用户名' }
],
password: [
{ required: true, message: '请输入密码' }
],
})
onLoad(() => {
})
onShow(() => {
const userInfoKey = constant.storageConstant.USERINFO
state.userInfo = uni.getStorageSync(userInfoKey)
})
const applyFormRef = ref<any>(null)
const doSubmit = async () => {
applyFormRef.value.submit()
const { isPass } = applyFormRef.value.validate()
if (!isPass) return
const tokenKey = constant.storageConstant.TOKEN
const userInfoKey = constant.storageConstant.USERINFO
uni.showLoading({ title: '登录中...', mask: true });
try {
const _pa = { ...applyForm }
const { data } = await userApi.testLogin(_pa)
uni.setStorageSync(tokenKey, data)
const { data: userData } = await userApi.userInfo();
uni.setStorageSync(userInfoKey, userData)
} catch (e) {
console.log(e);
}
uni.hideLoading()
uni.showToast({ title: '登录成功', icon: "none" });
router.back()
}
</script>
<template>
<crud-layout title="登陆" bg="/static/page/blue-bg.png">
<view class="h-30rpx" />
<view class="card p-x-30rpx p-y-40rpx">
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
<tm-form-item name="username" label="用户名" :showBottom="false">
<tm-input v-model="applyForm.username" placeholder="请输入用户名.." />
</tm-form-item>
<view class="h-30rpx" />
<tm-form-item name="password" label="验证码" :showBottom="false">
<tm-input password v-model="applyForm.password" placeholder="请输入用户密码.." />
</tm-form-item>
</tm-form>
</view>
<view v-if="state.detailType != 'view'"
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doSubmit">
登陆
</view>
</crud-layout>
</template>
<style lang="scss" scoped>
:deep() {
.tmFormItemLabel {
padding-bottom: 10rpx !important;
}
}
</style>
+19 -10
View File
@@ -20,16 +20,16 @@ export default {
loadingMsg: "授权中",
},
}),
authsh: (params: any) =>
request({
url: `/sys/auth/shjnsso`,
method: "POST",
custom: {
showLoading: false,
loadingMsg: "授权中",
},
data:params,
}),
authsh: (params: any) =>
request({
url: `/sys/auth/shjnsso`,
method: "POST",
custom: {
showLoading: false,
loadingMsg: "授权中",
},
data: params,
}),
refreshToken: (params: any) =>
request({
url: `/sys/auth/refresh-token`,
@@ -39,4 +39,13 @@ export default {
showLoading: false,
},
}),
testLogin: (data: any) =>
request({
url: `/sys/auth/test-login`,
method: "POST",
data,
custom: {
showLoading: false,
},
}),
};
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB