index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <header class="login">
  3. <van-nav-bar title="企业注册" left-text="返回" left-arrow @click-left="back"></van-nav-bar>
  4. <van-form class="login_form" @submit="register">
  5. <van-field class="form_input" v-model="form.companyName" name="companyName" label="公司名称" placeholder="请输入公司名称" :rules="rules.companyName" />
  6. <van-field class="form_input" v-model="form.name" name="name" label="姓名" placeholder="请输入姓名" :rules="rules.name" />
  7. <van-field class="form_input" v-model="form.phone" name="phone" label="手机号" placeholder="请输入手机号" :rules="rules.phone" />
  8. <div class="form_tip">手机号为负责人登录账号,默认密码:<span>000000</span></div>
  9. <div class="form_btn" style="margin: 16px;">
  10. <van-button round block type="info" native-type="submit"> 注册 </van-button>
  11. </div>
  12. </van-form>
  13. </header>
  14. </template>
  15. <script>
  16. import { constants } from "crypto";
  17. export default {
  18. data() {
  19. return {
  20. form: {
  21. companyName: '',
  22. name: '',
  23. phone: ''
  24. },
  25. rules: {
  26. companyName: [{ required: true, message: '请输入公司名称' }],
  27. name: [{ required: true, message: '请输入姓名' }],
  28. phone: [
  29. { required: true, message: '请输入手机号' },
  30. { validator: this.phoneValidator, message: '手机号格式错误' },
  31. ]
  32. }
  33. };
  34. },
  35. methods: {
  36. phoneValidator(val) {
  37. return /1\d{10}/.test(val);
  38. },
  39. register() {
  40. const toast = this.$toast.loading({
  41. forbidClick: true,
  42. duration: 0
  43. });
  44. this.$axios.post("/user/insertCompany", this.form)
  45. .then(res => {
  46. if(res.code == "ok") {
  47. toast.clear();
  48. this.$toast.success('注册成功');
  49. this.$router.push("/login");
  50. } else {
  51. toast.clear();
  52. this.$toast.fail('注册失败');
  53. }
  54. }).catch(err=> {toast.clear();});
  55. },
  56. back() {
  57. this.$router.push("/login");
  58. }
  59. },
  60. };
  61. </script>
  62. <style lang="less" scoped>
  63. .logo {
  64. font-size: 100px !important;
  65. margin-bottom: 150px;
  66. }
  67. /* 本页公共样式 */
  68. .login {
  69. height: 100vh;
  70. background-color: #fff;
  71. }
  72. header {
  73. text-align: center;
  74. }
  75. .login_form {
  76. padding-top: 20px;
  77. .form_input {
  78. margin: 0 0 30px 0;
  79. }
  80. .form_btn {
  81. width: 80%;
  82. margin: 0 auto !important;
  83. button {
  84. background-color: #20a0ff;
  85. }
  86. }
  87. .form_tip {
  88. margin: 0 0 30px 0;
  89. font-size: 14px;
  90. color: #afafaf;
  91. span {
  92. color: #ff0000;
  93. }
  94. }
  95. }
  96. </style>
  97. <style lang="less">
  98. .van-nav-bar .van-icon , .van-nav-bar__text {
  99. color: #20a0ff;
  100. }
  101. </style>