123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <template>
- <view>
- <u-navbar title="修改密码" autoBack placeholder></u-navbar>
- <view class="card_password">
- <view class="item_pass">
- <view class="pass_title">旧密码<span style="color: red;">*</span></view>
- <u-input v-show="isText1 === true" placeholder="请填写密码" border="surround" v-model="userInfo.oldCode"
- class="input_class_pwd" :password="true">
- <template slot="suffix" v-if="userInfo.oldCode">
- <u-icon name="eye-off" @click="isText1 = false" size="20"></u-icon>
- </template>
- </u-input>
- <u-input v-show="isText1 === false" placeholder="请填写密码" border="surround" v-model="userInfo.oldCode"
- class="input_class_pwd" :password="false">
- <template slot="suffix" v-if="userInfo.oldCode">
- <u-icon name="eye-fill" @click="isText1 = true" size="20"></u-icon>
- </template>
- </u-input>
- </view>
- <view class="item_pass">
- <view class="pass_title">新密码<span style="color: red;">*</span></view>
- <u-input v-show="isText2 === true" placeholder="请填写新密码" border="surround" v-model="userInfo.sedNewCode"
- class="input_class_pwd" :password="true">
- <template slot="suffix" v-if="userInfo.sedNewCode">
- <u-icon name="eye-off" @click="isText2 = false" size="20"></u-icon>
- </template>
- </u-input>
- <u-input v-show="isText2 === false" placeholder="请填写新密码" border="surround" v-model="userInfo.sedNewCode"
- class="input_class_pwd" :password="false">
- <template slot="suffix" v-if="userInfo.sedNewCode">
- <u-icon name="eye-fill" @click="isText2 = true" size="20"></u-icon>
- </template>
- </u-input>
- </view>
- <view class="item_pass">
- <view class="pass_title">再次输入新密码<span style="color: red;">*</span></view>
- <u-input v-show="isText3 === true" placeholder="请再次填写新密码" border="surround" v-model="userInfo.newCode"
- class="input_class_pwd" :password="true">
- <template slot="suffix" v-if="userInfo.newCode">
- <u-icon name="eye-off" @click="isText3 = false" size="20"></u-icon>
- </template>
- </u-input>
- <u-input v-show="isText3 === false" placeholder="请再次填写新密码" border="surround" v-model="userInfo.newCode"
- class="input_class_pwd" :password="false">
- <template slot="suffix" v-if="userInfo.newCode">
- <u-icon name="eye-fill" @click="isText3 = true" size="20"></u-icon>
- </template>
- </u-input>
- </view>
- </view>
- <view class="card_btn">
- <u-button type="primary" :disabled="disabled" text="提交" @click="amend"></u-button>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- userInfo: {
- oldCode: '',
- sedNewCode: '',
- newCode: ''
- },
- isText1: true,
- isText2: true,
- isText3: true,
- }
- },
- computed: {
- disabled() {
- if (this.userInfo.oldCode == '' || this.userInfo.sedNewCode == '' || this.userInfo.newCode == '') {
- return true;
- } else {
- return false;
- }
- },
- },
- methods: {
- amend() {
- if (this.userInfo.sedNewCode === this.userInfo.newCode) {
- this.$api.put('/api/user/pwd/set', {
- oldPassword: this.userInfo.oldCode,
- newPassword: this.userInfo.newCode,
- }).then(res => {
- if (res.code == 200) {
- this.$cache.removeToken()
- this.$cache.removeCache('userInfo')
- uni.redirectTo({
- url: '/pages/login'
- })
- } else {
- uni.showToast({
- title: res.data.msg,
- icon: 'none'
- });
- }
- })
- } else {
- uni.showToast({
- title: '输入两次密码不一样',
- icon: 'none'
- });
- }
- },
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #fff !important;
- }
- .card_password {
- padding: 20rpx 40rpx 40rpx 40rpx;
- }
- .item_pass {
- margin-top: 30rpx;
- }
- .pass_title {
- margin-bottom: 20rpx;
- }
- .card_btn {
- margin: 40rpx;
- }
- </style>
|