Register.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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:1,name:'工时统计基础版'},
  51. {id:2,name:'项目管理专业版'},{id:3,name:'企业办公旗舰版'},{id:4,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. mounted() {
  73. },
  74. methods: {
  75. //开始倒计时
  76. countDown() {
  77. if (this.countNum > 0) {
  78. this.countNum--;
  79. } else {
  80. clearInterval(this.timer);
  81. this.showTimer = false;
  82. }
  83. },
  84. sendVcode() {
  85. if (this.ruleForm.phone.length != 11) {
  86. this.$message({
  87. message: '手机号码格式不正确',
  88. type: 'error'
  89. });
  90. } else {
  91. this.http.post('/user/sendVcode', {mobile: this.ruleForm.phone} , res => {
  92. this.logining = false;
  93. if (res.code == "ok") {
  94. this.$message({
  95. message: '发送成功',
  96. type: 'success'
  97. });
  98. this.showTimer = true;
  99. this.countNum = 60;
  100. this.timer = setInterval(this.countDown, 1000);
  101. } else {
  102. this.$message({
  103. message: res.msg,
  104. type: 'error'
  105. });
  106. }
  107. }, error => {
  108. this.logining = false;
  109. this.$message({
  110. message: error,
  111. type: 'error'
  112. });
  113. })
  114. }
  115. },
  116. handleReset2() {
  117. this.$refs.ruleForm.resetFields();
  118. },
  119. handleSubmit(ev) {
  120. this.$refs.ruleForm.validate((valid) => {
  121. if (valid) {
  122. if (this.ruleForm.password.length < 6) {
  123. this.$message({
  124. message: '密码长度不能少于6位',
  125. type: 'error'
  126. });
  127. return;
  128. }
  129. //检查两次密码是否一致
  130. if (this.ruleForm.password != this.ruleForm.repwd) {
  131. this.$message({
  132. message: '两次输入的密码不一致',
  133. type: 'error'
  134. });
  135. return;
  136. }
  137. let formObj = this.ruleForm
  138. if(window.location.href.indexOf('360') > 1) {
  139. formObj.from = '360'
  140. }
  141. var _this = this;
  142. this.logining = true;
  143. this.http.post(this.port.manage.register, formObj, res => {
  144. this.logining = false;
  145. if (res.code == "ok") {
  146. this.$message({
  147. message: '注册成功',
  148. type: 'success'
  149. });
  150. this.$router.push({ path: '/login' });
  151. } else {
  152. this.$message({
  153. message: res.msg,
  154. type: 'error'
  155. });
  156. }
  157. }, error => {
  158. this.logining = false;
  159. this.$message({
  160. message: error,
  161. type: 'error'
  162. });
  163. })
  164. }
  165. });
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .login {
  172. height: 100%;
  173. .login-par {
  174. width: 100%;
  175. min-height: 100%;
  176. background: #f0f2f5 url('../assets/image/background.png') no-repeat 50%;
  177. background-size: 100%;
  178. padding: 110px 0 144px;
  179. position: relative;
  180. box-sizing: border-box;
  181. .login-logo {
  182. text-align: center;
  183. margin: 0 0 20px 0;
  184. }
  185. .login-container {
  186. -webkit-border-radius: 5px;
  187. border-radius: 5px;
  188. -moz-border-radius: 5px;
  189. background-clip: padding-box;
  190. width: 450px;
  191. height: 495px;
  192. padding: 25px 35px 25px 35px;
  193. background: #fff;
  194. border: 1px solid #eaeaea;
  195. box-shadow: 0 0 5px #cac6c6;
  196. border-top: 10px solid #20a0ff;
  197. margin:auto;
  198. .title {
  199. font-size: 20px;
  200. margin: 0px auto 30px auto;
  201. text-align: center;
  202. color: #505458;
  203. }
  204. .remember {
  205. margin: 0px 0px 35px 0px;
  206. }
  207. .login-input {
  208. margin: 15px 0 0 0;
  209. }
  210. .login-button {
  211. margin: 50px 0 0 0;
  212. }
  213. .login-button .el-button {
  214. padding: 14px;
  215. }
  216. }
  217. }
  218. }
  219. </style>