EnterpriseRegistration.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <div class="register">
  3. <div class="container">
  4. <div class="content">
  5. <div class="content-top">
  6. <h3>企业注册</h3>
  7. </div>
  8. <div v-if="activeTab == 0">
  9. <el-form :model="enterprise" :rules="rules" ref="enterprise" label-width="100px" class="demo-ruleForm">
  10. <el-form-item prop="mobile">
  11. <el-input v-model="enterprise.mobile" placeholder="手机号码"></el-input>
  12. <span class="tip" v-show="showMsgTip">单个手机号只能注册一个用户</span>
  13. <span class="tip tip-mobile"
  14. v-show="mobileRegister">该手机号已被注册</span>
  15. </el-form-item>
  16. <el-form-item prop="code">
  17. <el-input type="text" v-model="enterprise.code"
  18. v-bind:class="{ active: this.codeErrorChecked }" auto-complete="off" class="msg" placeholder="短信验证码"></el-input>
  19. <el-button type="primary" class="code"
  20. v-show="sendEnterpriseCode"
  21. @click="getCheckCode"
  22. :disabled="getCodeBtnIsDisabled">获取验证码</el-button>
  23. <el-button type="primary" v-show="!sendEnterpriseCode" class="code code-send">已发送({{enterprise_time}}s)</el-button>
  24. <span v-show="codeErrorChecked" class="codeError-tip">验证码输入错误</span>
  25. </el-form-item>
  26. <el-form-item>
  27. <a class="btn finish"
  28. @click="CheckPhone"
  29. :disabled="!this.checked || !this.mobileChecked || !this.codeChecked">验证手机</a>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-checkbox name="type" v-model="checked" @click="checkboxIsChecked"></el-checkbox>
  33. <span class="agree">我已阅读并同意 <a href="">《优软云服务条款》</a></span>
  34. </el-form-item>
  35. </el-form>
  36. </div>
  37. <form action="" v-if="activeTab == 1">
  38. <div class="form-group">
  39. <input type="text" class="form-control" placeholder="企业名称" />
  40. </div>
  41. <div class="form-group">
  42. <input type="text" class="form-control" placeholder="营业执照号" />
  43. </div>
  44. <div class="form-group">
  45. <input type="text" class="form-control" placeholder="管理员姓名" />
  46. </div>
  47. <div class="form-group">
  48. <input type="text" class="form-control" placeholder="登录密码" />
  49. <i class="fa fa-keyboard-o" aria-hidden="true"></i>
  50. <!--<div class="pwd sm">密码强度 <em></em><em></em><em></em><span>弱</span></div>-->
  51. <!--<div class="pwd md">密码强度 <em></em><em></em><em></em><span>中</span></div>-->
  52. <div class="pwd lar">密码强度 <em></em><em></em><em></em><span>强</span></div>
  53. </div>
  54. <div class="form-group">
  55. <input type="text" class="form-control" placeholder="密码确认" />
  56. <i class="fa fa-keyboard-o" aria-hidden="true"></i>
  57. </div>
  58. <div class="form-group">
  59. <input type="text" class="form-control" placeholder="联系邮箱" />
  60. </div>
  61. <button class="btn">确认注册</button>
  62. </form>
  63. <form action="" v-if="activeTab == 2">
  64. <div class="form-group">
  65. <input type="text" class="form-control" placeholder="企业名称" />
  66. </div>
  67. <div class="form-group">
  68. <input type="text" class="form-control" placeholder="营业执照号" />
  69. </div>
  70. <div class="form-group">
  71. <input type="text" class="form-control" placeholder="密码确认" />
  72. <i class="fa fa-keyboard-o" aria-hidden="true"></i>
  73. <span class="sure">手机号已注册过优软云,请输入原密码</span>
  74. </div>
  75. <button class="btn">确认注册</button>
  76. </form>
  77. </div>
  78. <div class="login">已有账号?<a href="">立即登录</a></div>
  79. </div>
  80. </div>
  81. </template>
  82. <script>
  83. export default {
  84. name: 'EnterpriseRegistration',
  85. data () {
  86. var validateMobile = (rule, value, callback) => {
  87. if (value === '') {
  88. callback(new Error('请填写正确的手机号'))
  89. this.showMsgTip = false
  90. this.getCodeBtnIsDisabled = true
  91. this.mobileChecked = false
  92. console.log(this.mobileChecked)
  93. } else {
  94. if (this.enterprise.mobile !== '') {
  95. var reg = /^1[0-9]{10}$/
  96. if (!reg.test(value)) {
  97. callback(new Error('请填写正确的手机号'))
  98. this.showMsgTip = false
  99. this.getCodeBtnIsDisabled = true
  100. this.mobileChecked = false
  101. } else {
  102. this.getCodeBtnIsDisabled = false
  103. this.showMsgTip = false
  104. this.mobileChecked = true
  105. }
  106. }
  107. callback()
  108. }
  109. }
  110. var validateCode = (rule, value, callback) => {
  111. if (value === '') {
  112. callback(new Error('请填写正确的验证码'))
  113. this.codeErrorChecked = false
  114. this.codeChecked = false
  115. } else {
  116. if (this.enterprise.code !== '') {
  117. if (this.token !== '') {
  118. if (this.enterprise.code !== '' && this.enterprise.mobile !== '') {
  119. let param = new FormData()
  120. param.append('mobile', this.enterprise.mobile)
  121. param.append('code', this.enterprise.code)
  122. param.append('token', this.token)
  123. let config = {
  124. headers: {'Content-Type': 'multipart/form-data'}
  125. }
  126. this.$http.post(`/sso/personal/register/checkCode`, param, config)
  127. .then(response => {
  128. if (response.data.success) {
  129. this.codeChecked = true
  130. this.codeErrorChecked = false
  131. } else {
  132. this.codeErrorChecked = true
  133. this.codeChecked = false
  134. }
  135. }, err => {
  136. // console.log(err)
  137. this.$message.error(err)
  138. })
  139. }
  140. } else {}
  141. }
  142. callback()
  143. }
  144. }
  145. return {
  146. activeTab: 0,
  147. enterprise: {
  148. mobile: '',
  149. code: ''
  150. },
  151. checked: true,
  152. getCodeBtnIsDisabled: true,
  153. mobileChecked: false,
  154. codeChecked: false,
  155. showMsgTip: true,
  156. mobileRegister: false,
  157. sendEnterpriseCode: true,
  158. codeErrorChecked: false,
  159. enterprise_time: 0,
  160. rules: {
  161. mobile: [
  162. {validator: validateMobile, trigger: 'blur'}
  163. ],
  164. code: [
  165. {validator: validateCode, trigger: 'blur'}
  166. ]
  167. }
  168. }
  169. },
  170. methods: {
  171. // 我同意是否被选中
  172. checkboxIsChecked () {
  173. this.checked = !this.checked
  174. },
  175. // 获取校验码
  176. getCheckCode () {
  177. this.$http.get(`/sso/userspace/register/checkCode`, {params: {mobile: this.enterprise.mobile}})
  178. .then(response => {
  179. this.token = response.data.token
  180. if (this.token !== '') {
  181. this.$message({
  182. message: '验证码已经发送到您的手机,请注意查收',
  183. type: 'success'
  184. })
  185. this.sendEnterpriseCode = false
  186. this.enterprise_time = 60
  187. var enterpriseTime = setInterval(() => {
  188. this.enterprise_time--
  189. if (this.enterprise_time <= 0) {
  190. this.sendEnterpriseCode = true
  191. clearInterval(enterpriseTime)
  192. }
  193. }, 1000)
  194. }
  195. }).catch(err => {
  196. console.log(err)
  197. this.$message.error(err.errMsg)
  198. })
  199. },
  200. // 验证手机
  201. CheckPhone () {
  202. if (this.mobileChecked && this.codeChecked) {
  203. var url = window.location.search
  204. var request = {}
  205. if (url.indexOf('?' !== -1)) {
  206. var str = url.substr(1)
  207. var strs = str.split('&')
  208. for (var i = 0; i < strs.length; i++) {
  209. request[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1])
  210. }
  211. }
  212. var appId = request['appId']
  213. console.log(appId)
  214. let param = new FormData()
  215. param.append('mobile', this.enterprise.mobile)
  216. param.append('code', this.enterprise.code)
  217. param.append('appId', appId)
  218. param.append('token', this.token)
  219. let config = {
  220. headers: {'Content-Type': 'multipart/form-data'}
  221. }
  222. this.$http.post('/sso/userspace/register/checkAdminTel', param, config)
  223. .then(response => {
  224. if (response.data.success) {
  225. console.log(response.data)
  226. } else {
  227. return Promise.reject(response.data)
  228. }
  229. }).catch(err => {
  230. console.log(err)
  231. this.$message.error(err.errMsg)
  232. })
  233. }
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="scss" scoped>
  239. .register {
  240. padding-bottom: 145px;
  241. margin: 0 auto;
  242. width: 100%;
  243. background: #eee;
  244. .container{
  245. padding-top: 50px;
  246. margin: 0 auto;
  247. width: 980px;
  248. text-align: center;
  249. .content{
  250. padding: 0 50px;
  251. margin: 50px auto 0;
  252. width: 100%;
  253. text-align: center;
  254. background: #fff;
  255. .content-top{
  256. height: 80px;
  257. line-height: 80px;
  258. border-bottom: 1px solid #dcdcdc;
  259. h3{
  260. font-family: 'SimHei';
  261. font-size: 24px;
  262. color: #000;
  263. }
  264. }
  265. form {
  266. padding-bottom: 44px;
  267. margin-top: 35px;
  268. span.sure{
  269. position: absolute;
  270. top: 0;
  271. right: -240px;
  272. font-size: 13px;
  273. color: #8c8c8c;
  274. }
  275. span.codeError-tip{
  276. position: absolute;
  277. top: 3px;
  278. right: -105px;
  279. color: #ff4949;
  280. font-size: 12px;
  281. }
  282. input{
  283. padding: 0 0 0 18px;
  284. width: 360px;
  285. height: 44px;
  286. line-height: 44px;
  287. font-size: 14px;
  288. color: #000;
  289. border-radius: 0;
  290. }
  291. i{
  292. position: absolute;
  293. top: 10px;
  294. right: 18px;
  295. font-size: 24px;
  296. color: #a0a0a0;
  297. cursor: pointer;
  298. }
  299. .pwd {
  300. position: absolute;
  301. top: 0;
  302. right: -205px;
  303. font-size: 13px;
  304. em{
  305. display: inline-block;
  306. margin: 0 8px 2px 0;
  307. width: 24px;
  308. height: 6px;
  309. &:first-child{
  310. margin-left: 10px;
  311. }
  312. }
  313. span{
  314. margin-left: 10px;
  315. font-size: 13px;
  316. }
  317. }
  318. .pwd.sm{
  319. color: #8c8c8c;
  320. em {
  321. background: #bfbfbf;
  322. &:first-child{
  323. background: #ff4e00;
  324. }
  325. }
  326. span{
  327. color: #ff4e00;
  328. }
  329. }
  330. .pwd.md{
  331. color: #8c8c8c;
  332. em {
  333. background: #22ac38;
  334. &:nth-child(3){
  335. background: #bfbfbf;
  336. }
  337. }
  338. span{
  339. color: #22ac38;
  340. }
  341. }
  342. .pwd.lar{
  343. color: #8c8c8c;
  344. em {
  345. background: #00a0e9;
  346. }
  347. span{
  348. color: #00a0e9;
  349. }
  350. }
  351. span.tip{
  352. position: absolute;
  353. top: 0;
  354. right: -190px;
  355. font-size: 13px;
  356. color: #8c8c8c;
  357. }
  358. input.msg{
  359. float: left;
  360. width: 210px;
  361. }
  362. span.msg{
  363. float: right;
  364. width: 130px;
  365. height: 44px;
  366. line-height: 44px;
  367. font-size: 14px;
  368. color: #5a5a5a;
  369. background: #f4f4f4;
  370. border: 1px solid #dcdcdc;
  371. cursor: pointer;
  372. }
  373. span.msg.send{
  374. background: #d2d2d2;
  375. color: #fff;
  376. }
  377. input[type='checkbox']{
  378. margin: 0 14px 0 55px;
  379. float: left;
  380. width: 16px;
  381. height: 16px;
  382. }
  383. span.agree{
  384. float: left;
  385. margin: 0 0 0 10px;
  386. font-size: 14px;
  387. color: #8b8b8b;
  388. a{
  389. color: #0076ad;
  390. }
  391. }
  392. .form-group.agree{
  393. margin: 20px auto 0 !important;
  394. }
  395. .btn {
  396. margin: 34px 0 16px 0;
  397. width: 360px;
  398. height: 44px;
  399. line-height: 44px;
  400. font-size: 16px;
  401. color: #fff;
  402. background: #0076AD;
  403. border-radius: 3px;
  404. }
  405. }
  406. }
  407. .login{
  408. margin-top: 20px;
  409. font-size: 14px;
  410. color: #8c8c8c;
  411. a{
  412. font-size: 14px;
  413. color: #0076ad;
  414. }
  415. }
  416. }
  417. }
  418. </style>