|
|
@@ -1,7 +1,11 @@
|
|
|
<template lang="html">
|
|
|
<div class="ibps-fixed-top my-pwd">
|
|
|
<van-sticky>
|
|
|
- <van-nav-bar :title="generateTitle()" :left-text="$t('common.button.back')" left-arrow fixed
|
|
|
+ <van-nav-bar
|
|
|
+:title="generateTitle()"
|
|
|
+:left-text="$t('common.button.back')"
|
|
|
+left-arrow
|
|
|
+fixed
|
|
|
@click-left="onBack" />
|
|
|
</van-sticky>
|
|
|
|
|
|
@@ -11,20 +15,43 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="divider" />
|
|
|
- <van-form @submit="onSave" @failed="onFailed" class="submitStyle">
|
|
|
+ <van-form class="submitStyle" @submit="onSave" @failed="onFailed">
|
|
|
<van-cell-group>
|
|
|
- <van-field v-model="form.primitivePassword" :label="$t('platform.my.change-password.primitivePassword')"
|
|
|
+ <van-field
|
|
|
+v-model="form.primitivePassword"
|
|
|
+:label="$t('platform.my.change-password.primitivePassword')"
|
|
|
:placeholder="$t('platform.my.change-password.primitivePasswordPlaceholder')"
|
|
|
:rules="[{ required: true, message: $t('platform.my.change-password.primitivePasswordPlaceholder') }]"
|
|
|
- type="password" name="my.primitivePassword" :size="size" autocomplete="off" required clearable />
|
|
|
- <van-field v-model="form.newPassword" :label="$t('platform.my.change-password.newPassword')"
|
|
|
+ type="password"
|
|
|
+name="my.primitivePassword"
|
|
|
+:size="size"
|
|
|
+autocomplete="off"
|
|
|
+required
|
|
|
+clearable />
|
|
|
+ <van-field
|
|
|
+v-model="form.newPassword"
|
|
|
+:label="$t('platform.my.change-password.newPassword')"
|
|
|
:placeholder="$t('platform.my.change-password.newPasswordPlaceholder')"
|
|
|
:rules="[{ required: true, message: $t('platform.my.change-password.newPasswordPlaceholder') }]"
|
|
|
- type="password" name="my.newPassword" :size="size" autocomplete="off" required clearable />
|
|
|
- <van-field v-model="form.repeatPassword" :label="$t('platform.my.change-password.repeatPassword')"
|
|
|
- :placeholder="$t('platform.my.change-password.repeatPasswordPlaceholder')" :rules="[{ required: true, message: $t('platform.my.change-password.newPasswordPlaceholder') },
|
|
|
+ type="password"
|
|
|
+name="my.newPassword"
|
|
|
+:size="size"
|
|
|
+autocomplete="off"
|
|
|
+required
|
|
|
+clearable />
|
|
|
+ <van-field
|
|
|
+v-model="form.repeatPassword"
|
|
|
+:label="$t('platform.my.change-password.repeatPassword')"
|
|
|
+ :placeholder="$t('platform.my.change-password.repeatPasswordPlaceholder')"
|
|
|
+:rules="[{ required: true, message: $t('platform.my.change-password.newPasswordPlaceholder') },
|
|
|
{ validator :repeatValidator,message:$t('platform.my.change-password.repeatErrorMessage') }
|
|
|
- ]" type="password" name="my.repeatPassword" :size="size" autocomplete="off" required clearable />
|
|
|
+ ]"
|
|
|
+type="password"
|
|
|
+name="my.repeatPassword"
|
|
|
+:size="size"
|
|
|
+autocomplete="off"
|
|
|
+required
|
|
|
+clearable />
|
|
|
</van-cell-group>
|
|
|
<div style="margin: 10px 0;border:0">
|
|
|
<van-button block size="large" native-type="submit" color=" #1E90FF">
|
|
|
@@ -36,68 +63,78 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import { changePassword } from '@/api/platform/org/user'
|
|
|
- import navbar from '@/mixins/navbar'
|
|
|
- import defaultImage from '@/assets/images/logo/lc.png'
|
|
|
- import { mapState } from 'vuex'
|
|
|
- import { getFile } from '@/utils/image'
|
|
|
+import { changePassword } from '@/api/platform/org/user'
|
|
|
+import navbar from '@/mixins/navbar'
|
|
|
+import defaultImage from '@/assets/images/logo/lc.png'
|
|
|
+import { mapState } from 'vuex'
|
|
|
+import { getFile } from '@/utils/image'
|
|
|
+import { encryptByAes } from '@/utils/encrypt'
|
|
|
|
|
|
- export default {
|
|
|
- mixins: [navbar],
|
|
|
- data() {
|
|
|
- return {
|
|
|
- form: {
|
|
|
- primitivePassword: '',
|
|
|
- newPassword: '',
|
|
|
- repeatPassword: ''
|
|
|
- },
|
|
|
- size: 'large'
|
|
|
+export default {
|
|
|
+ mixins: [navbar],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ form: {
|
|
|
+ primitivePassword: '',
|
|
|
+ newPassword: '',
|
|
|
+ repeatPassword: ''
|
|
|
+ },
|
|
|
+ size: 'large'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState('ibps/user', [
|
|
|
+ 'info'
|
|
|
+ ]),
|
|
|
+ // 获取用户头像
|
|
|
+ avatar() {
|
|
|
+ const str = '/file/getImage?attachmentId='
|
|
|
+ const photo = this.info && this.info.employee ? (/^\d+$/.test(this.info.employee.photo) ? (str + this.info.employee.photo) : this.info.employee.photo) : null
|
|
|
+ if (this.$utils.isEmpty(photo)) {
|
|
|
+ return this.errorImage
|
|
|
}
|
|
|
+ return getFile(photo)
|
|
|
},
|
|
|
- computed: {
|
|
|
- ...mapState('ibps/user', [
|
|
|
- 'info'
|
|
|
- ]),
|
|
|
- // 获取用户头像
|
|
|
- avatar() {
|
|
|
- let str = "/file/getImage?attachmentId="
|
|
|
- const photo = this.info && this.info.employee ? (/^\d+$/.test(this.info.employee.photo) ? (str + this.info.employee.photo) : this.info.employee.photo) : null
|
|
|
- if (this.$utils.isEmpty(photo)) {
|
|
|
- return this.errorImage
|
|
|
- }
|
|
|
- return getFile(photo)
|
|
|
- },
|
|
|
- errorImage() {
|
|
|
- return defaultImage
|
|
|
- },
|
|
|
+ errorImage() {
|
|
|
+ return defaultImage
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ repeatValidator(val) {
|
|
|
+ return this.form.newPassword === val
|
|
|
},
|
|
|
- methods: {
|
|
|
- repeatValidator(val) {
|
|
|
- return this.form.newPassword === val
|
|
|
- },
|
|
|
- updatePassWord() {
|
|
|
- this.form['userIds'] = [this.$store.getters.userId]
|
|
|
- changePassword(this.form).then(response => {
|
|
|
- this.$notify({
|
|
|
- type: 'success',
|
|
|
- message: this.$t('platform.my.change-password.success')
|
|
|
- })
|
|
|
- this.$router.push({ name: 'my' })
|
|
|
- }).catch(e => {
|
|
|
- console.error(e.cause)
|
|
|
- })
|
|
|
- },
|
|
|
- onSave() {
|
|
|
- this.updatePassWord()
|
|
|
- },
|
|
|
- onFailed() {
|
|
|
+ updatePassWord() {
|
|
|
+ // console.log(this.form, 'this.form')
|
|
|
+ // this.form['userIds'] = [this.$store.getters.userId]
|
|
|
+ const { primitivePassword, repeatPassword, newPassword } = this.form
|
|
|
+
|
|
|
+ const params = {
|
|
|
+ userIds: [this.$store.getters.userId],
|
|
|
+ primitivePassword: primitivePassword ? encryptByAes(primitivePassword, 'pwd') : '',
|
|
|
+ repeatPassword: encryptByAes(repeatPassword, 'pwd'),
|
|
|
+ newPassword: encryptByAes(newPassword, 'pwd')
|
|
|
+ }
|
|
|
+ changePassword(params).then(response => {
|
|
|
this.$notify({
|
|
|
- type: 'danger',
|
|
|
- message: this.$t('common.formError')
|
|
|
+ type: 'success',
|
|
|
+ message: this.$t('platform.my.change-password.success')
|
|
|
})
|
|
|
- }
|
|
|
+ this.$router.push({ name: 'my' })
|
|
|
+ }).catch(e => {
|
|
|
+ console.error(e.cause)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onSave() {
|
|
|
+ this.updatePassWord()
|
|
|
+ },
|
|
|
+ onFailed() {
|
|
|
+ this.$notify({
|
|
|
+ type: 'danger',
|
|
|
+ message: this.$t('common.formError')
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
.my-pwd {
|
|
|
@@ -117,7 +154,6 @@
|
|
|
padding-top: 15%;
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
-
|
|
|
img {
|
|
|
width: 100%;
|
|
|
border-radius: 50%;
|
|
|
@@ -136,7 +172,6 @@
|
|
|
|
|
|
.van-field {
|
|
|
|
|
|
-
|
|
|
::v-deep .van-field__label {
|
|
|
color: #6f6f70;
|
|
|
}
|
|
|
@@ -147,4 +182,4 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|