|
@@ -2,24 +2,21 @@
|
|
|
<view class="container">
|
|
<view class="container">
|
|
|
<!-- 旧密码输入框 -->
|
|
<!-- 旧密码输入框 -->
|
|
|
<view class="uni-input-wrapper">
|
|
<view class="uni-input-wrapper">
|
|
|
- <input class="uni-input" placeholder="请输入旧密码" :password="showPassword1"
|
|
|
|
|
- v-model="oldPassword" />
|
|
|
|
|
|
|
+ <input class="uni-input" placeholder="请输入旧密码" :password="showPassword1" v-model="oldPassword" />
|
|
|
<text class="uni-icon" :class="[!showPassword1 ? 'uni-eye-active' : '']"
|
|
<text class="uni-icon" :class="[!showPassword1 ? 'uni-eye-active' : '']"
|
|
|
@click="changePassword1"></text>
|
|
@click="changePassword1"></text>
|
|
|
</view>
|
|
</view>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<!-- 新密码输入框 -->
|
|
<!-- 新密码输入框 -->
|
|
|
<view class="uni-input-wrapper">
|
|
<view class="uni-input-wrapper">
|
|
|
- <input class="uni-input" placeholder="请输入新密码" :password="showPassword2"
|
|
|
|
|
- v-model="newPassword" />
|
|
|
|
|
|
|
+ <input class="uni-input" placeholder="请输入新密码" :password="showPassword2" v-model="newPassword" />
|
|
|
<text class="uni-icon" :class="[!showPassword2 ? 'uni-eye-active' : '']"
|
|
<text class="uni-icon" :class="[!showPassword2 ? 'uni-eye-active' : '']"
|
|
|
@click="changePassword2"></text>
|
|
@click="changePassword2"></text>
|
|
|
</view>
|
|
</view>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<!-- 确认新密码输入框 -->
|
|
<!-- 确认新密码输入框 -->
|
|
|
<view class="uni-input-wrapper">
|
|
<view class="uni-input-wrapper">
|
|
|
- <input class="uni-input" placeholder="请确认新密码" :password="showPassword3"
|
|
|
|
|
- v-model="confirmPassword" />
|
|
|
|
|
|
|
+ <input class="uni-input" placeholder="请确认新密码" :password="showPassword3" v-model="confirmPassword" />
|
|
|
<text class="uni-icon" :class="[!showPassword3 ? 'uni-eye-active' : '']"
|
|
<text class="uni-icon" :class="[!showPassword3 ? 'uni-eye-active' : '']"
|
|
|
@click="changePassword3"></text>
|
|
@click="changePassword3"></text>
|
|
|
</view>
|
|
</view>
|
|
@@ -30,46 +27,59 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
- import { ref } from 'vue';
|
|
|
|
|
-
|
|
|
|
|
|
|
+ import {
|
|
|
|
|
+ ref
|
|
|
|
|
+ } from 'vue';
|
|
|
|
|
+ import $modal from '@/plugins/modal.js'
|
|
|
|
|
+ import {
|
|
|
|
|
+ ChangePWD
|
|
|
|
|
+ } from '@/api/mine';
|
|
|
|
|
+ import {
|
|
|
|
|
+ useUserStore
|
|
|
|
|
+ } from '@/store/user';
|
|
|
|
|
+ import $tab from '@/plugins/tab.js'
|
|
|
|
|
+ const userStore = useUserStore();
|
|
|
const oldPassword = ref(''); // 旧密码
|
|
const oldPassword = ref(''); // 旧密码
|
|
|
const newPassword = ref(''); // 新密码
|
|
const newPassword = ref(''); // 新密码
|
|
|
const confirmPassword = ref(''); // 确认新密码
|
|
const confirmPassword = ref(''); // 确认新密码
|
|
|
const showPassword1 = ref(true); // 旧密码可见性
|
|
const showPassword1 = ref(true); // 旧密码可见性
|
|
|
const showPassword2 = ref(true); // 新密码可见性
|
|
const showPassword2 = ref(true); // 新密码可见性
|
|
|
const showPassword3 = ref(true); // 确认密码可见性
|
|
const showPassword3 = ref(true); // 确认密码可见性
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 提交逻辑
|
|
// 提交逻辑
|
|
|
function submit() {
|
|
function submit() {
|
|
|
// 检查新密码和确认密码是否一致
|
|
// 检查新密码和确认密码是否一致
|
|
|
if (newPassword.value !== confirmPassword.value) {
|
|
if (newPassword.value !== confirmPassword.value) {
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '新密码和确认密码不一致',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ $modal.showToast('新密码和确认密码不一致')
|
|
|
return; // 终止提交
|
|
return; // 终止提交
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查新密码强度
|
|
// 检查新密码强度
|
|
|
if (!validatePassword(newPassword.value)) {
|
|
if (!validatePassword(newPassword.value)) {
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '新密码必须包含至少8个字符、一个大写字母、一个小写字母和一个数字',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ $modal.showToast('新密码必须包含至少6个字符、包含字母和数字')
|
|
|
return; // 终止提交
|
|
return; // 终止提交
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 通过校验后,提示提交成功
|
|
// 通过校验后,提示提交成功
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '提交成功',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const params = {
|
|
|
|
|
+ staffId: userStore.user.useId,
|
|
|
|
|
+ oldpassword: oldPassword.value,
|
|
|
|
|
+ newpassword: newPassword.value,
|
|
|
|
|
+ }
|
|
|
|
|
+ ChangePWD(params).then(res => {
|
|
|
|
|
+ $modal.showToast(res.returnMsg);
|
|
|
|
|
+ if ("1" == res.returnCode) { //修改成功
|
|
|
|
|
+ userStore.LogOut().then(() => {
|
|
|
|
|
+ $tab.reLaunch('/pages/login')
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 校验密码强度
|
|
// 校验密码强度
|
|
|
function validatePassword(password) {
|
|
function validatePassword(password) {
|
|
|
- // 密码至少有8个字符,包含大写字母、小写字母和数字
|
|
|
|
|
- const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z\d]{8,}$/;
|
|
|
|
|
|
|
+ // 密码至少有6个字符,包含字母和数字
|
|
|
|
|
+ const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,}$/;
|
|
|
return passwordRegex.test(password);
|
|
return passwordRegex.test(password);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -77,12 +87,12 @@
|
|
|
function changePassword1() {
|
|
function changePassword1() {
|
|
|
showPassword1.value = !showPassword1.value;
|
|
showPassword1.value = !showPassword1.value;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 切换新密码可见性
|
|
// 切换新密码可见性
|
|
|
function changePassword2() {
|
|
function changePassword2() {
|
|
|
showPassword2.value = !showPassword2.value;
|
|
showPassword2.value = !showPassword2.value;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 切换确认密码可见性
|
|
// 切换确认密码可见性
|
|
|
function changePassword3() {
|
|
function changePassword3() {
|
|
|
showPassword3.value = !showPassword3.value;
|
|
showPassword3.value = !showPassword3.value;
|
|
@@ -98,12 +108,10 @@
|
|
|
margin-bottom: 30rpx;
|
|
margin-bottom: 30rpx;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
button {
|
|
button {
|
|
|
background-color: #007aff;
|
|
background-color: #007aff;
|
|
|
color: white;
|
|
color: white;
|
|
|
- padding: 20rpx 40rpx;
|
|
|
|
|
|
|
+ padding: 20rpx 40rpx;
|
|
|
border: none;
|
|
border: none;
|
|
|
border-radius: 10rpx;
|
|
border-radius: 10rpx;
|
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
@@ -112,24 +120,22 @@
|
|
|
.uni-input-wrapper {
|
|
.uni-input-wrapper {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
align-items: center;
|
|
align-items: center;
|
|
|
-
|
|
|
|
|
- padding: 20rpx;
|
|
|
|
|
-
|
|
|
|
|
- margin: 20rpx;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ padding: 20rpx;
|
|
|
|
|
+ margin: 20rpx;
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
.uni-icon {
|
|
.uni-icon {
|
|
|
margin-left: 20rpx;
|
|
margin-left: 20rpx;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.uni-eye-active {
|
|
.uni-eye-active {
|
|
|
color: #007aff;
|
|
color: #007aff;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- .submitBtn{
|
|
|
|
|
|
|
+
|
|
|
|
|
+ .submitBtn {
|
|
|
width: 90%;
|
|
width: 90%;
|
|
|
margin-top: 30rpx;
|
|
margin-top: 30rpx;
|
|
|
}
|
|
}
|