app登录方式修改 增加劳动合同号

This commit is contained in:
yangzhq68909 2025-09-03 15:17:38 +08:00
parent 8acb78320c
commit c97b130da9
7 changed files with 117 additions and 66 deletions

View File

@ -7,7 +7,7 @@ VITE_SHOW_SOURCEMAP = true
# 是否启用读取配置文件 min
#VITE_WEBAPP = 'D://opt//AppUpdateTest'
VITE_WEBAPP = ''
VITE_SERVER_BASEURL = 'http://10.75.15.247:8080/jeecg-boot'
VITE_SERVER_BASEURL = 'http://10.96.108.144:8080/jeecg-boot'
#VITE_SERVER_BASEURL = 'https://36.112.48.190/jeecg-boot'
#VITE_SERVER_BASEURL = 'https://szcx.zyyt.sinopec.com/jeecg-boot'

View File

@ -17,8 +17,8 @@ export default defineManifestConfig({
name: VITE_APP_TITLE,
appid: VITE_UNI_APPID,
description: '',
versionName: '2.1.0',
versionCode: '20250808',
versionName: '2.2.0',
versionCode: '20250903',
transformPx: false,
locale: VITE_FALLBACK_LOCALE, // 'zh-Hans'
/* 5+App特有相关 */

View File

@ -13,6 +13,7 @@ interface LoginParams {
*/
export function loginApi(config : LoginParams) {
// captcha/sys/login,/sys/sinopecLogin
console.log('----',config)
const url = config.captcha ? '/sys/login' : '/sys/sinopecLogin';
return http({
url,

View File

@ -9,9 +9,7 @@ export function queryPostByUserIdApi(userid : string) {
return http({
url: '/sys/user/queryPostByUserId',
method: 'GET',
data: {
userid
}
data: { userid }
});
}
@ -36,3 +34,12 @@ export function queryUserByOrgRoleApi(config : object) {
data: config
})
}
/*根据劳动合同号查询用户信息*/
export function queryUsernameByLdhth(ldhth : string) {
return http({
url: '/sys/user/queryUsernameByLdhth',
method: 'GET',
data: { ldhth }
})
}

View File

@ -2,8 +2,8 @@
"name": "数智产销",
"appid": "__UNI__9F097F0",
"description": "",
"versionName": "2.1.0",
"versionCode": "20250808",
"versionName": "2.2.0",
"versionCode": "20250903",
"transformPx": false,
"app-plus": {
"usingComponents": true,

View File

@ -17,13 +17,13 @@
<view class="account-login-area">
<view class="box account">
<wd-icon name="user" size="15px"></wd-icon>
<wd-text text="账号:"></wd-text>
<wd-input class="uni-input" placeholder="请输入统一身份认证" v-model.trim="userName"></wd-input>
<wd-text text=""></wd-text>
<wd-input class="uni-input" placeholder="统一身份/劳动合同号" v-model.trim="userName"></wd-input>
</view>
<view class="box password">
<wd-icon name="lock-on" size="15px"></wd-icon>
<wd-text text="密码:"></wd-text>
<input class="uni-input" placeholder="请输入密码" :password="showPassword"
<wd-text text=""></wd-text>
<input class="uni-input" placeholder="密码" :password="showPassword"
v-model.trim="password" />
<wd-icon v-if="showPassword" name="eye-close" size="18px"
@click="handleChangePassword"></wd-icon>
@ -52,15 +52,32 @@
</PageLayout>
</template>
<script lang="ts" setup>
import { useToast } from 'wot-design-uni'
import { ref } from 'vue'
import { useUserStore } from '@/store/user'
import { http } from '@/utils/http'
import { HOME_PAGE } from '@/common/constants'
import { useRouter } from '@/plugin/uni-mini-router'
<script setup>
import {
useToast
} from 'wot-design-uni'
import {
ref
} from 'vue'
import {
useUserStore
} from '@/store/user'
import {
http
} from '@/utils/http'
import {
HOME_PAGE
} from '@/common/constants'
import {
useRouter
} from '@/plugin/uni-mini-router'
import Base64 from 'base-64';
import { loginApi } from '@/api/system';
import {
loginApi
} from '@/api/system';
import {
queryUsernameByLdhth
} from '@/api/system/user';
defineOptions({
name: 'login',
@ -75,7 +92,8 @@
const showPassword = ref(true) //
const remPW = ref(false) //
/**h5系统信息中没有appWgtVersion值*/
const version = uni.getSystemInfoSync().appWgtVersion ? uni.getSystemInfoSync().appWgtVersion : uni.getSystemInfoSync().appVersion
const version = uni.getSystemInfoSync().appWgtVersion ? uni.getSystemInfoSync().appWgtVersion : uni.getSystemInfoSync()
.appVersion
const toast = useToast()
const userStore = useUserStore()
const handleChangePassword = () => {
@ -92,58 +110,85 @@
uni.setStorageSync('accountpassword', JSON.stringify(localObj))
uni.setStorageSync('savePwd', remPW.value)
}
const handleLogin = () => {
const handleLogin = async () => {
if (userName.value.length === 0) {
toast.warning('请输入统一身份认证')
toast.warning('请输入统一身份/劳动合同号')
return
}
if (password.value.length === 0) {
toast.warning('请输入密码')
return
}
let un = Base64.encode(encodeURIComponent(userName.value))
let pw = Base64.encode(encodeURIComponent(password.value))
loading.value = true
/*生产环境 begin */
// loginApi({ username: un, password: pw })
/*开发环境 begin */
loginApi({ username: userName.value, password: password.value, captcha: 'app' })
.then((res : any) => {
if (res.success) {
const { result } = res
const userInfo = result.userInfo
userStore.setUserInfo({
...userInfo,
token: result.token,
userid: userInfo.id,
username: userInfo.username,
realname: userInfo.realname,
avatar: userInfo.avatar,
post: userInfo.post,
tenantId: userInfo.loginTenantId,
localStorageTime: +new Date(),
})
savePwd() //
uni.setStorageSync('logintime', Date.now()) //
router.pushTab({ path: HOME_PAGE })
const params = {
username: userName.value,
password: password.value,
};
/*判断是否是六位纯数字*/
if (userName.value.match(/^\d{6}$/)) {
await queryUsernameByLdhth(userName.value).then(res => {
if (res) {
params = {
username: Base64.encode(encodeURIComponent(userName.value)),
password: Base64.encode(encodeURIComponent(password.value)),
};
} else {
res.message == '数据库中已存在该记录' ? res.message = '请使用统一身份账号登录' : res.message
if (!res.success) {
try {
// JSON message JSON
const response = JSON.parse(res.message);
if (response.error_description === '用户名或密码错误') {
res.message = '用户名或密码错误';
}
} catch (e) {
}
}
toast.warning(res.message)
params.captcha = 'app';
}
})
.finally(() => {
loading.value = false
})
} else {
/*开发环境 */
// params.captcha = 'app';
/*生产环境 */
params = {
username: Base64.encode(encodeURIComponent(userName.value)),
password: Base64.encode(encodeURIComponent(password.value)),
};
}
login(params)
}
const login = async (params) => {
loading.value = true
try {
// API
const res = await loginApi(params);
if (res.success) {
const {
result
} = res
const userInfo = result.userInfo
userStore.setUserInfo({
...userInfo,
token: result.token,
userid: userInfo.id,
username: userInfo.username,
realname: userInfo.realname,
avatar: userInfo.avatar,
post: userInfo.post,
tenantId: userInfo.loginTenantId,
localStorageTime: +new Date(),
})
savePwd() //
uni.setStorageSync('logintime', Date.now()) //
router.pushTab({
path: HOME_PAGE
})
} else {
res.message == '数据库中已存在该记录' ? res.message = '请使用统一身份账号登录' : res.message
if (!res.success) {
try {
// JSON message JSON
const response = JSON.parse(res.message);
if (response.error_description === '用户名或密码错误') {
res.message = '用户名或密码错误';
}
} catch (e) {}
}
toast.warning(res.message)
}
} finally {
loading.value = false;
}
}
onLoad(() => {

View File

@ -235,9 +235,7 @@ export const useUpdateApp = defineStore('updateApp', () => {
if (webApp) {// upDateAppApi by min
path = webApp
}
console.log(22222222222222222)
upDateAppApi(path).then(async (res : any) => {
console.log(3333333333)
let {
result
} = res