Register.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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">{{ $t('zhuCe') }}</h3>
  9. <el-form-item class="login-input" prop="companyName">
  10. <el-input type="text" v-model="ruleForm.companyName" autocomplete="off" :placeholder="$t('gongSiMing')" 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="$t('lable.name')" 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="$t('lable.phone')" 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="$t('yanZhengMa')" @keyup.enter.native="sendVcode()" clearable prefix-icon="iconfont firerock-iconyanzhengma">
  20. <el-button slot="append" @click="sendVcode" :disabled="ruleForm.phone=='' || showTimer">{{ $t('faSongYanZhengMa') }}<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="$t('sheZhiMiMaChangDuBuDiYu_6Wei')" 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="$t('zhongFuMiMa')" 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>{{ $t('xuanZeBanBen') }} </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">{{ $t('zhuCe') }}</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:this.$t('gongShiTongJiJiChuBan')},
  51. {id:2,name:this.$t('xiangMuGuanLiZhuanYeBan')},{id:3,name:this.$t('qiYeBanGongQiJianBan')},{id:4,name:this.$t('gongChengGuanLiZhuanYeBan')}],
  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: this.$t('qingShuRuGongSiMing'), trigger: 'blur' },],
  64. name: [{ required: true, message: this.$t('defaultText.PleaseEnterYourName'), trigger: 'blur' },],
  65. phone: [{ required: true, message: this.$t('defaultText.PleaseEnterYourPhone'), trigger: 'blur' },],
  66. vcode: [{ required: true, message: this.$t('qingShuRuYanZhengMa'), trigger: 'blur' },],
  67. password: [{ required: true, message: this.$t('qingSheZhiMiMaChangDuBuDiYu_6Wei'), trigger: 'blur' },],
  68. repwd: [{ required: true, message: this.$t('qingZhongFuShuRuMiMa'), 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: this.$t('shouJiHaoMaGeShiBuZhengQue'),
  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: this.$t('faSongChengGong'),
  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: this.$t('miMaChangDuBuNengShaoYu_6Wei'),
  125. type: 'error'
  126. });
  127. return;
  128. }
  129. //检查两次密码是否一致
  130. if (this.ruleForm.password != this.ruleForm.repwd) {
  131. this.$message({
  132. message: this.$t('liangCiShuRuDeMiMaBuYiZhi'),
  133. type: 'error'
  134. });
  135. return;
  136. }
  137. let formObj = this.ruleForm
  138. if(this.$route.query != {}) {
  139. formObj = {
  140. ...this.$route.query,
  141. ...formObj
  142. }
  143. }
  144. var _this = this;
  145. this.logining = true;
  146. this.http.post(this.port.manage.register, formObj, res => {
  147. this.logining = false;
  148. if (res.code == "ok") {
  149. this.$message({
  150. message: this.$t('zhuCeChengGong'),
  151. type: 'success'
  152. });
  153. this.$router.push({ path: '/login' });
  154. } else {
  155. this.$message({
  156. message: res.msg,
  157. type: 'error'
  158. });
  159. }
  160. }, error => {
  161. this.logining = false;
  162. this.$message({
  163. message: error,
  164. type: 'error'
  165. });
  166. })
  167. }
  168. });
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss" scoped>
  174. @import "../assets/scss/handle";
  175. .login {
  176. height: 100%;
  177. .login-par {
  178. width: 100%;
  179. min-height: 100%;
  180. background: #f0f2f5 url('../assets/image/background.png') no-repeat 50%;
  181. background-size: 100%;
  182. padding: 110px 0 144px;
  183. position: relative;
  184. box-sizing: border-box;
  185. .login-logo {
  186. text-align: center;
  187. margin: 0 0 20px 0;
  188. }
  189. .login-container {
  190. -webkit-border-radius: 5px;
  191. border-radius: 5px;
  192. -moz-border-radius: 5px;
  193. background-clip: padding-box;
  194. width: 450px;
  195. height: 495px;
  196. padding: 25px 35px 25px 35px;
  197. background: #fff;
  198. border: 1px solid;
  199. box-shadow: 0 0 5px #cac6c6;
  200. border-top: 10px solid;
  201. @include border_color("border_color");
  202. margin:auto;
  203. .title {
  204. font-size: 20px;
  205. margin: 0px auto 30px auto;
  206. text-align: center;
  207. color: #505458;
  208. }
  209. .remember {
  210. margin: 0px 0px 35px 0px;
  211. }
  212. .login-input {
  213. margin: 15px 0 0 0;
  214. }
  215. .login-button {
  216. margin: 50px 0 0 0;
  217. }
  218. .login-button .el-button {
  219. padding: 14px;
  220. }
  221. }
  222. }
  223. }
  224. </style>