123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <template>
- <view class="uni-app">
- <view class="status-bar" />
- <view class="main-container">
- <wk-nav-bar title="修改登录密码" />
- <view class="tips">
- 修改密码后,需重新登录应用
- </view>
- <view class="container">
- <view class="form">
- <view class="cell">
- <view class="cell-title">
- 原密码
- </view>
- <view class="cell-body">
- <input
- v-model="form.oldPassword"
- type="text"
- :maxlength="20"
- :password="!checkedStatus"
- placeholder="请输入原密码"
- placeholder-class="wk-placehoder placeholder"
- class="input-core">
- <!-- <text
- v-if="focusFlag.oldPassword && form.oldPassword"
- class="wk wk-close-fill"
- @click="handleClear('oldPassword')" /> -->
- </view>
- </view>
- <view class="cell">
- <view class="cell-title">
- 新密码
- </view>
- <view class="cell-body">
- <input
- v-model="form.newPassword"
- type="text"
- :maxlength="20"
- :password="!checkedStatus"
- placeholder="请输入新密码,由6-20位字母、数字组成"
- placeholder-class="wk-placehoder placeholder"
- class="input-core">
- </view>
- </view>
- <view class="cell">
- <view class="cell-title">
- 确认密码
- </view>
- <view class="cell-body">
- <input
- v-model="form.confirmPassword"
- type="text"
- :maxlength="20"
- :password="!checkedStatus"
- placeholder="请确认新密码"
- placeholder-class="wk-placehoder placeholder"
- class="input-core">
- </view>
- </view>
- <view class="checkbox-cell" @tap.stop="changeTaskStatus">
- <view
- :class="{over: checkedStatus}"
- class="checkbox">
- <span v-if="checkedStatus" class="icon wk wk-check" />
- </view>
- <text class="checkbox-label">
- 显示密码
- </text>
- </view>
- </view>
- <view class="submit" @click="handleSubmit">
- 确认修改
- </view>
- </view>
- </view>
- <uni-popup ref="popup" type="dialog">
- <uni-popup-dialog
- :content="dialogMsg"
- type="warning"
- @confirm="handleDialogConfirm" />
- </uni-popup>
- </view>
- </template>
- <script>
- import { UpdatePassword } from 'API/admin'
- import WkFieldInput from '@/components/wk-form/wk-field-input.vue'
- import { mapGetters } from 'vuex'
- export default {
- name: 'ResetPassword',
- data() {
- return {
- form: {
- oldPassword: null,
- newPassword: null,
- confirmPassword: null,
- },
- focusFlag: {
- oldPassword: false,
- newPassword: false,
- confirmPassword: false
- },
- dialogMsg: '',
- checkedStatus: false
- }
- },
- computed: {
- ...mapGetters({
- userInfo: 'user/userInfo'
- })
- },
- methods: {
- changeTaskStatus() {
- this.checkedStatus = !this.checkedStatus
- },
- changeFocusFlag(type, val = false) {
- this.$set(this.focusFlag, type, val)
- },
- handleClear(type) {
- console.log('handleClear', this.form)
- this.$set(this.form, type, '')
- this.$set(this.focusFlag, type, true)
- },
- handleSubmit() {
- if (!this.form.oldPassword) {
- this.$toast('原密码不能为空!')
- return
- }
- const pwdReg = /^(?=.*[a-zA-Z])(?=.*\d).{6,20}$/
- if (!pwdReg.test(this.form.newPassword)) {
- this.$toast('密码由6到20位数字、字母组成')
- return
- }
- if (this.form.newPassword !== this.form.confirmPassword) {
- this.$toast('两次密码不一致请重新输入!')
- return
- }
- this.dialogMsg = '您确定要修改登录密码吗?'
- this.$refs.popup.open()
- },
- handleDialogConfirm(next) {
- next()
- let params = {
- id: this.userInfo.userId,
- oldPwd: this.form.oldPassword,
- newPwd: this.form.newPassword,
- }
- UpdatePassword(params).then(() => {
- this.$toast('修改成功,即将跳转重新登录')
- setTimeout(() => {
- this.$Router.reLaunch('/pages/login/index')
- }, 3000)
- }).catch()
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .placeholder {
- font-size: 24rpx;
- color: $light;
- }
- .main-container {
- flex: 1;
- .tips {
- width: 100%;
- height: 76rpx;
- line-height: 76rpx;
- font-size: $wk-font-sm;
- color: $gray;
- background-color: #EBEEF1;
- padding: 0 45rpx;
- }
- .container {
- flex: 1;
- background-color: white;
- .form {
- padding: 0 45rpx;
- margin-top: 15rpx;
- .cell {
- margin-bottom: 20rpx;
- .cell-title {
- width: 100%;
- font-size: $wk-font-base;
- margin-bottom: 15rpx;
- }
- .cell-body {
- position: relative;
- .input-core {
- width: 100%;
- height: 80rpx;
- font-size: 28rpx;
- border: 1rpx solid #D2D2D2;
- border-radius: 8rpx;
- padding: 0 28rpx;
- }
- .wk-close-fill {
- position: absolute;
- top: 50%;
- right: 18rpx;
- transform: translateY(-50%);
- color: $light;
- font-size: $wk-font-base;
- }
- }
- }
- .checkbox-cell {
- width: 180rpx;
- @include left;
- .checkbox {
- width: 32rpx;
- height: 32rpx;
- margin-right: 15rpx;
- border: 1rpx solid #ccc;
- border-radius: 6rpx;
- overflow: hidden;
- @include center;
- .icon {
- font-size: $wk-font-mini;
- line-height: 1;
- color: white;
- }
- &.over {
- background-color: $theme-color;
- border-color: $theme-color;
- }
- }
- .checkbox-label {
- font-size: $wk-font-base;
- }
- }
- }
- .submit {
- width: 650rpx;
- height: 85rpx;
- text-align: center;
- font-size: 34rpx;
- line-height: 85rpx;
- color: white;
- background-color: $theme-color;
- border-radius: 16rpx;
- margin: 110rpx auto 0;
- }
- }
- }
- </style>
|