| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <template>
- <view class="body">
- <!-- 公共组件-每个页面必须引入 -->
- <public-module></public-module>
- <view class="form">
- <view class="password dis a-c j-s">
- <u-icon name="lock-opened-fill" color="#999" size="28"></u-icon>
- <input placeholder="旧密码" v-model="oldPassword" password=true
- placeholder-style="color: #C5C5C5;font-size:26upx" />
- </view>
- <view class="password">
- <u-icon name="lock-opened-fill" color="#999" size="28"></u-icon>
- <input placeholder="新密码(6-15位数字与字母组合)" v-model="repwd" password=true
- placeholder-style="color: #C5C5C5;font-size:26upx" />
- </view>
- <view class="password">
- <u-icon name="lock-opened-fill" color="#999" size="28"></u-icon>
- <input placeholder="确认密码" v-model="password" password=true
- placeholder-style="color: #C5C5C5;font-size:26upx" />
- </view>
- <button class="user-set-btn d-flex a-center j-center " :loading="loading" :disabled="disabled"
- type="primary" @tap="submit">完成</button>
- </view>
- </view>
- </template>
- <script>
- import {
- mapState,
- mapMutations
- } from "vuex"
- export default {
- data() {
- return {
- password: "",
- repwd: "",
- oldPassword: "",
- loading: false,
- disabled: true,
- }
- },
- watch: {
- password(val) {
- this.OnBtnChange();
- },
- repwd(val) {
- this.OnBtnChange();
- },
- oldPassword(val) {
- this.OnBtnChange();
- },
- },
- computed: {
- ...mapState(['userInfo'])
- },
- methods: {
- ...mapMutations(['emptyUserInfo']),
- // 改变按钮状态
- OnBtnChange() {
- if (this.password && this.repwd && this.oldPassword) {
- this.disabled = false;
- return;
- }
- this.disabled = true;
- },
- async submit() {
- if (!this.$base.passwordRegular.test(this.password)) {
- return uni.showToast({
- title: '密码须6-15位数字与字母组合',
- icon: 'none'
- });
- }
- if (this.password != this.repwd) {
- return uni.showToast({
- title: '两次密码输入不一致',
- icon: "none"
- });
- }
- let res = await this.$http.post('/user/updatePwd?id=' + this.userInfo.sysUser.id + '&password=' + this
- .password + '&oldPassword=' + this.oldPassword);
- if (res.code == 200) {
- this.password = "";
- this.repwd = "";
- this.oldPassword = "";
- uni.showToast({
- title: "修改密码成功",
- icon: "none"
- });
- this.emptyUserInfo();
- setTimeout(() => {
- uni.reLaunch({
- url: "/pages/login/login"
- })
- return true;
- }, 500);
- } else {
- uni.showToast({
- title: res.msg,
- icon: "none"
- });
- }
- }
- }
- }
- </script>
- <style>
- .body {
- position: absolute;
- width: 100%;
- height: 100vh;
- background-color: #F5F5F5;
- }
- .form {
- width: 100%;
- padding: 20upx 5%;
- font-size: 30upx;
- }
- .form .password {
- position: relative;
- width: 100%;
- height: 90upx;
- display: flex;
- align-items: center;
- border-radius: 5upx;
- background-color: #FFFFFF;
- padding: 0 0 0 20px;
- margin: 30rpx 0rpx 50rpx;
- }
- .form .password input {
- width: 100%;
- height: 50rpx;
- color: rgba($color: #ffffff, $alpha: 0.8);
- font-weight: 200;
- margin-left: 20px;
- }
- .icon {
- color: #999;
- height: 70upx;
- font-size: 40upx;
- z-index: 10;
- position: absolute;
- top: 10upx;
- left: 10upx;
- padding: 0 15upx;
- border-right: 2px solid #F5F5F5;
- }
- </style>
|