EnterpriseRegistrationSecondStep.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. <template>
  2. <div class="register">
  3. <div>
  4. <el-form :model="enterprise1" :rules="rules1" ref="enterprise1" label-width="100px" class="demo-ruleForm">
  5. <el-form-item prop="spaceName">
  6. <el-input type="text"
  7. v-model="enterprise1.spaceName"
  8. v-bind:class="{ active: isSpaceNameExist }"
  9. auto-complete="off"
  10. placeholder="企业名称"
  11. ></el-input>
  12. <span class="tip exist" v-show="isSpaceNameExist">该企业已被注册,请确认。<a href="https://www.usoftchina.com/contact">仍有问题?</a></span>
  13. </el-form-item>
  14. <el-form-item prop="businessCode">
  15. <el-input type="text"
  16. v-model="enterprise1.businessCode"
  17. v-bind:class="{ active: isBusinessCodeExist }"
  18. auto-complete="off"
  19. placeholder="营业执照号"></el-input>
  20. <span class="tip exist" v-show="isBusinessCodeExist">该企业已被注册,请确认。<a href="https://www.usoftchina.com/contact">仍有问题?</a></span>
  21. </el-form-item>
  22. <el-form-item prop="vipName" v-if="!isHasRegister">
  23. <el-input type="text" v-model="enterprise1.vipName" auto-complete="off" placeholder="管理员姓名"></el-input>
  24. </el-form-item>
  25. <el-form-item prop="password" v-if="!isHasRegister">
  26. <el-input type="password" v-model="enterprise1.password" auto-complete="off" placeholder="登录密码"></el-input>
  27. <div class="pwd sm" v-show="showMsgTip1">密码强度 <em></em><em></em><em></em><span>弱</span></div>
  28. <div class="pwd md" v-show="showMsgTip2">密码强度 <em></em><em></em><em></em><span>中</span></div>
  29. <div class="pwd lar" v-show="showMsgTip3">密码强度 <em></em><em></em><em></em><span>强</span></div>
  30. <div class="pwd low" v-show="showMsgTip4">密码强度 <em></em><em></em><em></em></div>
  31. </el-form-item>
  32. <el-form-item prop="password" v-if="isHasRegister">
  33. <el-input type="password"
  34. v-model="enterprise1.password"
  35. auto-complete="off"
  36. placeholder="密码确认"
  37. v-bind:class="{ correct: this.passwordChecked }"></el-input>
  38. <span class="sure" v-if="isHasRegister" v-show="phoneIsRegisterTip">手机号已注册,请输入原密码 <a>忘记密码?</a></span>
  39. </el-form-item>
  40. <el-form-item prop="confirm" v-if="!isHasRegister">
  41. <el-input type="password"
  42. auto-complete="off"
  43. placeholder="密码确认"
  44. v-model="enterprise1.confirm"></el-input>
  45. </el-form-item>
  46. <el-form-item prop="email" v-if="!isHasEmail">
  47. <el-input type="text" v-model="enterprise1.email" auto-complete="off" placeholder="联系邮箱"></el-input>
  48. </el-form-item>
  49. <a class="btn finish"
  50. :disabled="!isHasRegister ? !spaceNameChecked || !businessCodeChecked || !vipNameChecked || !passwordChecked || !passwordConfirmChecked || !emailChecked || !checked : !isHasEmail ? !spaceNameChecked || !businessCodeChecked || !passwordChecked || !emailChecked || !checked : !spaceNameChecked || !businessCodeChecked || !passwordChecked || !checked"
  51. @click="sureRegister">确认注册
  52. </a>
  53. </el-form-item>
  54. <el-form-item>
  55. <el-checkbox name="type" v-model="checked" @click="checkboxIsChecked"></el-checkbox>
  56. <span class="agree">我已阅读并同意 <a href="/common/agreement">《优软云服务条款》</a></span>
  57. </el-form-item>
  58. </el-form>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. export default {
  64. name: 'EnterpriseRegistrationSecondStep',
  65. data () {
  66. // 企业注册第二步
  67. var validateSpaceName = (rule, value, callback) => {
  68. if (value === '') {
  69. callback(new Error('请填写正确的企业名称'))
  70. this.spaceNameChecked = false
  71. } else {
  72. if (this.enterprise1.spaceName !== '') {
  73. if (value.length > 20) {
  74. callback(new Error('输入长度过长,20个字符以内'))
  75. this.spaceNameChecked = false
  76. } else {
  77. this.$http.get(`/api/userspace/checkSpaceName`, {params: {spaceName: this.enterprise1.spaceName}})
  78. .then(response => {
  79. if (response.data.success) {
  80. this.spaceNameChecked = true
  81. this.isSpaceNameExist = false
  82. } else {
  83. this.spaceNameChecked = false
  84. this.isSpaceNameExist = true
  85. return Promise.reject(response.data)
  86. }
  87. }).catch(err => {
  88. // console.log(err)
  89. this.$message.error(err.errMsg)
  90. })
  91. }
  92. }
  93. callback()
  94. }
  95. }
  96. var validateBusinessCode = (rule, value, callback) => {
  97. if (value === '') {
  98. callback(new Error('请填写正确的营业执照号'))
  99. this.businessCodeChecked = false
  100. } else {
  101. if (this.enterprise1.businessCode !== '') {
  102. let reg = /^[0-9]*$/
  103. if (reg.test(value)) {
  104. if (value.length > 20) {
  105. callback(new Error('输入长度过长,20个字符以内'))
  106. this.businessCodeChecked = false
  107. this.isBusinessCodeExist = false
  108. } else {
  109. this.$http.get(`/api/userspace/checkBusinessCode`, {params: {businessCode: this.enterprise1.businessCode}})
  110. .then(response => {
  111. if (response.data.success) {
  112. this.businessCodeChecked = true
  113. this.isBusinessCodeExist = false
  114. } else {
  115. this.businessCodeChecked = false
  116. this.isBusinessCodeExist = true
  117. return Promise.reject(response.data)
  118. }
  119. }).catch(err => {
  120. // console.log(err)
  121. this.$message.error(err.errMsg)
  122. })
  123. }
  124. } else {
  125. callback(new Error('请填写正确的营业执照号'))
  126. this.businessCodeChecked = false
  127. this.isBusinessCodeExist = false
  128. }
  129. }
  130. callback()
  131. }
  132. }
  133. var validateVipName = (rule, value, callback) => {
  134. if (this.isHasRegister) {
  135. this.vipNameChecked = true
  136. } else {
  137. if (value === '') {
  138. callback(new Error('请填写正确的管理员姓名'))
  139. this.vipNameChecked = false
  140. } else {
  141. if (this.enterprise1.vipName !== '') {
  142. if (value.length > 20) {
  143. callback(new Error('输入长度过长,20个字符以内'))
  144. } else {
  145. this.vipNameChecked = true
  146. }
  147. }
  148. callback()
  149. }
  150. }
  151. }
  152. var validatePassword = (rule, value, callback) => {
  153. if (this.enterprise1.password !== '') {
  154. if (value.length <= 20 && value.length >= 8) {
  155. var reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
  156. var reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
  157. if (reg1.test(value)) {
  158. // callback(new Error('密码强度强'))
  159. this.showMsgTip3 = true
  160. this.showMsgTip2 = false
  161. this.showMsgTip1 = false
  162. this.showMsgTip4 = false
  163. this.passwordChecked = true
  164. } else if (reg2.test(value)) {
  165. // callback(new Error('密码强度中'))
  166. this.showMsgTip2 = true
  167. this.showMsgTip3 = false
  168. this.showMsgTip1 = false
  169. this.showMsgTip4 = false
  170. this.passwordChecked = true
  171. } else {
  172. this.showMsgTip1 = true
  173. this.showMsgTip3 = false
  174. this.showMsgTip2 = false
  175. this.showMsgTip4 = false
  176. this.passwordChecked = false
  177. }
  178. } else {
  179. this.showMsgTip3 = false
  180. this.showMsgTip2 = false
  181. this.showMsgTip1 = false
  182. this.showMsgTip4 = true
  183. this.passwordChecked = false
  184. }
  185. }
  186. callback()
  187. }
  188. var validatePasswordTip = (rule, value, callback) => {
  189. if (this.isHasRegister) {
  190. if (value === '') {
  191. callback(new Error('请输入密码'))
  192. this.passwordChecked = false
  193. this.phoneIsRegisterTip = false
  194. } else {
  195. this.passwordChecked = true
  196. }
  197. } else {
  198. if (value === '') {
  199. callback(new Error('请输入密码'))
  200. this.passwordChecked = false
  201. } else {
  202. if (this.enterprise1.password !== '') {
  203. if (value.length <= 20 && value.length >= 8) {
  204. var reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
  205. var reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
  206. if (reg1.test(value)) {
  207. this.passwordChecked = true
  208. } else if (reg2.test(value)) {
  209. this.passwordChecked = true
  210. } else {
  211. callback(new Error('密码须为8-20字符的英文、数字混合'))
  212. this.passwordChecked = false
  213. }
  214. } else {
  215. callback(new Error('密码须为8-20字符的英文、数字混合'))
  216. this.passwordChecked = false
  217. }
  218. }
  219. callback()
  220. }
  221. }
  222. }
  223. var validateConfirm = (rule, value, callback) => {
  224. if (this.isHasRegister) {
  225. this.passwordConfirmChecked = true
  226. } else {
  227. if (value === '') {
  228. callback(new Error('请再次输入密码'))
  229. this.passwordConfirmChecked = false
  230. } else if (value !== this.enterprise1.password) {
  231. callback(new Error('两次输入密码不一致!'))
  232. } else {
  233. this.passwordConfirmChecked = true
  234. callback()
  235. }
  236. }
  237. }
  238. var validateEmail = (rule, value, callback) => {
  239. if (this.isHasEmail) {
  240. this.emailChecked = true
  241. } else {
  242. if (!value) {
  243. callback(new Error('请填写正确的联系邮箱'))
  244. this.emailChecked = false
  245. } else {
  246. if (this.enterprise1.email) {
  247. var reg = /^([\w-])+(\.\w+)*@([\w-])+((\.\w{2,3}){1,3})$/
  248. if (!reg.test(value)) {
  249. callback(new Error('请输入正确的邮箱地址格式'))
  250. this.emailChecked = false
  251. } else {
  252. this.emailChecked = true
  253. }
  254. }
  255. callback()
  256. }
  257. }
  258. }
  259. return {
  260. // 企业注册第二步
  261. enterprise1: {
  262. spaceName: '',
  263. businessCode: '',
  264. vipName: '',
  265. password: '',
  266. confirm: '',
  267. email: ''
  268. },
  269. checked: true,
  270. codeChecked: false,
  271. enterprise_time: 0,
  272. showMsgTip1: false,
  273. showMsgTip2: false,
  274. showMsgTip3: false,
  275. showMsgTip4: false,
  276. spaceNameChecked: false,
  277. businessCodeChecked: false,
  278. vipNameChecked: false,
  279. passwordChecked: false,
  280. passwordConfirmChecked: false,
  281. emailChecked: false,
  282. isHasRegister: false,
  283. isHasEmail: false,
  284. phoneIsRegisterTip: true,
  285. isSpaceNameExist: false,
  286. isBusinessCodeExist: false,
  287. // 企业注册第二步
  288. rules1: {
  289. spaceName: [
  290. {validator: validateSpaceName, trigger: 'blur'}
  291. ],
  292. businessCode: [
  293. {validator: validateBusinessCode, trigger: 'blur'}
  294. ],
  295. vipName: [
  296. {validator: validateVipName, trigger: 'blur'}
  297. ],
  298. password: [
  299. {validator: validatePassword, trigger: 'change'},
  300. {validator: validatePasswordTip, trigger: 'blur'}
  301. ],
  302. confirm: [
  303. {validator: validateConfirm, trigger: 'blur'}
  304. ],
  305. email: [
  306. {validator: validateEmail, trigger: 'blur'}
  307. ]
  308. }
  309. }
  310. },
  311. methods: {
  312. // 我同意是否被选中
  313. checkboxIsChecked () {
  314. this.checked = !this.checked
  315. },
  316. // 确认注册
  317. sureRegister () {
  318. if (!this.isHasRegister) {
  319. if (this.spaceNameChecked && this.businessCodeChecked && this.vipNameChecked && this.passwordChecked && this.passwordConfirmChecked && this.emailChecked && this.checked) {
  320. var url = window.location.search
  321. var request = {}
  322. if (url.indexOf('?' !== -1)) {
  323. var str = url.substr(1)
  324. var strs = str.split('&')
  325. for (var i = 0; i < strs.length; i++) {
  326. request[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1])
  327. }
  328. }
  329. var appId = request['appId'] || ''
  330. let param = new FormData()
  331. param.append('spaceName', this.enterprise1.spaceName)
  332. param.append('businessCode', this.enterprise1.businessCode)
  333. param.append('vipName', this.enterprise1.vipName || '')
  334. param.append('password', this.enterprise1.password)
  335. param.append('email', this.enterprise1.email || '')
  336. param.append('appId', appId)
  337. let config = {
  338. headers: {'Content-Type': 'multipart/form-data'}
  339. }
  340. this.$http.post('/sso/userspace/register', param, config)
  341. .then(response => {
  342. if (response.data.success) {
  343. } else {
  344. return Promise.reject(response.data)
  345. }
  346. }).catch(err => {
  347. this.$message.error(err.errMsg)
  348. })
  349. }
  350. } else {
  351. if (this.isHasEmail) {
  352. if (this.spaceNameChecked && this.businessCodeChecked && this.passwordChecked) {
  353. let param = new FormData()
  354. param.append('spaceName', this.enterprise1.spaceName)
  355. param.append('businessCode', this.enterprise1.businessCode)
  356. param.append('vipName', this.enterprise1.vipName || '')
  357. param.append('password', this.enterprise1.password)
  358. param.append('email', this.enterprise1.email || '')
  359. param.append('appId', appId)
  360. let config = {
  361. headers: {'Content-Type': 'multipart/form-data'}
  362. }
  363. this.$http.post('/sso/userspace/register', param, config)
  364. .then(response => {
  365. if (response.data.success) {
  366. } else {
  367. return Promise.reject(response.data)
  368. }
  369. }).catch(err => {
  370. this.$message.error(err.errMsg)
  371. })
  372. }
  373. } else {
  374. if (this.spaceNameChecked && this.businessCodeChecked && this.passwordChecked && this.emailChecked) {
  375. let param = new FormData()
  376. param.append('spaceName', this.enterprise1.spaceName)
  377. param.append('businessCode', this.enterprise1.businessCode)
  378. param.append('vipName', this.enterprise1.vipName || '')
  379. param.append('password', this.enterprise1.password)
  380. param.append('email', this.enterprise1.email || '')
  381. param.append('appId', appId)
  382. let config = {
  383. headers: {'Content-Type': 'multipart/form-data'}
  384. }
  385. this.$http.post('/sso/userspace/register', param, config)
  386. .then(response => {
  387. if (response.data.success) {
  388. window.location.href = '/overRegister/overEnterprise'
  389. } else {
  390. return Promise.reject(response.data)
  391. }
  392. }).catch(err => {
  393. this.$message.error(err.errMsg)
  394. })
  395. }
  396. }
  397. }
  398. }
  399. }
  400. }
  401. </script>
  402. <style lang="scss" scoped>
  403. .register {
  404. margin: 0 auto;
  405. width: 100%;
  406. background: #fff;
  407. .container{
  408. padding-top: 50px;
  409. margin: 0 auto;
  410. width: 980px;
  411. text-align: center;
  412. .content{
  413. padding: 0 50px;
  414. margin: 50px auto 0;
  415. width: 100%;
  416. text-align: center;
  417. background: #fff;
  418. .content-top{
  419. height: 80px;
  420. line-height: 80px;
  421. border-bottom: 1px solid #dcdcdc;
  422. h3{
  423. font-family: 'SimHei';
  424. font-size: 24px;
  425. color: #000;
  426. }
  427. }
  428. form {
  429. padding-bottom: 44px;
  430. margin-top: 35px;
  431. span.sure{
  432. position: absolute;
  433. top: 0;
  434. right: -240px;
  435. font-size: 13px;
  436. color: #8c8c8c;
  437. }
  438. span.codeError-tip{
  439. position: absolute;
  440. top: 3px;
  441. right: -105px;
  442. color: #ff4949;
  443. font-size: 12px;
  444. }
  445. input{
  446. padding: 0 0 0 18px;
  447. width: 360px;
  448. height: 44px;
  449. line-height: 44px;
  450. font-size: 14px;
  451. color: #000;
  452. border-radius: 0;
  453. }
  454. i{
  455. position: absolute;
  456. top: 10px;
  457. right: 18px;
  458. font-size: 24px;
  459. color: #a0a0a0;
  460. cursor: pointer;
  461. }
  462. .pwd {
  463. margin: 6px 0 -15px 0;
  464. text-align: left;
  465. font-size: 13px;
  466. em{
  467. display: inline-block;
  468. margin: 0 8px 2px 0;
  469. width: 24px;
  470. height: 6px;
  471. &:first-child{
  472. margin-left: 10px;
  473. }
  474. }
  475. span{
  476. margin-left: 10px;
  477. font-size: 13px;
  478. }
  479. }
  480. .pwd.sm{
  481. color: #8c8c8c;
  482. em {
  483. background: #bfbfbf;
  484. &:first-child{
  485. background: #ff4e00;
  486. }
  487. }
  488. span{
  489. color: #ff4e00;
  490. }
  491. }
  492. .pwd.md{
  493. color: #8c8c8c;
  494. em {
  495. background: #22ac38;
  496. &:nth-child(3){
  497. background: #bfbfbf;
  498. }
  499. }
  500. span{
  501. color: #22ac38;
  502. }
  503. }
  504. .pwd.lar{
  505. color: #8c8c8c;
  506. em {
  507. background: #00a0e9;
  508. }
  509. span{
  510. color: #00a0e9;
  511. }
  512. }
  513. .pwd.low{
  514. color: #8c8c8c;
  515. em {
  516. background: #bfbfbf;
  517. }
  518. span{
  519. color: #00a0e9;
  520. }
  521. }
  522. span.tip{
  523. position: absolute;
  524. top: 0;
  525. right: -165px;
  526. font-size: 13px;
  527. color: #8c8c8c;
  528. }
  529. span.tip.exist{
  530. right: -239px;
  531. a{
  532. color: #2d8cf0;
  533. }
  534. }
  535. input.msg{
  536. float: left;
  537. width: 210px;
  538. }
  539. span.msg{
  540. float: right;
  541. width: 130px;
  542. height: 44px;
  543. line-height: 44px;
  544. font-size: 14px;
  545. color: #5a5a5a;
  546. background: #f4f4f4;
  547. border: 1px solid #dcdcdc;
  548. cursor: pointer;
  549. }
  550. span.msg.send{
  551. background: #d2d2d2;
  552. color: #fff;
  553. }
  554. input[type='checkbox']{
  555. margin: 0 14px 0 55px;
  556. float: left;
  557. width: 16px;
  558. height: 16px;
  559. }
  560. span.agree{
  561. float: left;
  562. margin: 0 0 0 10px;
  563. font-size: 14px;
  564. color: #8b8b8b;
  565. a{
  566. color: #0076ad;
  567. }
  568. }
  569. .form-group.agree{
  570. margin: 20px auto 0 !important;
  571. }
  572. .btn {
  573. margin: 34px 0 16px 0;
  574. width: 360px;
  575. height: 44px;
  576. line-height: 44px;
  577. font-size: 16px;
  578. color: #fff;
  579. background: #0076AD;
  580. border-radius: 3px;
  581. }
  582. }
  583. }
  584. .login{
  585. margin-top: 20px;
  586. font-size: 14px;
  587. color: #8c8c8c;
  588. a{
  589. font-size: 14px;
  590. color: #0076ad;
  591. }
  592. }
  593. }
  594. }
  595. </style>