Register.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="login">
  3. <div class="login-par">
  4. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-position="left" label-width="0px" class="demo-ruleForm login-container">
  5. <!-- <div class="login-logo">
  6. <img src="../assets/image/login_logo.png" style="width:80px;height:80px;"/>
  7. </div> -->
  8. <h3 class="title">注册</h3>
  9. <el-form-item class="login-input" prop="companyName">
  10. <el-input type="text" v-model="ruleForm.companyName" autocomplete="off" placeholder="公司名" clearable prefix-icon="el-icon-s-home"></el-input>
  11. </el-form-item>
  12. <el-form-item class="login-input" prop="name">
  13. <el-input type="text" v-model="ruleForm.name" autocomplete="off" placeholder="姓名" clearable prefix-icon="el-icon-user-solid"></el-input>
  14. </el-form-item>
  15. <el-form-item class="login-input" prop="phone">
  16. <el-input type="text" v-model="ruleForm.phone" autocomplete="off" placeholder="手机号" clearable prefix-icon="el-icon-mobile-phone"></el-input>
  17. </el-form-item>
  18. <el-form-item class="login-input" prop="vcode">
  19. <el-input type="text" v-model="ruleForm.vcode" autocomplete="off" placeholder="验证码" clearable prefix-icon="iconfont firerock-iconyanzhengma">
  20. <el-button slot="append" @click="sendVcode" :disabled="ruleForm.phone=='' || showTimer">发送验证码<span v-if="showTimer">({{countNum}})</span></el-button>
  21. </el-input>
  22. </el-form-item>
  23. <el-form-item class="login-input" prop="password">
  24. <el-input type="password" v-model="ruleForm.password" autocomplete="off" placeholder="设置密码,长度不低于6位" clearable prefix-icon="iconfont firerock-iconmima">
  25. </el-input>
  26. </el-form-item>
  27. <el-form-item class="login-input" prop="repwd">
  28. <el-input type="password" v-model="ruleForm.repwd" autocomplete="off" placeholder="重复密码" clearable prefix-icon="iconfont firerock-iconmima">
  29. </el-input>
  30. </el-form-item>
  31. <el-form-item class="login-input" prop="type" style="text-align:center;">
  32. <el-divider ></el-divider>
  33. <div style="margin-top:10px;">
  34. <span>选择版本: </span><el-select v-model="ruleForm.type" style="width:250px;">
  35. <el-option v-for="item in typeList" :value="item.id" :label="item.name" :key="item.id"></el-option>
  36. </el-select>
  37. </div>
  38. </el-form-item>
  39. <div class="login-button" style="width:100%;margin-top:20px;">
  40. <el-button type="primary" style="width:100%;" @click.native.prevent="handleSubmit" :loading="logining">注册</el-button>
  41. </div>
  42. </el-form>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. typeList:[{id:0,name:'工时统计表简易版'},{id:1,name:'工时统计基础版'},
  51. {id:2,name:'项目管理专业版'},{id:3,name:'工程管理专业版'}],
  52. logining: false,
  53. showTimer: false,
  54. countNum: 60,
  55. // 登录信息
  56. ruleForm: {
  57. companyName: '',
  58. name: '',
  59. phone: '',
  60. type:2,
  61. },
  62. rules: {
  63. companyName: [{ required: true, message: '请输入公司名', trigger: 'blur' },],
  64. name: [{ required: true, message: '请输入姓名', trigger: 'blur' },],
  65. phone: [{ required: true, message: '请输入手机号', trigger: 'blur' },],
  66. vcode: [{ required: true, message: '请输入验证码', trigger: 'blur' },],
  67. password: [{ required: true, message: '请设置密码,长度不低于6位', trigger: 'blur' },],
  68. repwd: [{ required: true, message: '请重复输入密码', trigger: 'blur' },]
  69. }
  70. };
  71. },
  72. methods: {
  73. //开始倒计时
  74. countDown() {
  75. if (this.countNum > 0) {
  76. this.countNum--;
  77. } else {
  78. clearInterval(this.timer);
  79. this.showTimer = false;
  80. }
  81. },
  82. sendVcode() {
  83. if (this.ruleForm.phone.length != 11) {
  84. this.$message({
  85. message: '手机号码格式不正确',
  86. type: 'error'
  87. });
  88. } else {
  89. this.http.post('/user/sendVcode', {mobile: this.ruleForm.phone} , res => {
  90. this.logining = false;
  91. if (res.code == "ok") {
  92. this.$message({
  93. message: '发送成功',
  94. type: 'success'
  95. });
  96. this.showTimer = true;
  97. this.countNum = 60;
  98. this.timer = setInterval(this.countDown, 1000);
  99. } else {
  100. this.$message({
  101. message: res.msg,
  102. type: 'error'
  103. });
  104. }
  105. }, error => {
  106. this.logining = false;
  107. this.$message({
  108. message: error,
  109. type: 'error'
  110. });
  111. })
  112. }
  113. },
  114. handleReset2() {
  115. this.$refs.ruleForm.resetFields();
  116. },
  117. handleSubmit(ev) {
  118. this.$refs.ruleForm.validate((valid) => {
  119. if (valid) {
  120. if (this.ruleForm.password.length < 6) {
  121. this.$message({
  122. message: '密码长度不能少于6位',
  123. type: 'error'
  124. });
  125. return;
  126. }
  127. //检查两次密码是否一致
  128. if (this.ruleForm.password != this.ruleForm.repwd) {
  129. this.$message({
  130. message: '两次输入的密码不一致',
  131. type: 'error'
  132. });
  133. return;
  134. }
  135. var _this = this;
  136. this.logining = true;
  137. this.http.post(this.port.manage.register, this.ruleForm , res => {
  138. this.logining = false;
  139. if (res.code == "ok") {
  140. this.$message({
  141. message: '注册成功',
  142. type: 'success'
  143. });
  144. this.$router.push({ path: '/login' });
  145. } else {
  146. this.$message({
  147. message: res.msg,
  148. type: 'error'
  149. });
  150. }
  151. }, error => {
  152. this.logining = false;
  153. this.$message({
  154. message: error,
  155. type: 'error'
  156. });
  157. })
  158. }
  159. });
  160. }
  161. }
  162. }
  163. </script>
  164. <style lang="scss" scoped>
  165. .login {
  166. height: 100%;
  167. .login-par {
  168. width: 100%;
  169. min-height: 100%;
  170. background: #f0f2f5 url('../assets/image/background.png') no-repeat 50%;
  171. background-size: 100%;
  172. padding: 110px 0 144px;
  173. position: relative;
  174. box-sizing: border-box;
  175. .login-logo {
  176. text-align: center;
  177. margin: 0 0 20px 0;
  178. }
  179. .login-container {
  180. -webkit-border-radius: 5px;
  181. border-radius: 5px;
  182. -moz-border-radius: 5px;
  183. background-clip: padding-box;
  184. width: 450px;
  185. height: 495px;
  186. padding: 25px 35px 25px 35px;
  187. background: #fff;
  188. border: 1px solid #eaeaea;
  189. box-shadow: 0 0 5px #cac6c6;
  190. border-top: 10px solid #20a0ff;
  191. margin:auto;
  192. .title {
  193. font-size: 20px;
  194. margin: 0px auto 30px auto;
  195. text-align: center;
  196. color: #505458;
  197. }
  198. .remember {
  199. margin: 0px 0px 35px 0px;
  200. }
  201. .login-input {
  202. margin: 15px 0 0 0;
  203. }
  204. .login-button {
  205. margin: 50px 0 0 0;
  206. }
  207. .login-button .el-button {
  208. padding: 14px;
  209. }
  210. }
  211. }
  212. }
  213. </style>