PersonalRegistration.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  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 class="content-tab">
  10. <span :class="{speed: speediness === false}" @click="clickWay(false)">用户名注册</span>
  11. <span :class="{speed: speediness === true}" @click="clickWay(true)">手机号注册</span>
  12. </div>
  13. <div>
  14. <el-form :model="item" :rules="rules2" ref="item" label-width="100px" class="demo-ruleForm">
  15. <el-form-item prop="vipName" v-if="!speediness">
  16. <el-input type="text" v-model="item.vipName" auto-complete="off" placeholder="会员名"></el-input>
  17. </el-form-item>
  18. <el-form-item prop="password" v-if="!speediness">
  19. <el-input type="password" v-model="item.password" auto-complete="new-password" placeholder="登录密码"></el-input>
  20. <div class="pwd sm" v-show="showMsgTip1">密码强度 <em></em><em></em><em></em><span>弱</span></div>
  21. <div class="pwd md" v-show="showMsgTip2">密码强度 <em></em><em></em><em></em><span>中</span></div>
  22. <div class="pwd lar" v-show="showMsgTip3">密码强度 <em></em><em></em><em></em><span>强</span></div>
  23. <div class="pwd low" v-show="showMsgTip4">密码强度 <em></em><em></em><em></em></div>
  24. </el-form-item>
  25. <el-form-item prop="confirm" v-if="!speediness">
  26. <el-input type="password"
  27. v-model="item.confirm"
  28. v-bind:class="{active: showPasswordError}"
  29. auto-complete="new-password"
  30. placeholder="密码确认"></el-input>
  31. <span class="tip passwordError" v-show="showPasswordError">两次输入密码不一致</span>
  32. </el-form-item>
  33. <el-form-item prop="mobile">
  34. <el-input v-model="item.mobile"
  35. v-bind:class="{active: mobileRegister}"
  36. placeholder="手机号码"></el-input>
  37. <span class="tip" v-show="showMsgTip">单个手机号只能注册一个用户</span>
  38. <span class="tip tip-mobile" v-show="mobileRegister">该手机号已被注册</span>
  39. </el-form-item>
  40. <el-form-item prop="captcha" class="captcha">
  41. <el-input type="text"
  42. v-model="ImgCode"
  43. auto-complete="off"
  44. class="code-input"
  45. @keyup.enter.native="getCheckCode"></el-input>
  46. <img id="captchaImage2" class="code-img" src="/sso/login/checkCode"/>
  47. <a class="code-click" @click="getCode">看不清换一张</a>
  48. </el-form-item>
  49. <el-form-item prop="code">
  50. <el-input type="text" v-model="item.code"
  51. v-bind:class="{ active: codeErrorChecked }" auto-complete="off" class="msg" placeholder="短信验证码"></el-input>
  52. <el-button type="primary" class="code"
  53. v-show="sendPersonalCode"
  54. @click="getCheckCode"
  55. :disabled="this.checkMobile">获取验证码</el-button>
  56. <el-button type="primary" v-show="!sendPersonalCode" class="code code-send">已发送({{personal_time}}s)</el-button>
  57. <span v-show="codeErrorChecked" class="codeError-tip">{{codeErrorMsg}}</span>
  58. </el-form-item>
  59. <el-form-item>
  60. <el-checkbox name="type" v-model="checked" @click="checkboxChecked"></el-checkbox>
  61. <span class="agree" v-if="!agreementUrl || (agreementUrl && (JSON.parse(agreementUrl.terms).isUrl))">我已阅读并同意 <a href="/common/agreement">《优软云服务条款》</a></span>
  62. <span class="agree" v-else>我已阅读并同意<a :href="`/common/cityAgreement/?appId=${this.$route.query.appId}`">《{{JSON.parse(agreementUrl.terms).name || ''}}》</a></span>
  63. </el-form-item>
  64. <el-form-item>
  65. <a class="btn finish" @click="allSubmit">确认注册</a>
  66. </el-form-item>
  67. </el-form>
  68. </div>
  69. </div>
  70. <div class="login">已有账号?<a :href="returnLogin">立即登录</a></div>
  71. <loading v-show="isShowLoading"/>
  72. </div>
  73. <!--尾部-->
  74. <div v-html="loginStyle.footUrl" class="footer"></div>
  75. </div>
  76. </template>
  77. <script>
  78. import md5 from 'js-md5'
  79. import Loading from '~components/common/loading/Loading.vue'
  80. export default {
  81. name: 'PersonalRegistration',
  82. components: {
  83. Loading
  84. },
  85. data () {
  86. var validateName = (rule, value, callback) => {
  87. if (value === '') {
  88. callback(new Error('会员名不能为空'))
  89. this.vipNameChecked = false
  90. } else {
  91. if (this.item.vipName !== '') {
  92. if (value.length < 2 || value.length > 20) {
  93. callback(new Error('请填写合适的会员名称,2~20个字符'))
  94. this.vipNameChecked = false
  95. } else {
  96. this.vipNameChecked = true
  97. }
  98. }
  99. }
  100. callback()
  101. }
  102. var validatePass = (rule, value, callback) => {
  103. if (this.item.password !== '') {
  104. if (value.length <= 20 && value.length >= 8) {
  105. var reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
  106. var reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
  107. if (reg1.test(value)) {
  108. // callback(new Error('密码强度强'))
  109. this.showMsgTip3 = true
  110. this.showMsgTip2 = false
  111. this.showMsgTip1 = false
  112. this.showMsgTip4 = false
  113. this.passwordChecked = true
  114. } else if (reg2.test(value)) {
  115. // callback(new Error('密码强度中'))
  116. this.showMsgTip2 = true
  117. this.showMsgTip3 = false
  118. this.showMsgTip1 = false
  119. this.showMsgTip4 = false
  120. this.passwordChecked = true
  121. } else {
  122. this.showMsgTip1 = true
  123. this.showMsgTip3 = false
  124. this.showMsgTip2 = false
  125. this.showMsgTip4 = false
  126. this.passwordChecked = false
  127. }
  128. } else {
  129. this.showMsgTip3 = false
  130. this.showMsgTip2 = false
  131. this.showMsgTip1 = false
  132. this.showMsgTip4 = true
  133. this.passwordChecked = false
  134. }
  135. }
  136. callback()
  137. }
  138. var validatePassTip = (rule, value, callback) => {
  139. if (value === '') {
  140. callback(new Error('请输入密码'))
  141. this.passwordChecked = false
  142. } else {
  143. if (this.item.password !== '') {
  144. if (value.length <= 20 && value.length >= 8) {
  145. var reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
  146. var reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
  147. if (reg1.test(value)) {
  148. this.passwordChecked = true
  149. } else if (reg2.test(value)) {
  150. this.passwordChecked = true
  151. } else {
  152. callback(new Error('密码须为8-20字符的英文、数字混合'))
  153. this.passwordChecked = false
  154. }
  155. } else {
  156. callback(new Error('密码须为8-20字符的英文、数字混合'))
  157. this.passwordChecked = false
  158. }
  159. if (this.item.confirm !== '') {
  160. if (value !== this.item.confirm) {
  161. this.showPasswordError = true
  162. // callback(new Error('两次输入密码不一致!'))
  163. this.confirmChecked = false
  164. } else {
  165. this.confirmChecked = true
  166. this.showPasswordError = false
  167. callback()
  168. }
  169. }
  170. }
  171. callback()
  172. }
  173. }
  174. var validatePass2 = (rule, value, callback) => {
  175. if (value === '') {
  176. callback(new Error('请再次输入密码'))
  177. this.confirmChecked = false
  178. this.showPasswordError = false
  179. } else if (value !== this.item.password) {
  180. // callback(new Error('两次输入密码不一致!'))
  181. this.showPasswordError = true
  182. this.confirmChecked = false
  183. } else {
  184. this.confirmChecked = true
  185. this.showPasswordError = false
  186. callback()
  187. }
  188. }
  189. var validateMobile = (rule, value, callback) => {
  190. if (value === '') {
  191. callback(new Error('请填写正确的手机号'))
  192. this.showMsgTip = false
  193. this.checkMobile = true
  194. this.mobileRegister = false
  195. this.mobileChecked = false
  196. } else {
  197. if (this.item.mobile !== '') {
  198. var reg = /^1([0-9]{10})$/
  199. if (!reg.test(value)) {
  200. callback(new Error('请填写正确的手机号'))
  201. this.showMsgTip = false
  202. this.checkMobile = true
  203. this.mobileRegister = false
  204. this.mobileChecked = false
  205. } else {
  206. this.$http.get(`/api/user/checkMobile`, {params: {mobile: this.item.mobile, mobileArea: ''}})
  207. .then(response => {
  208. if (response.data.hasRegister) {
  209. this.mobileRegister = true
  210. this.showMsgTip = false
  211. this.checkMobile = true
  212. this.mobileChecked = false
  213. } else {
  214. this.showMsgTip = false
  215. this.checkMobile = false
  216. this.mobileRegister = false
  217. this.mobileChecked = true
  218. }
  219. })
  220. }
  221. }
  222. callback()
  223. }
  224. }
  225. var validateCode = (rule, value, callback) => {
  226. if (value === '') {
  227. callback(new Error('请填写正确的验证码'))
  228. this.codeErrorChecked = false
  229. this.codeChecked = false
  230. } else {
  231. if (this.item.mobile === '') {
  232. callback(new Error('请先填写正确的手机号'))
  233. } else {
  234. if (this.token) {
  235. if (this.item.code.length === 6) {
  236. let param = new FormData()
  237. param.append('mobile', this.item.mobile)
  238. param.append('code', this.item.code)
  239. param.append('token', this.token)
  240. let config = {
  241. headers: {'Content-Type': 'multipart/form-data'}
  242. }
  243. this.$http.post(`/sso/personal/register/checkCode`, param, config)
  244. .then(response => {
  245. if (response.data.success) {
  246. this.codeChecked = true
  247. this.codeErrorChecked = false
  248. } else {
  249. this.codeErrorChecked = true
  250. this.codeChecked = false
  251. // callback(new Error('验证码输入错误'))
  252. return Promise.reject(response.data)
  253. }
  254. }).catch(err => {
  255. this.codeErrorMsg = err.errMsg
  256. // this.$message.error(err.errMsg)
  257. })
  258. } else {
  259. callback(new Error('请输入正确的验证码'))
  260. this.codeChecked = false
  261. this.codeErrorChecked = false
  262. }
  263. } else {
  264. callback(new Error('请先获取验证码'))
  265. this.codeChecked = false
  266. this.codeErrorChecked = false
  267. }
  268. }
  269. callback()
  270. }
  271. }
  272. var validateCodeIsEmpty = (rule, value, callback) => {
  273. if (value === '') {
  274. callback(new Error('请填写正确的验证码'))
  275. this.codeErrorChecked = false
  276. this.codeChecked = false
  277. } else {
  278. if (this.item.mobile === '') {
  279. callback(new Error('请先填写正确的手机号'))
  280. } else {
  281. if (this.token) {
  282. if (this.item.code.length === 6) {
  283. let param = new FormData()
  284. param.append('mobile', this.item.mobile)
  285. param.append('code', this.item.code)
  286. param.append('token', this.token)
  287. let config = {
  288. headers: {'Content-Type': 'multipart/form-data'}
  289. }
  290. this.$http.post(`/sso/personal/register/checkCode`, param, config)
  291. .then(response => {
  292. if (response.data.success) {
  293. this.codeChecked = true
  294. this.codeErrorChecked = false
  295. } else {
  296. this.codeErrorChecked = true
  297. this.codeChecked = false
  298. return Promise.reject(response.data)
  299. }
  300. }).catch(err => {
  301. this.codeErrorMsg = err.errMsg
  302. })
  303. } else {
  304. callback(new Error('请输入正确的验证码'))
  305. this.codeChecked = false
  306. this.codeErrorChecked = false
  307. }
  308. } else {
  309. callback(new Error('请先获取验证码'))
  310. this.codeChecked = false
  311. this.codeErrorChecked = false
  312. }
  313. }
  314. callback()
  315. }
  316. }
  317. return {
  318. speediness: false,
  319. ImgCode: '',
  320. item: {
  321. vipName: '',
  322. password: '',
  323. confirm: '',
  324. mobile: '',
  325. code: ''
  326. },
  327. isShowLoading: false,
  328. showPasswordError: false,
  329. vipNameChecked: false,
  330. passwordChecked: false,
  331. confirmChecked: false,
  332. mobileChecked: false,
  333. codeChecked: false,
  334. codeErrorChecked: false,
  335. showMsgTip: true,
  336. showMsgTip1: false,
  337. showMsgTip2: false,
  338. showMsgTip3: false,
  339. showMsgTip4: false,
  340. checkMobile: true,
  341. checked: true,
  342. token: '',
  343. mobileRegister: false,
  344. sendPersonalCode: true,
  345. codeErrorMsg: '',
  346. personal_time: 0,
  347. queryLink: '',
  348. appId: '',
  349. returnLogin: '',
  350. rules2: {
  351. vipName: [
  352. { validator: validateName, trigger: 'blur' }
  353. ],
  354. password: [
  355. { validator: validatePassTip, trigger: 'blur' },
  356. { validator: validatePass, trigger: 'change' }
  357. ],
  358. confirm: [
  359. { required: true, validator: validatePass2, trigger: 'blur' }
  360. ],
  361. mobile: [
  362. { validator: validateMobile, trigger: 'blur' }
  363. ],
  364. code: [
  365. { validator: validateCode, trigger: 'change' },
  366. { validator: validateCodeIsEmpty, trigger: 'blur' }
  367. ]
  368. }
  369. }
  370. },
  371. mounted () {
  372. // 获取链接
  373. this.$nextTick(() => {
  374. this.getUrl()
  375. this.getCode()
  376. })
  377. },
  378. computed: {
  379. loginStyle () {
  380. return this.$store.state.login.loginStyle.data.content
  381. },
  382. agreementUrl () {
  383. return this.$store.state.login.agreementUrl.data.content
  384. }
  385. },
  386. methods: {
  387. // 切换注册方式
  388. clickWay (type) {
  389. if (this.speediness !== type) {
  390. this.speediness = type
  391. this.ImgCode = ''
  392. this.$refs.item.resetFields()
  393. }
  394. },
  395. // 获取链接
  396. getUrl () {
  397. var url = window.location.search
  398. var request = {}
  399. var origin = window.location.origin
  400. this.returnLogin = origin + url
  401. if (url.indexOf('?' !== -1)) {
  402. var str = url.substr(1)
  403. var strs = str.split('&')
  404. this.queryLink = str
  405. for (var i = 0; i < strs.length; i++) {
  406. request[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1])
  407. }
  408. }
  409. this.appId = request['appId'] || ''
  410. },
  411. // 注册
  412. goRegister () {
  413. window.location.href = `/register/enterpriseRegistration${this.queryLink ? '?' + this.queryLink : ''}`
  414. },
  415. // 我同意是否被选中
  416. checkboxChecked () {
  417. this.checked = !this.checked
  418. },
  419. // 用户名表单提交
  420. submit () {
  421. if (this.vipNameChecked && this.passwordChecked && this.confirmChecked && this.mobileChecked && this.codeChecked && this.checked) {
  422. if (this.item.password !== this.item.confirm) {
  423. this.$message.error('请确认两次填写密码是否一致')
  424. } else {
  425. this.isShowLoading = true
  426. let param = new FormData()
  427. param.append('vipName', this.item.vipName)
  428. param.append('password', this.item.password)
  429. param.append('mobile', this.item.mobile)
  430. // param.append('mobileArea', '')
  431. param.append('appId', this.appId)
  432. param.append('code', this.item.code)
  433. param.append('token', this.token)
  434. param.append('t', this.$route.query.tk ? this.$route.query.tk : '')
  435. param.append('returnUrl', this.$route.query.returnURL ? this.$route.query.returnURL : '')
  436. let config = {
  437. headers: {'Content-Type': 'multipart/form-data'}
  438. }
  439. this.$http.post('/sso/personal/register', param, config)
  440. .then(response => {
  441. this.isShowLoading = false
  442. if (response.data.success) {
  443. if (response.data.content.type) {
  444. if (response.data.content.type === 'mall') {
  445. let param = response.data.content.data
  446. let a = ''
  447. for (let n in param) {
  448. a += (n + '=' + encodeURIComponent(param[n]) + '&')
  449. }
  450. let params = a.substr(0, a.length - 1)
  451. this.isShowLoading = true
  452. if (response.data.content.currentUrl) {
  453. this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
  454. name: 'successCallback',
  455. timeout: 3000
  456. }, (err, data) => {
  457. if (err) {
  458. this.$message.error('注册成功,请点击下方“立即登录”完成登录')
  459. this.isShowLoading = false
  460. throw err
  461. } else {
  462. this.loginOther(response, params)
  463. }
  464. })
  465. } else {
  466. this.loginOther(response, params, 3000)
  467. }
  468. } else if (response.data.content.type === 'city') {
  469. let param = response.data.content.data
  470. let a = ''
  471. for (let n in param) {
  472. a += (n + '=' + encodeURIComponent(param[n]) + '&')
  473. }
  474. let params = a.substr(0, a.length - 1)
  475. this.isShowLoading = true
  476. if (response.data.content.currentUrl) {
  477. this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
  478. name: 'successCallback',
  479. timeout: 3000
  480. }, (err, data) => {
  481. if (err) {
  482. this.$message.error('注册成功,请点击下方“立即登录”完成登录')
  483. this.isShowLoading = false
  484. throw err
  485. } else {
  486. this.loginCityOther(response, params)
  487. }
  488. })
  489. } else {
  490. this.loginCityOther(response, params, 3000)
  491. }
  492. }
  493. } else {
  494. let userUU = response.data.content.userUU
  495. console.log(userUU)
  496. window.location.href = `/overRegister/${userUU}`
  497. }
  498. } else {
  499. return Promise.reject(response.data)
  500. }
  501. }).catch(err => {
  502. this.$message.error(err.errMsg)
  503. this.isShowLoading = false
  504. this.personal_time = 0
  505. })
  506. }
  507. } else {
  508. if (!this.item.vipName) {
  509. this.$message.error('会员名不能为空')
  510. } else if (!this.vipNameChecked) {
  511. this.$message.error('会员名输入有误,请按提示重新输入')
  512. } else if (!this.item.password) {
  513. this.$message.error('密码不能为空')
  514. } else if (!this.passwordChecked) {
  515. this.$message.error('密码输入有误,请按提示重新输入')
  516. } else if (!this.item.confirm) {
  517. this.$message.error('请再次输入密码')
  518. } else if (!this.confirmChecked) {
  519. this.$message.error('请确认两次填写密码是否一致')
  520. } else if (!this.item.mobile) {
  521. this.$message.error('手机号不能为空')
  522. } else if (!this.mobileChecked) {
  523. this.$message.error('手机号输入有误,请按提示重新输入')
  524. } else if (!this.token) {
  525. this.$message.error('请先获取验证码')
  526. } else if (!this.item.code) {
  527. this.$message.error('验证码不能为空')
  528. } else if (!this.codeChecked) {
  529. this.$message.error('验证码输入有误,请按提示重新输入')
  530. } else if (!this.checked) {
  531. this.$message.error('您对阅读条款未做勾选')
  532. }
  533. }
  534. },
  535. // 快速登录
  536. waySubmit () {
  537. if (this.mobileChecked && this.codeChecked && this.checked) {
  538. this.isShowLoading = true
  539. let param = new FormData()
  540. param.append('mobile', this.item.mobile)
  541. param.append('appId', this.appId)
  542. param.append('code', this.item.code)
  543. param.append('token', this.token)
  544. param.append('t', this.$route.query.tk ? this.$route.query.tk : '')
  545. if (this.$route.query.baseUrl) {
  546. param.append('baseUrl', this.$route.query.baseUrl)
  547. }
  548. if (this.$route.query.returnURL) {
  549. param.append('returnUrl', this.$route.query.returnURL)
  550. }
  551. let config = {
  552. headers: {'Content-Type': 'multipart/form-data'}
  553. }
  554. this.$http.post('/sso/personal/register/sms', param, config)
  555. .then(response => {
  556. this.isShowLoading = false
  557. if (response.data.success) {
  558. if (response.data.content.type) {
  559. if (response.data.content.type === 'mall') {
  560. let param = response.data.content.data
  561. let a = ''
  562. for (let n in param) {
  563. a += (n + '=' + encodeURIComponent(param[n]) + '&')
  564. }
  565. let params = a.substr(0, a.length - 1)
  566. this.isShowLoading = true
  567. if (response.data.content.currentUrl) {
  568. this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
  569. name: 'successCallback',
  570. timeout: 3000
  571. }, (err, data) => {
  572. if (err) {
  573. this.$message.error('注册成功,请点击下方“立即登录”完成登录')
  574. this.isShowLoading = false
  575. throw err
  576. } else {
  577. this.loginOther(response, params)
  578. }
  579. })
  580. } else {
  581. this.loginOther(response, params, 3000)
  582. }
  583. } else if (response.data.content.type === 'city') {
  584. let param = response.data.content.data
  585. let a = ''
  586. for (let n in param) {
  587. a += (n + '=' + encodeURIComponent(param[n]) + '&')
  588. }
  589. let params = a.substr(0, a.length - 1)
  590. this.isShowLoading = true
  591. if (response.data.content.currentUrl) {
  592. this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
  593. name: 'successCallback',
  594. timeout: 3000
  595. }, (err, data) => {
  596. if (err) {
  597. this.$message.error('注册成功,请点击下方“立即登录”完成登录')
  598. this.isShowLoading = false
  599. throw err
  600. } else {
  601. this.loginCityOther(response, params)
  602. }
  603. })
  604. } else {
  605. this.loginCityOther(response, params, 3000)
  606. }
  607. }
  608. } else {
  609. let userUU = response.data.content.userUU
  610. console.log(userUU)
  611. window.location.href = `/overRegister/${userUU}`
  612. }
  613. } else {
  614. return Promise.reject(response.data)
  615. }
  616. }).catch(err => {
  617. this.$message.error(err.errMsg)
  618. this.isShowLoading = false
  619. this.personal_time = 0
  620. })
  621. } else {
  622. if (!this.item.mobile) {
  623. this.$message.error('手机号不能为空')
  624. } else if (!this.mobileChecked) {
  625. this.$message.error('手机号输入有误,请按提示重新输入')
  626. } else if (!this.token) {
  627. this.$message.error('请先获取验证码')
  628. } else if (!this.item.code) {
  629. this.$message.error('验证码不能为空')
  630. } else if (!this.codeChecked) {
  631. this.$message.error('验证码输入有误,请按提示重新输入')
  632. } else if (!this.checked) {
  633. this.$message.error('您对阅读条款未做勾选')
  634. }
  635. }
  636. },
  637. // 提交注册流程
  638. allSubmit () {
  639. if (this.speediness) {
  640. this.waySubmit()
  641. } else {
  642. this.submit()
  643. }
  644. },
  645. // 获取验证码
  646. // async getCode () {
  647. // let { data } = await this.$http.get(`/sso/personal/register/checkCode`, {params: {mobile: this.item.mobile}})
  648. // this.token = data.token
  649. // },
  650. // 获取验证码
  651. getCode () {
  652. let imgSrc = document.getElementById('captchaImage2')
  653. imgSrc.setAttribute('src', '/sso/resetPwd/checkCaptcha?timestamp=' + (new Date()).valueOf())
  654. },
  655. getCheckCode () {
  656. let md5Code = md5(`{mobile=${this.item.mobile},code=${this.ImgCode},salt=sso}`)
  657. this.isShowLoading = true
  658. this.$http.get(`/sso/personal/register/checkCode`, {params: {mobile: this.item.mobile, timestamp: new Date().getTime() + '', code: this.ImgCode, sign: md5Code}})
  659. .then(response => {
  660. this.isShowLoading = false
  661. if (response.data) {
  662. this.token = response.data.token
  663. if (response.data.errMsg) {
  664. this.$message({
  665. message: response.data.errMsg,
  666. type: 'error'
  667. })
  668. this.ImgCode = ''
  669. this.getCode()
  670. return
  671. }
  672. if (this.token !== '') {
  673. this.$message({
  674. message: '验证码已经发送到您的手机,请注意查收',
  675. type: 'success'
  676. })
  677. this.sendPersonalCode = false
  678. // this.visible2 = false
  679. this.personal_time = 60
  680. // this.ImgCode = ''
  681. var personalTime = setInterval(() => {
  682. this.personal_time--
  683. if (this.personal_time <= 0) {
  684. this.sendPersonalCode = true
  685. clearInterval(personalTime)
  686. }
  687. }, 1000)
  688. // this.getCode()
  689. }
  690. } else {
  691. return Promise.reject(response.data)
  692. }
  693. }).catch(err => {
  694. this.isShowLoading = false
  695. this.$message.error(err.errMsg)
  696. })
  697. },
  698. getJsonp: function (url, timeout = 500) {
  699. return new Promise((resolve, reject) => {
  700. this.$jsonp(url, {
  701. name: 'successCallback',
  702. timeout: timeout
  703. }, function (err, data) {
  704. if (err) {
  705. reject(err)
  706. throw err
  707. } else {
  708. resolve(data)
  709. }
  710. })
  711. })
  712. },
  713. crossAfter (url) {
  714. try {
  715. window.location.href = url
  716. } catch (err) {
  717. console.log(err)
  718. }
  719. },
  720. loginOther (response, a, timeout) {
  721. const crossAfter = this.crossAfter
  722. let promises = []
  723. for (let i in response.data.content.loginUrls) {
  724. if (response.data.content.currentUrl !== response.data.content.loginUrls[i]) {
  725. promises.push(this.getJsonp(`${response.data.content.loginUrls[i]}?${a}`))
  726. }
  727. }
  728. let returnUrl = decodeURIComponent(this.$route.query.returnURL)
  729. Promise.all(promises).then(() => {
  730. crossAfter(returnUrl || 'http://www.ubtob.com', timeout)
  731. }).catch(() => {
  732. crossAfter(returnUrl || 'http://www.ubtob.com', timeout)
  733. })
  734. },
  735. loginCityOther (response, a, timeout) {
  736. const crossAfter = this.crossAfter
  737. let promises = []
  738. for (let i in response.data.content.loginUrls) {
  739. if (response.data.content.currentUrl !== response.data.content.loginUrls[i]) {
  740. promises.push(this.getJsonp(`${response.data.content.loginUrls[i]}?${a}`))
  741. }
  742. }
  743. Promise.all(promises).then(() => {
  744. crossAfter('/overRegister/cityRegisterOver/' + this.$store.state.option.fullPath || '/overRegister/cityRegisterOver/' + this.$store.state.option.fullPath, timeout)
  745. }).catch(() => {
  746. crossAfter('/overRegister/cityRegisterOver/' + this.$store.state.option.fullPath || '/overRegister/cityRegisterOver/' + this.$store.state.option.fullPath, timeout)
  747. })
  748. }
  749. }
  750. }
  751. </script>
  752. <style lang="scss" scoped>
  753. .register {
  754. margin: 0 auto;
  755. width: 100%;
  756. background: #eee;
  757. .container{
  758. padding-top: 50px;
  759. margin: 0 auto;
  760. width: 980px;
  761. text-align: center;
  762. .content{
  763. padding: 0 50px;
  764. margin: 50px auto 0;
  765. width: 100%;
  766. text-align: center;
  767. background: #fff;
  768. .content-top{
  769. position: relative;
  770. height: 80px;
  771. line-height: 80px;
  772. border-bottom: 1px solid #dcdcdc;
  773. h3{
  774. font-family: 'SimHei';
  775. font-size: 24px;
  776. color: #000;
  777. }
  778. a.go{
  779. position: absolute;
  780. top: 0;
  781. right: 0;
  782. font-size: 14px;
  783. i{
  784. margin-right: 3px;
  785. }
  786. }
  787. }
  788. .content-tab{
  789. width: 360px;
  790. margin: 0 auto;
  791. height: 50px;
  792. margin-top: 15px;
  793. color: #999;
  794. span{
  795. display:inline-block;
  796. width:50%;
  797. vertical-align:top;
  798. font-size:20px;
  799. text-align: center;
  800. line-height:40px;
  801. height:40px;
  802. border-bottom:2px solid #fff;
  803. cursor:pointer;
  804. &.speed{
  805. color:#3375a7;
  806. border-bottom:2px solid #3375a7;
  807. }
  808. }
  809. }
  810. form {
  811. padding-bottom: 44px;
  812. margin-top: 15px;
  813. input{
  814. padding: 0 0 0 18px;
  815. width: 360px;
  816. height: 44px;
  817. line-height: 44px;
  818. font-size: 14px;
  819. color: #000;
  820. border-radius: 0;
  821. }
  822. span.help{
  823. position: absolute;
  824. right: -230px;
  825. top:0;
  826. font-size: 12px;
  827. color: #f00;
  828. }
  829. i.fa{
  830. position: absolute;
  831. top: 10px;
  832. right: 18px;
  833. font-size: 24px;
  834. color: #a0a0a0;
  835. cursor: pointer;
  836. }
  837. .pwd {
  838. margin: 6px 0 -15px 0;
  839. text-align: left;
  840. font-size: 13px;
  841. em{
  842. display: inline-block;
  843. margin: 0 8px 2px 0;
  844. width: 24px;
  845. height: 6px;
  846. &:first-child{
  847. margin-left: 10px;
  848. }
  849. }
  850. span{
  851. margin-left: 10px;
  852. font-size: 13px;
  853. }
  854. }
  855. .pwd.sm{
  856. color: #8c8c8c;
  857. em {
  858. background: #bfbfbf;
  859. &:first-child{
  860. background: #ff4e00;
  861. }
  862. }
  863. span{
  864. color: #ff4e00;
  865. }
  866. }
  867. .pwd.md{
  868. color: #8c8c8c;
  869. em {
  870. background: #22ac38;
  871. &:nth-child(3){
  872. background: #bfbfbf;
  873. }
  874. }
  875. span{
  876. color: #22ac38;
  877. }
  878. }
  879. .pwd.lar{
  880. color: #8c8c8c;
  881. em {
  882. background: #00a0e9;
  883. }
  884. span{
  885. color: #00a0e9;
  886. }
  887. }
  888. .pwd.low{
  889. color: #8c8c8c;
  890. em{
  891. background: #bfbfbf;
  892. }
  893. }
  894. span.tip{
  895. position: absolute;
  896. top: 3px;
  897. right: -190px;
  898. font-size: 13px;
  899. color: #8c8c8c;
  900. }
  901. span.tip.tip-mobile{
  902. top: 3px;
  903. right: -118px;
  904. color: #ff4949;
  905. font-size: 12px;
  906. }
  907. span.codeError-tip{
  908. position: absolute;
  909. top: 3px;
  910. left: 378px;
  911. width: 200px;
  912. text-align: left;
  913. color: #ff4949;
  914. font-size: 12px;
  915. }
  916. span.tip.passwordError{
  917. position: absolute;
  918. top: 3px;
  919. left: 380px;
  920. width: 200px;
  921. text-align: left;
  922. color: #ff4949;
  923. font-size: 12px;
  924. }
  925. input.msg{
  926. float: left;
  927. width: 210px;
  928. }
  929. button.msg{
  930. float: right;
  931. width: 130px;
  932. height: 44px;
  933. font-size: 14px;
  934. color: #5a5a5a;
  935. background: #f4f4f4;
  936. border: 1px solid #dcdcdc;
  937. cursor: pointer;
  938. &:disabled{
  939. cursor: not-allowed ;
  940. opacity: .7;
  941. }
  942. }
  943. span.msg.send{
  944. float: right;
  945. width: 130px;
  946. height: 44px;
  947. line-height: 44px;
  948. font-size: 14px;
  949. background: #d2d2d2;
  950. color: #fff;
  951. border: 1px solid #dcdcdc;
  952. }
  953. input[type='checkbox']{
  954. margin: 0 14px 0 55px;
  955. float: left;
  956. width: 16px;
  957. height: 16px;
  958. }
  959. span.agree{
  960. float: left;
  961. margin: 1px 0 0 10px;
  962. font-size: 14px;
  963. color: #8b8b8b;
  964. a{
  965. color: #0076ad;
  966. }
  967. }
  968. .form-group.agree{
  969. margin: 20px auto 0 !important;
  970. }
  971. .submitBtn {
  972. display: inline-block;
  973. width: 360px;
  974. height: 44px;
  975. line-height: 44px;
  976. font-size: 16px;
  977. color: #fff;
  978. background: #0076AD;
  979. border-radius: 3px;
  980. border: none;
  981. &:disabled{
  982. cursor: not-allowed ;
  983. opacity: .7;
  984. }
  985. }
  986. }
  987. }
  988. .login{
  989. margin-top: 20px;
  990. font-size: 14px;
  991. color: #8c8c8c;
  992. a{
  993. font-size: 14px;
  994. color: #0076ad;
  995. }
  996. }
  997. }
  998. }
  999. .footer{
  1000. padding: 50px 0;
  1001. }
  1002. </style>