import { ModalConfig } from "/@/components/ResetPwd";
import { httpChangePwd } from "/@/api/mobile/user";
import { isAlphanumeric, isnumber, validAlphabets } from "/@/utils/validate";
const ResetPwd: ModalConfig = {
  title: "修改密码",
  httpChangePwd,
  formItems: [
    {
      field: "id",
      type: "input",
      labelWidth: "100px",
      isHidden: true,
      placeholder: "用户ID"
    },
    {
      field: "new_password",
      type: "input",
      placeholder: "新密码",
      label: "新密码",
      labelWidth: "100px",
      span: 24,
      rules: [
        {
          required: true,
          validator: (_, value) => {
            if (value === "") {
              return new Error("新密码不能为空！");
            } else {
              if (!isAlphanumeric(value)) {
                return new Error("新密码为6-16位数字字母组合！");
              } else if (value.length < 6 || value.length > 16) {
                return new Error("新密码为6-16位数字字母组合！");
              } else if (isnumber(value)) {
                return new Error("新密码不能为纯数字！");
              } else if (validAlphabets(value)) {
                return new Error("新密码不能为纯字母！");
              } else {
                return true;
              }
            }
          },
          trigger: "blur"
        }
      ]
    },
    {
      field: "confirmPassword",
      type: "input",
      placeholder: "确认密码",
      label: "确认密码",
      labelWidth: "100px",
      span: 24,
      rules: [
        {
          required: true,
          validator: (_, value) => {
            if (value === "") {
              return new Error("新密码不能为空！");
            } else {
              return true;
            }
          },
          trigger: "blur"
        }
      ]
    }
  ]
};

export default ResetPwd;
