| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <template>
- <view class="pwd-retrieve-container">
- <view style="wibackground-color: black;">
- <view style="width: 70vw;margin-left: 13vw;margin-top: 10vh;">
- <uni-forms ref="form" :value="user" labelWidth="0px">
- <uni-forms-item name="oldPassword">
- <!-- <uni-easyinput type="password" :styles="styles" :placeholderStyle="placeholderStyle"
- v-model="user.oldPassword" :placeholder="i18('请输入旧密码')" /> -->
- <view style="color: aliceblue;margin-left: 1vw;">{{i18('旧密码')}}{{oldPassword}}</view>
- <u-input :placeholder="i18('请输入旧密码')" v-show="oldPassword" :password="true" :styles="styles"
- color="#e7e7e7" v-model="user.oldPassword" style="border-radius: 20px;">
- <template slot="suffix">
- <uni-icons :type="oldPassword ? 'eye': 'eye-slash'" size="25" style="color: aliceblue;"
- @click="oldPasswordeye()"></uni-icons>
- </template>
- </u-input>
- <u-input :placeholder="i18('请输入旧密码')" v-show="!oldPassword" :password="false" :styles="styles"
- color="#e7e7e7" v-model="user.oldPassword" style="border-radius: 20px;">
- <template slot="suffix">
- <uni-icons :type="oldPassword ? 'eye': 'eye-slash'" size="25" style="color: aliceblue;"
- @click="oldPasswordeye()"></uni-icons>
- </template>
- </u-input>
- </uni-forms-item>
- <uni-forms-item name="newPassword">
- <!-- <uni-easyinput type="password" v-model="user.newPassword" :styles="styles" :placeholderStyle="placeholderStyle" :placeholder="i18('请输入新密码')" /> -->
- <view style="color: aliceblue;margin-left: 1vw;">{{i18('新密码')}}</view>
- <u-input :placeholder="i18('请输入新密码')" v-show="newPassword" :password="true" :styles="styles"
- color="#e7e7e7" v-model="user.newPassword" style="border-radius: 20px;">
- <template slot="suffix">
- <uni-icons :type="newPassword ? 'eye': 'eye-slash'" size="25" style="color: aliceblue;"
- @click="newPasswordeye()"></uni-icons>
- </template>
- </u-input>
- <u-input :placeholder="i18('请输入新密码')" v-show="!newPassword" :password="false" :styles="styles"
- color="#e7e7e7" v-model="user.newPassword" style="border-radius: 20px;">
- <template slot="suffix">
- <uni-icons :type="newPassword ? 'eye': 'eye-slash'" size="25" style="color: aliceblue;"
- @click="newPasswordeye()"></uni-icons>
- </template>
- </u-input>
- </uni-forms-item>
- <uni-forms-item name="confirmPassword">
- <!-- <uni-easyinput type="password" v-model="user.confirmPassword" :styles="styles" :placeholderStyle="placeholderStyle" :placeholder="i18('请确认新密码')" /> -->
- <view style="color: aliceblue;margin-left: 1vw;">{{i18('确认密码')}}</view>
- <u-input :placeholder="i18('请确认新密码')" v-show="confirmPassword" :password="true" :styles="styles"
- color="#e7e7e7" v-model="user.confirmPassword" style="border-radius: 20px;">
- <template slot="suffix">
- <uni-icons :type="confirmPassword ? 'eye': 'eye-slash'" size="25" style="color: aliceblue;"
- @click="confirmPasswordeye()"></uni-icons>
- </template>
- </u-input>
- <u-input :placeholder="i18('请确认新密码')" v-show="!confirmPassword" :password="false" :styles="styles"
- color="#e7e7e7" v-model="user.confirmPassword" style="border-radius: 20px;">
- <template slot="suffix">
- <uni-icons :type="confirmPassword ? 'eye': 'eye-slash'" size="25" style="color: aliceblue;"
- @click="confirmPasswordeye()"></uni-icons>
- </template>
- </u-input>
- </uni-forms-item>
- <button type="primary" style="background: #57B03D;color: white;border-radius: 20px;"
- @click="submit">{{i18('提交')}}</button>
- <view style="bottom: 80px;position: absolute;left: 10px;right:10px">
- <button type="warn" @click="" style="background: #ca2f14;color: white;border-radius: 20px;"
- @click="deleteUser">{{i18('注销账号')}}</button>
- </view>
- <!-- <view style="bottom: 10px;position: absolute;left: 10px;right:10px">
- <button type="warn" @click="" style="background: #57B03D;color: white" @click="handleLogout">{{i18('退出登录')}}</button>
- </view> -->
- </uni-forms>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- updateUserPwd
- } from "@/api/system/user"
- import i18 from '@/utils/i18.js'
- export default {
- data() {
- return {
- placeholderStyle: "color:#bababa;font-size:14px",
- styles: {
- color: '#ffffff',
- borderColor: '#ffffff'
- },
- 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('两次输入的密码不一致')
- }]
- }
- },
- oldPassword: true,
- newPassword: true,
- confirmPassword: true,
- }
- },
- onReady() {
- this.$refs.form.setRules(this.rules)
- },
- onShow() {
- uni.setNavigationBarTitle({
- title: this.$t('page.modifypwd')
- })
- },
- methods: {
- eye(type) {
- if (type == 1) {
- this.oldPassword = !this.oldPassword
- } else if (type = 2) {
- } else {
- }
- },
- oldPasswordeye() {
- this.oldPassword = !this.oldPassword
- },
- confirmPasswordeye() {
- this.confirmPassword = !this.confirmPassword
- },
- newPasswordeye() {
- this.newPassword = !this.newPassword
- },
- 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-image: url('/static/images/new/starts/bg2.jpg');
- background-size: cover;
- background-repeat: no-repeat;
- }
-
- .pwd-retrieve-container {
- padding-top: 36rpx;
- padding: 15px;
- line-height: 30px;
- }
- </style>
|