接口调试
This commit is contained in:
parent
d4250fa50b
commit
8b8d1c0fc1
|
|
@ -24,6 +24,7 @@
|
||||||
"@dcloudio/uni-mp-xhs": "3.0.0-4050720250324001",
|
"@dcloudio/uni-mp-xhs": "3.0.0-4050720250324001",
|
||||||
"@dcloudio/uni-quickapp-webview": "3.0.0-4050720250324001",
|
"@dcloudio/uni-quickapp-webview": "3.0.0-4050720250324001",
|
||||||
"clipboard": "^2.0.11",
|
"clipboard": "^2.0.11",
|
||||||
|
"crypto-js": "^4.2.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"pinia": "^2.3.0",
|
"pinia": "^2.3.0",
|
||||||
|
|
@ -49,7 +50,8 @@
|
||||||
"sass": "^1.63.2",
|
"sass": "^1.63.2",
|
||||||
"sass-loader": "^10.4.1",
|
"sass-loader": "^10.4.1",
|
||||||
"vite": "5.2.8",
|
"vite": "5.2.8",
|
||||||
"vite-plugin-eslint": "^1.8.1"
|
"vite-plugin-eslint": "^1.8.1",
|
||||||
|
"vite-plugin-remove-console": "^2.2.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@ampproject/remapping": {
|
"node_modules/@ampproject/remapping": {
|
||||||
|
|
@ -6110,6 +6112,11 @@
|
||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/crypto-js": {
|
||||||
|
"version": "4.2.0",
|
||||||
|
"resolved": "https://repo.huaweicloud.com/repository/npm/crypto-js/-/crypto-js-4.2.0.tgz",
|
||||||
|
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
|
||||||
|
},
|
||||||
"node_modules/css-font-size-keywords": {
|
"node_modules/css-font-size-keywords": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://repo.huaweicloud.com/repository/npm/css-font-size-keywords/-/css-font-size-keywords-1.0.0.tgz",
|
"resolved": "https://repo.huaweicloud.com/repository/npm/css-font-size-keywords/-/css-font-size-keywords-1.0.0.tgz",
|
||||||
|
|
@ -12157,6 +12164,12 @@
|
||||||
"fsevents": "~2.3.2"
|
"fsevents": "~2.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/vite-plugin-remove-console": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://repo.huaweicloud.com/repository/npm/vite-plugin-remove-console/-/vite-plugin-remove-console-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-qgjh5pz75MdE9Kzs8J0kBwaCfifHV0ezRbB9rpGsIOxam+ilcGV7WOk91vFJXquzRmiKrFh3Hxlh0JJWAmXTbQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/vue": {
|
"node_modules/vue": {
|
||||||
"version": "3.5.13",
|
"version": "3.5.13",
|
||||||
"resolved": "https://repo.huaweicloud.com/repository/npm/vue/-/vue-3.5.13.tgz",
|
"resolved": "https://repo.huaweicloud.com/repository/npm/vue/-/vue-3.5.13.tgz",
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@
|
||||||
"@dcloudio/uni-mp-xhs": "3.0.0-4050720250324001",
|
"@dcloudio/uni-mp-xhs": "3.0.0-4050720250324001",
|
||||||
"@dcloudio/uni-quickapp-webview": "3.0.0-4050720250324001",
|
"@dcloudio/uni-quickapp-webview": "3.0.0-4050720250324001",
|
||||||
"clipboard": "^2.0.11",
|
"clipboard": "^2.0.11",
|
||||||
|
"crypto-js": "^4.2.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"pinia": "^2.3.0",
|
"pinia": "^2.3.0",
|
||||||
|
|
@ -75,6 +76,7 @@
|
||||||
"sass": "^1.63.2",
|
"sass": "^1.63.2",
|
||||||
"sass-loader": "^10.4.1",
|
"sass-loader": "^10.4.1",
|
||||||
"vite": "5.2.8",
|
"vite": "5.2.8",
|
||||||
"vite-plugin-eslint": "^1.8.1"
|
"vite-plugin-eslint": "^1.8.1",
|
||||||
|
"vite-plugin-remove-console": "^2.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
<up-input
|
<up-input
|
||||||
clearable
|
clearable
|
||||||
prefixIcon="account"
|
prefixIcon="account"
|
||||||
placeholder="填输入登录手机号"
|
placeholder="填输入手机号"
|
||||||
v-model="opinionModel.username"
|
v-model="opinionModel.username"
|
||||||
/>
|
/>
|
||||||
</up-form-item>
|
</up-form-item>
|
||||||
|
|
@ -47,13 +47,26 @@
|
||||||
<up-button type="primary" text="登录" @tap="onSubmitLogin" shape="circle" />
|
<up-button type="primary" text="登录" @tap="onSubmitLogin" shape="circle" />
|
||||||
</up-form-item>
|
</up-form-item>
|
||||||
</up-form>
|
</up-form>
|
||||||
|
<up-loading-page
|
||||||
|
color="#333"
|
||||||
|
fontSize="16"
|
||||||
|
loadingColor="#2979ff"
|
||||||
|
:loading="sendLoading"
|
||||||
|
bg-color="rgba(0,0,0,0.5)"
|
||||||
|
loading-text="正在登录..."
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { loginApi } from '@/services/login.js'
|
import { debounce } from 'lodash-es' // 引入防抖函数
|
||||||
const showPassword = ref(false)
|
import { useMemberStore } from '@/stores'
|
||||||
|
import { loginApi, getUserInfoApi } from '@/services/login.js'
|
||||||
|
|
||||||
|
const showPassword = ref(false) // 密码是否可见
|
||||||
|
const sendLoading = ref(false) // 加载中
|
||||||
|
const memberStore = useMemberStore() // 用户信息
|
||||||
|
|
||||||
// 表单数据源
|
// 表单数据源
|
||||||
const opinionModel = ref({
|
const opinionModel = ref({
|
||||||
|
|
@ -66,17 +79,17 @@ const opinionRules = ref({
|
||||||
{
|
{
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
message: '请填写账号',
|
message: '请填写手机号',
|
||||||
trigger: ['blur', 'change'],
|
trigger: ['blur', 'change'],
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// pattern: /^[\u4e00-\u9fa5]{2,6}$/,
|
pattern: /^(1\d{10}|!Admin)$/,
|
||||||
// // 正则检验前先将值转为字符串
|
// 正则检验前先将值转为字符串
|
||||||
// transform(value) {
|
transform(value) {
|
||||||
// return String(value)
|
return String(value)
|
||||||
// },
|
},
|
||||||
// message: '请填写正确的姓名',
|
message: '请填写正确手机号',
|
||||||
// },
|
},
|
||||||
],
|
],
|
||||||
password: [
|
password: [
|
||||||
{
|
{
|
||||||
|
|
@ -98,35 +111,63 @@ const isSuccess = ref(false)
|
||||||
const showModal = ref(false)
|
const showModal = ref(false)
|
||||||
|
|
||||||
// 提交按钮
|
// 提交按钮
|
||||||
const onSubmitLogin = () => {
|
const onSubmitLogin = debounce(() => {
|
||||||
|
sendLoading.value = true
|
||||||
loginModelRef.value
|
loginModelRef.value
|
||||||
.validate()
|
.validate()
|
||||||
.then(async (valid) => {
|
.then(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
uni.$u.toast('登录成功')
|
console.log(
|
||||||
setTimeout(() => {
|
'%c🔍 登录请求入参 %c',
|
||||||
// uni.switchTab({ url: '/pages/workbenches/index' })
|
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||||
uni.switchTab({ url: '/pages/workbenches/index' })
|
'',
|
||||||
}, 500)
|
opinionModel.value,
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await loginApi(opinionModel.value)
|
||||||
|
console.log(
|
||||||
|
'%c🔍 登录请求出参 %c',
|
||||||
|
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||||
|
'',
|
||||||
|
res,
|
||||||
|
)
|
||||||
|
sendLoading.value = false
|
||||||
|
if (res.code === 200) {
|
||||||
|
memberStore.setToken(res.token)
|
||||||
|
uni.$u.toast('登录成功')
|
||||||
|
getUserInfo()
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.switchTab({ url: '/pages/workbenches/index' })
|
||||||
|
}, 500)
|
||||||
|
} else {
|
||||||
|
uni.$u.toast('登录失败' + res.message)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
sendLoading.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// 处理验证错误
|
// 处理验证错误
|
||||||
})
|
})
|
||||||
}
|
}, 500)
|
||||||
|
|
||||||
// 继续填写
|
// 获取用户信息
|
||||||
const onContinueFill = () => {
|
const getUserInfo = () => {
|
||||||
isSuccess.value = false
|
getUserInfoApi().then((res) => {
|
||||||
}
|
if (res.code === 200) {
|
||||||
// 退出
|
console.log(
|
||||||
const onExit = () => {
|
'%c🔍 用户信息请求出参 %c',
|
||||||
showModal.value = true
|
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||||
}
|
'',
|
||||||
|
res,
|
||||||
|
)
|
||||||
|
|
||||||
// 确认退出
|
// 存储用户信息
|
||||||
const onConfirm = () => {
|
memberStore.setUserInfo(res.data)
|
||||||
uni.redirectTo({ url: '/pages/index/index' })
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,19 +18,19 @@
|
||||||
>
|
>
|
||||||
<up-form-item prop="username">
|
<up-form-item prop="username">
|
||||||
<up-input
|
<up-input
|
||||||
|
readonly
|
||||||
clearable
|
clearable
|
||||||
prefixIcon="account"
|
prefixIcon="account"
|
||||||
placeholder="填输入手机号"
|
|
||||||
v-model="editPasswordModel.username"
|
v-model="editPasswordModel.username"
|
||||||
/>
|
/>
|
||||||
</up-form-item>
|
</up-form-item>
|
||||||
<up-form-item prop="password">
|
<up-form-item prop="oldP">
|
||||||
<up-input
|
<up-input
|
||||||
clearable
|
clearable
|
||||||
prefixIcon="lock"
|
prefixIcon="lock"
|
||||||
:password="!showPassword_1"
|
:password="!showPassword_1"
|
||||||
placeholder="填输入密码"
|
placeholder="填输入原密码"
|
||||||
v-model="editPasswordModel.password"
|
v-model="editPasswordModel.oldP"
|
||||||
>
|
>
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
<u-icon
|
<u-icon
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
clearable
|
clearable
|
||||||
prefixIcon="lock"
|
prefixIcon="lock"
|
||||||
:password="!showPassword_2"
|
:password="!showPassword_2"
|
||||||
placeholder="填输入8-20位新密码"
|
placeholder="请输入8-20位新密码"
|
||||||
v-model="editPasswordAgainModel.newPassword"
|
v-model="editPasswordAgainModel.newPassword"
|
||||||
>
|
>
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
clearable
|
clearable
|
||||||
prefixIcon="lock"
|
prefixIcon="lock"
|
||||||
:password="!showPassword_3"
|
:password="!showPassword_3"
|
||||||
placeholder="填再次输入8-20位新密码"
|
placeholder="请再次输入8-20位新密码"
|
||||||
v-model="editPasswordAgainModel.newPasswordAgain"
|
v-model="editPasswordAgainModel.newPasswordAgain"
|
||||||
>
|
>
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
|
|
@ -122,7 +122,10 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { nextTick, ref } from 'vue'
|
import { nextTick, ref } from 'vue'
|
||||||
|
import { useMemberStore } from '@/stores'
|
||||||
|
import { checkPasswordApi, editPasswordApi } from '@/services/my.js'
|
||||||
|
|
||||||
|
const memberStore = useMemberStore() // 用户信息
|
||||||
const showPassword_1 = ref(false) // 密码是否显示
|
const showPassword_1 = ref(false) // 密码是否显示
|
||||||
const showPassword_2 = ref(false) // 密码是否显示
|
const showPassword_2 = ref(false) // 密码是否显示
|
||||||
const showPassword_3 = ref(false) // 密码是否显示
|
const showPassword_3 = ref(false) // 密码是否显示
|
||||||
|
|
@ -130,9 +133,10 @@ const currenSteps = ref(0) // 步骤索引
|
||||||
const countDownRef = ref(null) // 倒计时组件
|
const countDownRef = ref(null) // 倒计时组件
|
||||||
const editPasswordRef = ref(null) // 密码表单
|
const editPasswordRef = ref(null) // 密码表单
|
||||||
const editPasswordAgainRef = ref(null) // 重复密码表单
|
const editPasswordAgainRef = ref(null) // 重复密码表单
|
||||||
|
|
||||||
const editPasswordModel = ref({
|
const editPasswordModel = ref({
|
||||||
username: '',
|
username: memberStore.userInfo.loginName || '',
|
||||||
password: '',
|
oldP: '',
|
||||||
})
|
})
|
||||||
const editPasswordAgainModel = ref({
|
const editPasswordAgainModel = ref({
|
||||||
newPassword: '',
|
newPassword: '',
|
||||||
|
|
@ -146,12 +150,20 @@ const editPasswordRules = ref({
|
||||||
trigger: ['blur', 'change'],
|
trigger: ['blur', 'change'],
|
||||||
message: '请输入手机号',
|
message: '请输入手机号',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
pattern: /^(1\d{10}|!Admin)$/,
|
||||||
|
// 正则检验前先将值转为字符串
|
||||||
|
transform(value) {
|
||||||
|
return String(value)
|
||||||
|
},
|
||||||
|
message: '请填写正确手机号',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
password: [
|
password: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
trigger: ['blur', 'change'],
|
trigger: ['blur', 'change'],
|
||||||
message: '请输入密码',
|
message: '请输入原密码',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
@ -195,7 +207,25 @@ const onHandleNext = () => {
|
||||||
.validate()
|
.validate()
|
||||||
.then(async (valid) => {
|
.then(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
currenSteps.value++
|
console.log(
|
||||||
|
'%c🔍 校验原密码请求入参 %c',
|
||||||
|
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||||
|
'',
|
||||||
|
editPasswordModel.value.oldP,
|
||||||
|
)
|
||||||
|
// 调后台接口判断原密码是否正确
|
||||||
|
const res = await checkPasswordApi({ oldP: editPasswordModel.value.oldP })
|
||||||
|
console.log(
|
||||||
|
'%c🔍 校验原密码请求出参 %c',
|
||||||
|
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||||
|
'',
|
||||||
|
res,
|
||||||
|
)
|
||||||
|
if (res.code === 200) {
|
||||||
|
currenSteps.value++
|
||||||
|
} else {
|
||||||
|
uni.$u.toast('验证失败' + res.msg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|
@ -203,18 +233,41 @@ const onHandleNext = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 确定
|
// 确定
|
||||||
const onHandleSubmit = async () => {
|
const onHandleSubmit = () => {
|
||||||
editPasswordAgainRef.value
|
editPasswordAgainRef.value
|
||||||
.validate()
|
.validate()
|
||||||
.then(async (valid) => {
|
.then(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
currenSteps.value++
|
// 调后台接口修改密码
|
||||||
// 开启倒计时
|
const editParams = {
|
||||||
nextTick(() => {
|
password: editPasswordAgainModel.value.newPassword,
|
||||||
if (countDownRef.value) {
|
id: memberStore.userInfo.id,
|
||||||
countDownRef.value.start()
|
}
|
||||||
}
|
console.log(
|
||||||
})
|
'%c🔍 修改密码请求入参 %c',
|
||||||
|
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||||
|
'',
|
||||||
|
editParams,
|
||||||
|
)
|
||||||
|
const res = await editPasswordApi(editParams)
|
||||||
|
console.log(
|
||||||
|
'%c🔍 修改密码请求出参 %c',
|
||||||
|
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||||
|
'',
|
||||||
|
res,
|
||||||
|
)
|
||||||
|
|
||||||
|
if (res.code === 200) {
|
||||||
|
uni.$u.toast('密码修改成功')
|
||||||
|
currenSteps.value++
|
||||||
|
nextTick(() => {
|
||||||
|
if (countDownRef.value) {
|
||||||
|
countDownRef.value.start()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.$u.toast('修改失败' + res.msg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,10 @@
|
||||||
|
|
||||||
<view class="my-info-right">
|
<view class="my-info-right">
|
||||||
<view class="my-info-name">
|
<view class="my-info-name">
|
||||||
<text>用户名</text>
|
<text>{{ userInfo.username }}</text>
|
||||||
<text class="my-info-name-job">项目经理</text>
|
<text class="my-info-name-job">{{ userInfo.roleName || '无' }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view style="color: #999"> 139****5213 </view>
|
<view style="color: #999"> {{ userInfo.loginName }} </view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
@ -22,9 +22,9 @@
|
||||||
<view class="my-info-list">
|
<view class="my-info-list">
|
||||||
<up-cell-group>
|
<up-cell-group>
|
||||||
<up-cell
|
<up-cell
|
||||||
|
isLink
|
||||||
size="large"
|
size="large"
|
||||||
title="修改密码"
|
title="修改密码"
|
||||||
isLink
|
|
||||||
class="edit-password"
|
class="edit-password"
|
||||||
@tap="onEditPassWord"
|
@tap="onEditPassWord"
|
||||||
>
|
>
|
||||||
|
|
@ -42,17 +42,21 @@
|
||||||
title="温馨提示"
|
title="温馨提示"
|
||||||
:show="showModalLogout"
|
:show="showModalLogout"
|
||||||
:showCancelButton="true"
|
:showCancelButton="true"
|
||||||
content="是否确认退出当前账号?"
|
|
||||||
@confirm="onConfirmLogout"
|
|
||||||
@cancel="onCancelLogout"
|
@cancel="onCancelLogout"
|
||||||
|
@confirm="onConfirmLogout"
|
||||||
|
content="是否确认退出当前账号?"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { reactive, ref, watch } from 'vue'
|
||||||
|
import { useMemberStore } from '@/stores'
|
||||||
|
|
||||||
const showModalLogout = ref(false)
|
const showModalLogout = ref(false)
|
||||||
|
const memberStore = useMemberStore() // 用户信息
|
||||||
|
|
||||||
|
const userInfo = ref(memberStore.userInfo || {})
|
||||||
|
|
||||||
// 修改密码
|
// 修改密码
|
||||||
const onEditPassWord = () => {
|
const onEditPassWord = () => {
|
||||||
|
|
@ -66,8 +70,8 @@ const onLogOut = () => {
|
||||||
}
|
}
|
||||||
// 确认退出
|
// 确认退出
|
||||||
const onConfirmLogout = () => {
|
const onConfirmLogout = () => {
|
||||||
uni.removeStorageSync('token')
|
memberStore.clearUserInfo() // 清除用户信息
|
||||||
uni.removeStorageSync('userInfo')
|
memberStore.clearToken() // 清除token
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url: '/pages/login/index',
|
url: '/pages/login/index',
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { useMemberStore } from '@/stores'
|
||||||
import iconCard from './components/icon-card.vue'
|
import iconCard from './components/icon-card.vue'
|
||||||
import icon_1 from '../../static/image/home_1.png'
|
import icon_1 from '../../static/image/home_1.png'
|
||||||
import icon_2 from '../../static/image/home_2.png'
|
import icon_2 from '../../static/image/home_2.png'
|
||||||
|
|
@ -16,6 +17,9 @@ import icon_4 from '../../static/image/home_4.png'
|
||||||
import icon_5 from '../../static/image/home_5.png'
|
import icon_5 from '../../static/image/home_5.png'
|
||||||
import icon_6 from '../../static/image/home_6.png'
|
import icon_6 from '../../static/image/home_6.png'
|
||||||
|
|
||||||
|
const memberStore = useMemberStore() // 用户信息
|
||||||
|
const userPermissions = ref(memberStore.userInfo.permissions || [])
|
||||||
|
|
||||||
const iconList_1 = ref([
|
const iconList_1 = ref([
|
||||||
{
|
{
|
||||||
jumpPath: '/pages/safetyViolations/index',
|
jumpPath: '/pages/safetyViolations/index',
|
||||||
|
|
@ -50,12 +54,14 @@ const iconList_2 = ref([
|
||||||
iconUrl: icon_6,
|
iconUrl: icon_6,
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
if (userPermissions.value.length > 0) {
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.workbenches-container {
|
.workbenches-container {
|
||||||
// height: 100%;
|
height: 100%;
|
||||||
// height: 100vh;
|
|
||||||
background-color: #f6f9ff;
|
background-color: #f6f9ff;
|
||||||
padding-bottom: 60px;
|
padding-bottom: 60px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,17 @@ export const loginApi = (data) => {
|
||||||
return http({
|
return http({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/imgTool/login',
|
url: '/imgTool/login',
|
||||||
|
isEncrypt: true,
|
||||||
data,
|
data,
|
||||||
|
header: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 获取用户信息
|
||||||
|
export const getUserInfoApi = () => {
|
||||||
|
return http({
|
||||||
|
method: 'GET',
|
||||||
|
url: '/imgTool/users/current',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { http } from '@/utils/http'
|
||||||
|
|
||||||
|
// 原密码校验接口
|
||||||
|
export const checkPasswordApi = (data) => {
|
||||||
|
return http({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/imgTool/users/checkPassword',
|
||||||
|
data,
|
||||||
|
header: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 修改密码
|
||||||
|
export const editPasswordApi = (data) => {
|
||||||
|
return http({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/imgTool/users/password',
|
||||||
|
data,
|
||||||
|
header: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
// 加解密方法
|
||||||
|
import CryptoJS from 'crypto-js'
|
||||||
|
|
||||||
|
const key = 'zhst@bonus@zhst@bonus@1234567890' // 加密密钥
|
||||||
|
const utf8Key = CryptoJS.enc.Utf8.parse(key)
|
||||||
|
|
||||||
|
// AES 加密(UTF-8 处理)
|
||||||
|
export const encrypt = (message) => {
|
||||||
|
const utf8Message = CryptoJS.enc.Utf8.parse(message)
|
||||||
|
const cbc_iv = CryptoJS.enc.Utf8.parse('1234567812345678')
|
||||||
|
const encrypted = CryptoJS.AES.encrypt(utf8Message, utf8Key, {
|
||||||
|
iv: cbc_iv,
|
||||||
|
mode: CryptoJS.mode.CBC,
|
||||||
|
padding: CryptoJS.pad.Pkcs7,
|
||||||
|
})
|
||||||
|
return encrypted.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
// AES 解密
|
||||||
|
export const decrypt = (encryptedBase64) => {
|
||||||
|
const decrypted = CryptoJS.AES.decrypt(encryptedBase64, utf8Key, {
|
||||||
|
iv: cbc_iv,
|
||||||
|
mode: CryptoJS.mode.CBC,
|
||||||
|
padding: CryptoJS.pad.Pkcs7,
|
||||||
|
})
|
||||||
|
return CryptoJS.enc.Utf8.stringify(decrypted)
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import { useMemberStore } from '@/stores'
|
import { useMemberStore } from '@/stores'
|
||||||
|
import { encrypt, decrypt } from './encrypt' // 引入加解密方法
|
||||||
|
import { cloneDeep } from 'lodash-es' // 引入深拷贝函数
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加拦截器
|
* 添加拦截器
|
||||||
|
|
@ -19,6 +21,19 @@ const httpInterceptor = {
|
||||||
options.url = baseURL + options.url
|
options.url = baseURL + options.url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.isEncrypt) {
|
||||||
|
if (options.data) {
|
||||||
|
options.data = cloneDeep(options.data) // 参数深拷贝 避免影响视图
|
||||||
|
for (const key in options.data) {
|
||||||
|
options.data[key] = encrypt(options.data[key])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
options.data = {
|
||||||
|
encryptedData: encrypt(JSON.stringify(options.data)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 2. 设置请求超时时间,默认为60s,设置为 10s
|
// 2. 设置请求超时时间,默认为60s,设置为 10s
|
||||||
options.timeout = 10000
|
options.timeout = 10000
|
||||||
|
|
||||||
|
|
@ -33,6 +48,7 @@ const httpInterceptor = {
|
||||||
const token = memberStore.token
|
const token = memberStore.token
|
||||||
if (token) {
|
if (token) {
|
||||||
options.header.Authorization = token
|
options.header.Authorization = token
|
||||||
|
options.header.Token = token
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -47,6 +63,7 @@ export const http = (options) => {
|
||||||
...options,
|
...options,
|
||||||
success(res) {
|
success(res) {
|
||||||
// 1. 判断是否请求成功
|
// 1. 判断是否请求成功
|
||||||
|
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
if (res.data.code >= 200 && res.data.code < 300) {
|
if (res.data.code >= 200 && res.data.code < 300) {
|
||||||
resolve(res.data)
|
resolve(res.data)
|
||||||
|
|
@ -71,12 +88,13 @@ export const http = (options) => {
|
||||||
}
|
}
|
||||||
} else if (res.statusCode === 401) {
|
} else if (res.statusCode === 401) {
|
||||||
// 2. 401 表示token过期 去往登录页重新登录
|
// 2. 401 表示token过期 去往登录页重新登录
|
||||||
const memberStore = useMemberStore()
|
// const memberStore = useMemberStore()
|
||||||
memberStore.clearUserInfo()
|
// memberStore.clearUserInfo()
|
||||||
memberStore.clearToken()
|
// memberStore.clearToken()
|
||||||
uni.navigateTo({
|
// uni.navigateTo({
|
||||||
url: '/pages/login/index',
|
// url: '/pages/login/index',
|
||||||
})
|
// })
|
||||||
|
uni.$u.toast(res.data.message)
|
||||||
reject(res)
|
reject(res)
|
||||||
} else {
|
} else {
|
||||||
// 3. 其他错误
|
// 3. 其他错误
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
|
import removeConsole from 'vite-plugin-remove-console'
|
||||||
import uni from '@dcloudio/vite-plugin-uni'
|
import uni from '@dcloudio/vite-plugin-uni'
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [uni()],
|
plugins: [uni(), removeConsole()],
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
// 在此处编写代理规则
|
// 在此处编写代理规则
|
||||||
'/api': {
|
'/api': {
|
||||||
target: 'http://192.168.2.135:11997', // 梁超
|
target: 'http://192.168.0.133:11997', // 梁超
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => {
|
rewrite: (path) => {
|
||||||
return path.replace(/\/api/, '')
|
return path.replace(/\/api/, '')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue