u
This commit is contained in:
1 parent
68f08d921a
commit
3656d05f62
97 files changed
+17495
No files matched your search
@@ -0,0 +1,253 @@
|
||||
<script lang="ts" setup>
|
||||
import type { FieldValidateError, FormExpose, FormRules } from 'sard-uniapp'
|
||||
import { getWindowInfo, toast } from 'sard-uniapp'
|
||||
import { reactive, ref } from 'vue'
|
||||
import { loaddataApi, saveobjtApi } from '@/request/api'
|
||||
import { useUserStore } from '@/store'
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
const startOffset = ref(getWindowInfo().statusBarHeight + 60)
|
||||
|
||||
const submitLoading = ref(false)
|
||||
|
||||
const formModel = reactive({
|
||||
oldPassword: '',
|
||||
newPassword: '',
|
||||
confirmPassword: '',
|
||||
})
|
||||
|
||||
const formRules: FormRules = {
|
||||
}
|
||||
|
||||
const formRef = ref<FormExpose>()
|
||||
|
||||
async function onSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
|
||||
if (formModel.confirmPassword !== formModel.newPassword) {
|
||||
toast.fail('两次输入的密码不一致,请重新输入')
|
||||
return
|
||||
}
|
||||
|
||||
submitLoading.value = true
|
||||
|
||||
const searchcondition = `b_id = '${userStore.userInfo.userid}' AND ISNULL(b_password, '') = ISNULL('${formModel.oldPassword}', '')`
|
||||
|
||||
const searchRes = await loaddataApi({
|
||||
viewname: 'v_mini_loginid',
|
||||
searchcondition: `${searchcondition}`,
|
||||
orderfield: 'b_id',
|
||||
soption: '',
|
||||
})
|
||||
|
||||
if (!searchRes.data || searchRes.data.length === 0) {
|
||||
toast.fail('旧密码错误,请重新输入')
|
||||
return
|
||||
}
|
||||
|
||||
const updateObj = {
|
||||
b_id: userStore.userInfo.userid,
|
||||
b_password: formModel.newPassword,
|
||||
}
|
||||
|
||||
const tables = []
|
||||
const insertValues = []
|
||||
const updateValues = []
|
||||
const delValues = []
|
||||
const keys = []
|
||||
|
||||
tables.push('b_truck')
|
||||
insertValues.push('[]')
|
||||
updateValues.push(JSON.stringify([updateObj]))
|
||||
delValues.push('[]')
|
||||
keys.push('b_id')
|
||||
|
||||
const saveobjtRes = await saveobjtApi({
|
||||
tables,
|
||||
insertValues,
|
||||
delValues,
|
||||
updateValues,
|
||||
keys,
|
||||
})
|
||||
|
||||
if (saveobjtRes.data === 'OK') {
|
||||
toast.success('密码修改成功,请重新登录')
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
url: '/pages-sub/login/index',
|
||||
})
|
||||
}, 500)
|
||||
}
|
||||
else {
|
||||
console.log(saveobjtRes)
|
||||
toast.fail(saveobjtRes.data || '修改失败')
|
||||
}
|
||||
}
|
||||
catch (error: any) {
|
||||
// 表单校验错误
|
||||
if (Array.isArray(error) && error[0]?.message) {
|
||||
toast.fail(error[0].message)
|
||||
}
|
||||
else {
|
||||
toast.fail('操作失败,请重试')
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
finally {
|
||||
// 关闭 loading
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="form-container">
|
||||
<sar-form-plain
|
||||
ref="formRef"
|
||||
:model="formModel"
|
||||
:rules="formRules"
|
||||
scroll-to-first-error
|
||||
:scroll-into-view-options="{
|
||||
startOffset,
|
||||
position: 'start',
|
||||
}"
|
||||
>
|
||||
<view class="form-description">
|
||||
<view class="form-title">
|
||||
密码修改
|
||||
</view>
|
||||
<view class="form-subtitle">
|
||||
确保账户安全,请谨慎操作
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-list">
|
||||
<sar-form-item-plain name="password">
|
||||
<view class="form-label">
|
||||
旧密码
|
||||
</view>
|
||||
<view class="form-input">
|
||||
<sar-input
|
||||
v-model="formModel.oldPassword"
|
||||
placeholder="请输入旧密码"
|
||||
type="password"
|
||||
show-eye
|
||||
>
|
||||
<template #prepend>
|
||||
<sar-icon family="iconfont" name="lock" size="36rpx" />
|
||||
</template>
|
||||
</sar-input>
|
||||
</view>
|
||||
</sar-form-item-plain>
|
||||
<sar-form-item-plain name="password">
|
||||
<view class="form-label">
|
||||
新密码
|
||||
</view>
|
||||
<view class="form-input">
|
||||
<sar-input
|
||||
v-model="formModel.newPassword"
|
||||
placeholder="请输入新密码"
|
||||
type="password"
|
||||
show-eye
|
||||
>
|
||||
<template #prepend>
|
||||
<sar-icon family="iconfont" name="lock" size="36rpx" />
|
||||
</template>
|
||||
</sar-input>
|
||||
</view>
|
||||
</sar-form-item-plain>
|
||||
<sar-form-item-plain name="password">
|
||||
<view class="form-label">
|
||||
确认密码
|
||||
</view>
|
||||
<view class="form-input">
|
||||
<sar-input
|
||||
v-model="formModel.confirmPassword"
|
||||
placeholder="请输入确认密码"
|
||||
type="password"
|
||||
show-eye
|
||||
>
|
||||
<template #prepend>
|
||||
<sar-icon family="iconfont" name="lock" size="36rpx" />
|
||||
</template>
|
||||
</sar-input>
|
||||
</view>
|
||||
</sar-form-item-plain>
|
||||
</view>
|
||||
|
||||
<view class="footer">
|
||||
<sar-button loading-type="clock" :loading="submitLoading" @click="onSubmit">
|
||||
确认修改
|
||||
</sar-button>
|
||||
</view>
|
||||
</sar-form-plain>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
page {
|
||||
background-color: #fff;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/style/mixins.scss';
|
||||
|
||||
.form-container {
|
||||
padding: 0rpx 32rpx;
|
||||
}
|
||||
|
||||
.form-description {
|
||||
padding: 64rpx 0 64rpx;
|
||||
color: var(--sar-secondary-color);
|
||||
|
||||
.form-title {
|
||||
font-size: 64rpx;
|
||||
font-weight: bold;
|
||||
color: #000;
|
||||
}
|
||||
.form-subtitle {
|
||||
margin-top: 16rpx;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.form-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@include flexGap(36rpx, column);
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: flex;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.form-star {
|
||||
color: var(--sar-danger);
|
||||
}
|
||||
.form-input {
|
||||
margin-top: 20rpx;
|
||||
:deep(.sar-input) {
|
||||
background-color: #fff;
|
||||
.sar-icon {
|
||||
color: var(--sar-input-placeholder-color);
|
||||
}
|
||||
}
|
||||
:deep(.sar-input_focused) {
|
||||
.sar-input__prepend {
|
||||
.sar-icon {
|
||||
color: var(--sar-input-focused-border-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
// position: sticky;
|
||||
// bottom: 0;
|
||||
padding-top: 64rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user