Mr.Shi
2023-09-04 682182cf67a5aa9fed34335fea22d4673f30f10c
minipro_standard/pages/changePassword/changePassword.vue
@@ -25,7 +25,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 +33,7 @@
</template>
<script>
   import { updatePwd } from '@/util/api/PersonalAPI'
   export default {
      data() {
         return {
@@ -42,6 +43,38 @@
               confirmPassword: ''
            }
         };
      },
      methods: {
         // 忘记密码
         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-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{6,}$/.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>