111
k94314517
2023-10-16 ca73a173f008c8d7a9d700bad897ca24fe2d2203
minipro_standard/pages/changePassword/changePassword.vue
@@ -10,6 +10,7 @@
            <view class="password_list_item_box">
               <input type="password" v-model="form.originalPassword" maxlength="20" placeholder="请输入原密码">
            </view>
            <text class="password_list_item_btn" @click="forgotPassword">忘记密码</text>
         </view>
         <view class="password_list_item">
            <text>新密码</text>
@@ -25,7 +26,7 @@
         </view>
      </view>
      <view class="password_footer">
         <button v-preventReClick class="password_footer_submit">
         <button class="password_footer_submit" @click="submit">
            <text>完成</text>
         </button>
      </view>
@@ -33,6 +34,7 @@
</template>
<script>
   import { updatePwd } from '@/util/api/PersonalAPI'
   export default {
      data() {
         return {
@@ -42,6 +44,40 @@
               confirmPassword: ''
            }
         };
      },
      methods: {
         // 忘记密码
         forgotPassword() {
            uni.navigateTo({
               url: '/pages_adjust/pages/forgotPassword/forgotPassword'
            });
         },
         // 提交修改
         submit() {
            if (!this.form.originalPassword) {
               uni.showToast({ title: '原密码不能为空', icon: 'none', duration: 2000 });
            } else if (!this.form.newPassword) {
               uni.showToast({ title: '新密码不能为空', icon: 'none', duration: 2000 });
            } else if (!/^([a-z0-9\.\@\!\#\(/)/$\%\^\&\*\(\)]){6,20}$/i.test(this.form.newPassword)) {
               uni.showToast({ title: '密码格式不正确', icon: 'none', duration: 2000 });
            } else if (!this.form.confirmPassword) {
               uni.showToast({ title: '确认密码不能为空', icon: 'none', duration: 2000 });
            } else if (this.form.newPassword !== this.form.confirmPassword) {
               uni.showToast({ title: '两次输入的密码不一致', icon: 'none', duration: 2000 });
            } else {
               updatePwd({
                  newPwd: this.form.newPassword,
                  oldPwd: this.form.originalPassword
               }).then(res => {
                  if (res.code === 200) {
                     uni.showToast({ title: '修改成功', icon: 'success', duration: 2000, mask: true });
                     setTimeout(() => {
                        uni.navigateBack({ delta: 1 });
                     }, 2000)
                  }
               })
            }
         }
      }
   }
</script>
@@ -83,6 +119,13 @@
                   font-weight: 400;
                   color: #222222;
               }
            .password_list_item_btn {
               text-align: right;
               font-size: 26rpx;
               font-family: PingFangSC-Regular, PingFang SC;
               font-weight: 400;
               color: #4275FC;
            }
               .password_list_item_box {
                   display: flex;
                   justify-content: space-between;