| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <template>
- <view class="pwd-retrieve-container">
- <uni-forms ref="form" :value="user" labelWidth="80px">
- <uni-forms-item name="oldPassword" :label="i18('旧密码')">
- <uni-easyinput type="password" v-model="user.oldPassword" :placeholder="i18('请输入旧密码')" />
- </uni-forms-item>
- <uni-forms-item name="newPassword" :label="i18('新密码')">
- <uni-easyinput type="password" v-model="user.newPassword" :placeholder="i18('请输入新密码')" />
- </uni-forms-item>
- <uni-forms-item name="confirmPassword" :label="i18('确认密码')">
- <uni-easyinput type="password" v-model="user.confirmPassword" :placeholder="i18('请确认新密码')" />
- </uni-forms-item>
- <button type="primary" style="background: #0E9F9B;color: white" @click="submit">{{i18('提交')}}</button>
- <view style="bottom: 80px;position: absolute;left: 10px;right:10px">
- <button type="warn" @click="" style="background: #0E9F9B;color: white" @click="deleteUser">{{i18('注销账号')}}</button>
- </view>
- <view style="bottom: 10px;position: absolute;left: 10px;right:10px">
- <button type="warn" @click="" style="background: #0E9F9B;color: white" @click="handleLogout">{{i18('退出登录')}}</button>
- </view>
- </uni-forms>
- </view>
- </template>
- <script>
- import { updateUserPwd } from "@/api/system/user"
- import i18 from '@/utils/i18.js'
- export default {
- data() {
- return {
- user: {
- oldPassword: undefined,
- newPassword: undefined,
- confirmPassword: undefined
- },
- rules: {
- oldPassword: {
- rules: [{
- required: true,
- errorMessage: i18('旧密码不能为空')
- }]
- },
- newPassword: {
- rules: [{
- required: true,
- errorMessage: i18('新密码不能为空'),
- },
- {
- minLength: 6,
- maxLength: 20,
- errorMessage: i18('长度在 6 到 20 个字符')
- }
- ]
- },
- confirmPassword: {
- rules: [{
- required: true,
- errorMessage: i18('确认密码不能为空')
- }, {
- validateFunction: (rule, value, data) => data.newPassword === value,
- errorMessage: i18('两次输入的密码不一致')
- }
- ]
- }
- }
- }
- },
- onReady() {
- this.$refs.form.setRules(this.rules)
- },
- onShow(){
- uni.setNavigationBarTitle({
- title: this.$t('page.modifypwd')
- })
- },
- methods: {
- i18(text){
- return i18(text)
- },
- submit() {
- this.$refs.form.validate().then(res => {
- updateUserPwd(this.user.oldPassword, this.user.newPassword).then(response => {
- this.$modal.msgSuccess("修改成功")
- })
- })
- },
- handleLogout() {
- this.$modal.confirm('确定注销并退出系统吗?').then(() => {
- this.$store.dispatch('LogOut').then(() => {
- this.$tab.reLaunch('/pages/index')
- })
- })
- },
- deleteUser() {
- this.$modal.confirm('确定删除账号吗?').then(() => {
- this.$store.dispatch('DeleteUser').then(() => {
- this.$tab.reLaunch('/pages/index')
- })
- })
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #ffffff;
- }
- .pwd-retrieve-container {
- padding-top: 36rpx;
- padding: 15px;
- }
- </style>
|