PersonalRegistration.vue 21 KB

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