1.0.0 • Published 10 months ago

hjh-password v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

说明

用户信息加修改密码 组件支持 vue2,vue3

配置属性

字段类型默认值描述
isChangePasswordbooleantrue是否显示修改密码
isTelephonebooleantrue是否显示手机号
isRolebooleantrue是否显示角色
isUserNamebooleantrue是否显示账号
userInfoobject{name: "name", phoneNum: "telephone", role: "role", acctName: "userName"}用户信息

配置方法

方法名参数返回类型描述
changePasswordval: anyvoid提交修改密码
doFlagvoid是否需要双因子认证
verificationCodevoid双因子认证短信验证
setFlage: booleanvoid控制是否展示双因子弹窗(通过 ref 调用)
changeDialoge: booleanvoid点击提交修改密码成功后调用请传入参数 false(通过 ref 调用)

代码配置示例 :

<template>
  <hjh-password
    ref="hjhPassword"
    :userInfo="{
      name: '43534534',
      acctName: '111',
      phoneNum: '123',
      role: 'guanliy',
    }"
    @doFlag="test"
    @changePassword="change"
    @verificationCode="verificationCode"
  />
</template>

<script lang="ts" setup>
import { ref } from "vue";
import hjhPassword from "hjh-password"";
import "hjh-password/dist/style.css";
import {isEnableTwoFactorAuth,verifyCaptchaCode,modifyPassword} from '../src/api/index';

const hjhPassword=ref()
const captchaId=ref('')
const captchaKey=ref('')
const test=()=>{
  //验证是否需要双因子短信验证
  isEnableTwoFactorAuth().then(res=>{
    hjhPassword.value.setFlag(res.data.flag)
    captchaId.value=res.data.captchaId
  })
}

//不需要双因子认证这个函数不需要调用
const verificationCode=(e)=>{
  verifyCaptchaCode({captchaId:  captchaId.value,captchaCode:e}).then(res=>{
    if(res.data.captchaKey){
      //成功则关闭双因子短信验证弹窗
      hjhPassword.value.setFlag(false)
    }
})
}
const change = (data) => {
  modifyPassword({ oldPassword: data.oldPassword; newPassword: data.newPassword; captchaKey: captchaKey.value }).then(res=>{
    if(res===200){
hjhPassword.value.changeDialog(false)
    }
  })
};
</script>

接口需要三个地址:

  • 是否开启双因子:
  • 修改密码-短信验证:
  • 修改密码:
1.0.0

10 months ago