|
|
@@ -45,12 +45,42 @@
|
|
|
<text class="company">宇光同行</text>
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
+
|
|
|
+ <!-- 自定义选择器弹窗 -->
|
|
|
+ <view v-if="showPasswordPicker" class="picker-modal">
|
|
|
+ <view class="modal-mask" @click="showPasswordPicker = false"></view>
|
|
|
+ <view class="modal-content">
|
|
|
+ <view class="modal-header">
|
|
|
+ <text class="modal-title">修改密码</text>
|
|
|
+ <text class="modal-close" @click="showPasswordPicker = false">取消</text>
|
|
|
+ </view>
|
|
|
+ <view class="form-item-input">
|
|
|
+ <text class="label-picker">新密码</text>
|
|
|
+ <view class="view-input-picker">
|
|
|
+ <input class="input-picker" :type="showNewPassword ? 'text' : 'password'" placeholder="请输入新密码" v-model="newpassword" />
|
|
|
+ <image class="eye-icon-picker" :src="showNewPassword ? '/static/images/login/4.png' : '/static/images/login/3.png'" mode="aspectFit" @click="handleToggleNewPassword"></image>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="form-item-input">
|
|
|
+ <text class="label-picker">确认密码</text>
|
|
|
+ <view class="view-input-picker">
|
|
|
+ <input class="input-picker" :type="showConfirmPassword ? 'text' : 'password'" placeholder="请输入确认密码" v-model="confirmpassword" />
|
|
|
+ <image class="eye-icon-picker" :src="showConfirmPassword ? '/static/images/login/4.png' : '/static/images/login/3.png'" mode="aspectFit" @click="handleToggleConfirmPassword"></image>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="form-item-btn">
|
|
|
+ <button class="btn-primary" @click="handleRestPassword">
|
|
|
+ 确认
|
|
|
+ </button>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="uts">
|
|
|
import { ref, computed, onMounted } from 'vue'
|
|
|
- import { loginByAccount, getUserInfo } from '../../api/auth/login'
|
|
|
+ import { loginByAccount, getUserInfo, resetPassword } from '../../api/auth/login'
|
|
|
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
|
|
|
import {
|
|
|
saveAccessToken,
|
|
|
@@ -67,9 +97,14 @@
|
|
|
// 表单数据
|
|
|
const username = ref<string>("")
|
|
|
const password = ref<string>("")
|
|
|
+ const newpassword = ref<string>("")
|
|
|
+ const confirmpassword = ref<string>("")
|
|
|
const rememberPassword = ref<boolean>(false)
|
|
|
const showPassword = ref<boolean>(false)
|
|
|
+ const showNewPassword = ref<boolean>(false)
|
|
|
+ const showConfirmPassword = ref<boolean>(false)
|
|
|
const loading = ref<boolean>(false)
|
|
|
+ const showPasswordPicker = ref<boolean>(false)
|
|
|
|
|
|
// 版本号
|
|
|
const manifestVersion = manifest.versionName as string | null
|
|
|
@@ -89,7 +124,42 @@
|
|
|
const handleTogglePassword = (): void => {
|
|
|
showPassword.value = !showPassword.value
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ // 切换密码显示/隐藏
|
|
|
+ const handleToggleNewPassword = (): void => {
|
|
|
+ showNewPassword.value = !showNewPassword.value
|
|
|
+ }
|
|
|
+
|
|
|
+ // 切换密码显示/隐藏
|
|
|
+ const handleToggleConfirmPassword = (): void => {
|
|
|
+ showConfirmPassword.value = !showConfirmPassword.value
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleRestPassword = async (): Promise<void> => {
|
|
|
+ try {
|
|
|
+ if(newpassword.value != confirmpassword.value){
|
|
|
+ uni.showToast({
|
|
|
+ title: '两次输入的密码不一致',
|
|
|
+ icon: 'error'
|
|
|
+ })
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ await resetPassword(username.value, password.value, newpassword.value);
|
|
|
+ showPasswordPicker.value = false;
|
|
|
+ uni.showToast({
|
|
|
+ title: '修改成功,请重新登录',
|
|
|
+ icon: 'success'
|
|
|
+ })
|
|
|
+ newpassword.value = ""
|
|
|
+ confirmpassword.value = "";
|
|
|
+ } catch (e: any) {
|
|
|
+ uni.showToast({
|
|
|
+ title: e.message ?? '密码修改失败',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
// 登录处理
|
|
|
const handleLogin = async (): Promise<void> => {
|
|
|
|
|
|
@@ -128,6 +198,13 @@
|
|
|
// 提取 data 部分
|
|
|
const resultObj = result as UTSJSONObject
|
|
|
// const data = resultObj['data'] as UTSJSONObject
|
|
|
+
|
|
|
+ const isInitPassword = resultObj["isInitPassword"] as boolean | null;
|
|
|
+ // console.log("================"+ code)
|
|
|
+ if(isInitPassword==true){
|
|
|
+ showPasswordPicker.value = true;
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
// 保存登录信息
|
|
|
saveAccessToken(resultObj['token'] as string)
|
|
|
@@ -338,4 +415,107 @@
|
|
|
font-size: 24rpx;
|
|
|
color: #333333;
|
|
|
}
|
|
|
+ .picker-modal {
|
|
|
+ position: fixed;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
+ z-index: 1000;
|
|
|
+ }
|
|
|
+
|
|
|
+ .modal-mask {
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
+ background-color: rgba(0, 0, 0, 0.5);
|
|
|
+ }
|
|
|
+
|
|
|
+ .modal-content {
|
|
|
+ position: absolute;
|
|
|
+ bottom: 0;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ background-color: #ffffff;
|
|
|
+ border-top-left-radius: 16rpx;
|
|
|
+ border-top-right-radius: 16rpx;
|
|
|
+ max-height: 1000rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .modal-header {
|
|
|
+ flex-direction: row;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ padding: 30rpx;
|
|
|
+ border-bottom: 1rpx solid #f0f0f0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .modal-title {
|
|
|
+ font-size: 32rpx;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #333333;
|
|
|
+ }
|
|
|
+
|
|
|
+ .modal-close {
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #007aff;
|
|
|
+ }
|
|
|
+
|
|
|
+ .form-item-btn{
|
|
|
+ flex: 1;
|
|
|
+ align-items: center;
|
|
|
+ margin-bottom: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .form-item-input{
|
|
|
+ flex: 1;
|
|
|
+ flex-direction: row;
|
|
|
+ background-color: #ffffff;
|
|
|
+ padding: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .btn-primary {
|
|
|
+ z-index: 999;
|
|
|
+ font-size: 15px;
|
|
|
+ border-radius: 10rpx;
|
|
|
+ width: 100px;
|
|
|
+ padding: 5px;
|
|
|
+ background-color: #165DFF;
|
|
|
+ line-height: 45rpx;
|
|
|
+ color: #ffffff;
|
|
|
+ .btn-text{
|
|
|
+ color: #ffffff;
|
|
|
+ padding: 5px 15px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .label-picker{
|
|
|
+ font-size: 32rpx;
|
|
|
+ color: #333333;
|
|
|
+ font-weight: bold;
|
|
|
+ width: 180rpx;
|
|
|
+ padding: 20rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .input-picker {
|
|
|
+ width: 70%;
|
|
|
+ height: 90rpx;
|
|
|
+ padding: 0 100rpx 0 30rpx;
|
|
|
+ background-color: #f5f5f5;
|
|
|
+ border-radius: 12rpx;
|
|
|
+ font-size: 30rpx;
|
|
|
+ color: #333333;
|
|
|
+ border: 1rpx solid transparent;
|
|
|
+ }
|
|
|
+
|
|
|
+ .eye-icon-picker {
|
|
|
+ position: absolute;
|
|
|
+ right: 230rpx;
|
|
|
+ top: 50%;
|
|
|
+ transform: translateY(-50%);
|
|
|
+ width: 40rpx;
|
|
|
+ height: 40rpx;
|
|
|
+ }
|
|
|
+
|
|
|
</style>
|