PersonalRegistration.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  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. this.speediness = type
  390. this.ImgCode = ''
  391. this.$refs.item.resetFields()
  392. },
  393. // 获取链接
  394. getUrl () {
  395. var url = window.location.search
  396. var request = {}
  397. var origin = window.location.origin
  398. this.returnLogin = origin + url
  399. if (url.indexOf('?' !== -1)) {
  400. var str = url.substr(1)
  401. var strs = str.split('&')
  402. this.queryLink = str
  403. for (var i = 0; i < strs.length; i++) {
  404. request[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1])
  405. }
  406. }
  407. this.appId = request['appId'] || ''
  408. },
  409. // 注册
  410. goRegister () {
  411. window.location.href = `/register/enterpriseRegistration${this.queryLink ? '?' + this.queryLink : ''}`
  412. },
  413. // 我同意是否被选中
  414. checkboxChecked () {
  415. this.checked = !this.checked
  416. },
  417. // 用户名表单提交
  418. submit () {
  419. if (this.vipNameChecked && this.passwordChecked && this.confirmChecked && this.mobileChecked && this.codeChecked && this.checked) {
  420. if (this.item.password !== this.item.confirm) {
  421. this.$message.error('请确认两次填写密码是否一致')
  422. } else {
  423. this.isShowLoading = true
  424. let param = new FormData()
  425. param.append('vipName', this.item.vipName)
  426. param.append('password', this.item.password)
  427. param.append('mobile', this.item.mobile)
  428. // param.append('mobileArea', '')
  429. param.append('appId', this.appId)
  430. param.append('code', this.item.code)
  431. param.append('token', this.token)
  432. param.append('t', this.$route.query.tk ? this.$route.query.tk : '')
  433. param.append('returnUrl', this.$route.query.returnURL ? this.$route.query.returnURL : '')
  434. let config = {
  435. headers: {'Content-Type': 'multipart/form-data'}
  436. }
  437. this.$http.post('/sso/personal/register', param, config)
  438. .then(response => {
  439. this.isShowLoading = false
  440. if (response.data.success) {
  441. if (response.data.content.type) {
  442. if (response.data.content.type === 'mall') {
  443. let param = response.data.content.data
  444. let a = ''
  445. for (let n in param) {
  446. a += (n + '=' + encodeURIComponent(param[n]) + '&')
  447. }
  448. let params = a.substr(0, a.length - 1)
  449. this.isShowLoading = true
  450. if (response.data.content.currentUrl) {
  451. this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
  452. name: 'successCallback',
  453. timeout: 3000
  454. }, (err, data) => {
  455. if (err) {
  456. this.$message.error('注册成功,请点击下方“立即登录”完成登录')
  457. this.isShowLoading = false
  458. throw err
  459. } else {
  460. this.loginOther(response, params)
  461. }
  462. })
  463. } else {
  464. this.loginOther(response, params, 3000)
  465. }
  466. } else if (response.data.content.type === 'city') {
  467. let param = response.data.content.data
  468. let a = ''
  469. for (let n in param) {
  470. a += (n + '=' + encodeURIComponent(param[n]) + '&')
  471. }
  472. let params = a.substr(0, a.length - 1)
  473. this.isShowLoading = true
  474. if (response.data.content.currentUrl) {
  475. this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
  476. name: 'successCallback',
  477. timeout: 3000
  478. }, (err, data) => {
  479. if (err) {
  480. this.$message.error('注册成功,请点击下方“立即登录”完成登录')
  481. this.isShowLoading = false
  482. throw err
  483. } else {
  484. this.loginCityOther(response, params)
  485. }
  486. })
  487. } else {
  488. this.loginCityOther(response, params, 3000)
  489. }
  490. }
  491. } else {
  492. let userUU = response.data.content.userUU
  493. console.log(userUU)
  494. window.location.href = `/overRegister/${userUU}`
  495. }
  496. } else {
  497. return Promise.reject(response.data)
  498. }
  499. }).catch(err => {
  500. this.$message.error(err.errMsg)
  501. this.isShowLoading = false
  502. this.personal_time = 0
  503. })
  504. }
  505. } else {
  506. if (!this.item.vipName) {
  507. this.$message.error('会员名不能为空')
  508. } else if (!this.vipNameChecked) {
  509. this.$message.error('会员名输入有误,请按提示重新输入')
  510. } else if (!this.item.password) {
  511. this.$message.error('密码不能为空')
  512. } else if (!this.passwordChecked) {
  513. this.$message.error('密码输入有误,请按提示重新输入')
  514. } else if (!this.item.confirm) {
  515. this.$message.error('请再次输入密码')
  516. } else if (!this.confirmChecked) {
  517. this.$message.error('请确认两次填写密码是否一致')
  518. } else if (!this.item.mobile) {
  519. this.$message.error('手机号不能为空')
  520. } else if (!this.mobileChecked) {
  521. this.$message.error('手机号输入有误,请按提示重新输入')
  522. } else if (!this.token) {
  523. this.$message.error('请先获取验证码')
  524. } else if (!this.item.code) {
  525. this.$message.error('验证码不能为空')
  526. } else if (!this.codeChecked) {
  527. this.$message.error('验证码输入有误,请按提示重新输入')
  528. } else if (!this.checked) {
  529. this.$message.error('您对阅读条款未做勾选')
  530. }
  531. }
  532. },
  533. // 快速登录
  534. waySubmit () {
  535. if (this.mobileChecked && this.codeChecked && this.checked) {
  536. this.isShowLoading = true
  537. let param = new FormData()
  538. param.append('mobile', this.item.mobile)
  539. param.append('appId', this.appId)
  540. param.append('code', this.item.code)
  541. param.append('token', this.token)
  542. param.append('t', this.$route.query.tk ? this.$route.query.tk : '')
  543. if (this.$route.query.baseUrl) {
  544. param.append('baseUrl', this.$route.query.baseUrl)
  545. }
  546. if (this.$route.query.returnURL) {
  547. param.append('returnUrl', this.$route.query.returnURL)
  548. }
  549. let config = {
  550. headers: {'Content-Type': 'multipart/form-data'}
  551. }
  552. this.$http.post('/sso/personal/register/sms', param, config)
  553. .then(response => {
  554. this.isShowLoading = false
  555. if (response.data.success) {
  556. if (response.data.content.type) {
  557. if (response.data.content.type === 'mall') {
  558. let param = response.data.content.data
  559. let a = ''
  560. for (let n in param) {
  561. a += (n + '=' + encodeURIComponent(param[n]) + '&')
  562. }
  563. let params = a.substr(0, a.length - 1)
  564. this.isShowLoading = true
  565. if (response.data.content.currentUrl) {
  566. this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
  567. name: 'successCallback',
  568. timeout: 3000
  569. }, (err, data) => {
  570. if (err) {
  571. this.$message.error('注册成功,请点击下方“立即登录”完成登录')
  572. this.isShowLoading = false
  573. throw err
  574. } else {
  575. this.loginOther(response, params)
  576. }
  577. })
  578. } else {
  579. this.loginOther(response, params, 3000)
  580. }
  581. } else if (response.data.content.type === 'city') {
  582. let param = response.data.content.data
  583. let a = ''
  584. for (let n in param) {
  585. a += (n + '=' + encodeURIComponent(param[n]) + '&')
  586. }
  587. let params = a.substr(0, a.length - 1)
  588. this.isShowLoading = true
  589. if (response.data.content.currentUrl) {
  590. this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
  591. name: 'successCallback',
  592. timeout: 3000
  593. }, (err, data) => {
  594. if (err) {
  595. this.$message.error('注册成功,请点击下方“立即登录”完成登录')
  596. this.isShowLoading = false
  597. throw err
  598. } else {
  599. this.loginCityOther(response, params)
  600. }
  601. })
  602. } else {
  603. this.loginCityOther(response, params, 3000)
  604. }
  605. }
  606. } else {
  607. let userUU = response.data.content.userUU
  608. let returnUrl = ''
  609. if (this.$route.query.returnURL) {
  610. returnUrl = decodeURIComponent(this.$route.query.returnURL)
  611. }
  612. window.location.href = returnUrl || `/overRegister/${userUU}`
  613. }
  614. } else {
  615. return Promise.reject(response.data)
  616. }
  617. }).catch(err => {
  618. this.$message.error(err.errMsg)
  619. this.isShowLoading = false
  620. this.personal_time = 0
  621. })
  622. } else {
  623. if (!this.item.mobile) {
  624. this.$message.error('手机号不能为空')
  625. } else if (!this.mobileChecked) {
  626. this.$message.error('手机号输入有误,请按提示重新输入')
  627. } else if (!this.token) {
  628. this.$message.error('请先获取验证码')
  629. } else if (!this.item.code) {
  630. this.$message.error('验证码不能为空')
  631. } else if (!this.codeChecked) {
  632. this.$message.error('验证码输入有误,请按提示重新输入')
  633. } else if (!this.checked) {
  634. this.$message.error('您对阅读条款未做勾选')
  635. }
  636. }
  637. },
  638. // 提交注册流程
  639. allSubmit () {
  640. if (this.speediness) {
  641. this.waySubmit()
  642. } else {
  643. this.submit()
  644. }
  645. },
  646. // 获取验证码
  647. // async getCode () {
  648. // let { data } = await this.$http.get(`/sso/personal/register/checkCode`, {params: {mobile: this.item.mobile}})
  649. // this.token = data.token
  650. // },
  651. // 获取验证码
  652. getCode () {
  653. let imgSrc = document.getElementById('captchaImage2')
  654. imgSrc.setAttribute('src', '/sso/resetPwd/checkCaptcha?timestamp=' + (new Date()).valueOf())
  655. },
  656. getCheckCode () {
  657. let md5Code = md5(`{mobile=${this.item.mobile},code=${this.ImgCode},salt=sso}`)
  658. this.isShowLoading = true
  659. this.$http.get(`/sso/personal/register/checkCode`, {params: {mobile: this.item.mobile, timestamp: new Date().getTime() + '', code: this.ImgCode, sign: md5Code}})
  660. .then(response => {
  661. this.isShowLoading = false
  662. if (response.data) {
  663. this.token = response.data.token
  664. if (response.data.errMsg) {
  665. this.$message({
  666. message: response.data.errMsg,
  667. type: 'error'
  668. })
  669. this.ImgCode = ''
  670. this.getCode()
  671. return
  672. }
  673. if (this.token !== '') {
  674. this.$message({
  675. message: '验证码已经发送到您的手机,请注意查收',
  676. type: 'success'
  677. })
  678. this.sendPersonalCode = false
  679. // this.visible2 = false
  680. this.personal_time = 60
  681. // this.ImgCode = ''
  682. var personalTime = setInterval(() => {
  683. this.personal_time--
  684. if (this.personal_time <= 0) {
  685. this.sendPersonalCode = true
  686. clearInterval(personalTime)
  687. }
  688. }, 1000)
  689. // this.getCode()
  690. }
  691. } else {
  692. return Promise.reject(response.data)
  693. }
  694. }).catch(err => {
  695. this.isShowLoading = false
  696. this.$message.error(err.errMsg)
  697. })
  698. },
  699. getJsonp: function (url, timeout = 500) {
  700. return new Promise((resolve, reject) => {
  701. this.$jsonp(url, {
  702. name: 'successCallback',
  703. timeout: timeout
  704. }, function (err, data) {
  705. if (err) {
  706. reject(err)
  707. throw err
  708. } else {
  709. resolve(data)
  710. }
  711. })
  712. })
  713. },
  714. crossAfter (url) {
  715. try {
  716. window.location.href = url
  717. } catch (err) {
  718. console.log(err)
  719. }
  720. },
  721. loginOther (response, a, timeout) {
  722. const crossAfter = this.crossAfter
  723. let promises = []
  724. for (let i in response.data.content.loginUrls) {
  725. if (response.data.content.currentUrl !== response.data.content.loginUrls[i]) {
  726. promises.push(this.getJsonp(`${response.data.content.loginUrls[i]}?${a}`))
  727. }
  728. }
  729. let returnUrl = decodeURIComponent(this.$route.query.returnURL)
  730. Promise.all(promises).then(() => {
  731. crossAfter(returnUrl || 'http://www.ubtob.com', timeout)
  732. }).catch(() => {
  733. crossAfter(returnUrl || 'http://www.ubtob.com', timeout)
  734. })
  735. },
  736. loginCityOther (response, a, timeout) {
  737. const crossAfter = this.crossAfter
  738. let promises = []
  739. for (let i in response.data.content.loginUrls) {
  740. if (response.data.content.currentUrl !== response.data.content.loginUrls[i]) {
  741. promises.push(this.getJsonp(`${response.data.content.loginUrls[i]}?${a}`))
  742. }
  743. }
  744. Promise.all(promises).then(() => {
  745. crossAfter('/overRegister/cityRegisterOver/' + this.$store.state.option.fullPath || '/overRegister/cityRegisterOver/' + this.$store.state.option.fullPath, timeout)
  746. }).catch(() => {
  747. crossAfter('/overRegister/cityRegisterOver/' + this.$store.state.option.fullPath || '/overRegister/cityRegisterOver/' + this.$store.state.option.fullPath, timeout)
  748. })
  749. }
  750. }
  751. }
  752. </script>
  753. <style lang="scss" scoped>
  754. .register {
  755. margin: 0 auto;
  756. width: 100%;
  757. background: #eee;
  758. .container{
  759. padding-top: 50px;
  760. margin: 0 auto;
  761. width: 980px;
  762. text-align: center;
  763. .content{
  764. padding: 0 50px;
  765. margin: 50px auto 0;
  766. width: 100%;
  767. text-align: center;
  768. background: #fff;
  769. .content-top{
  770. position: relative;
  771. height: 80px;
  772. line-height: 80px;
  773. border-bottom: 1px solid #dcdcdc;
  774. h3{
  775. font-family: 'SimHei';
  776. font-size: 24px;
  777. color: #000;
  778. }
  779. a.go{
  780. position: absolute;
  781. top: 0;
  782. right: 0;
  783. font-size: 14px;
  784. i{
  785. margin-right: 3px;
  786. }
  787. }
  788. }
  789. .content-tab{
  790. width: 360px;
  791. margin: 0 auto;
  792. height: 50px;
  793. margin-top: 15px;
  794. color: #999;
  795. span{
  796. display:inline-block;
  797. width:50%;
  798. vertical-align:top;
  799. font-size:20px;
  800. text-align: center;
  801. line-height:40px;
  802. height:40px;
  803. border-bottom:2px solid #fff;
  804. cursor:pointer;
  805. &.speed{
  806. color:#3375a7;
  807. border-bottom:2px solid #3375a7;
  808. }
  809. }
  810. }
  811. form {
  812. padding-bottom: 44px;
  813. margin-top: 15px;
  814. input{
  815. padding: 0 0 0 18px;
  816. width: 360px;
  817. height: 44px;
  818. line-height: 44px;
  819. font-size: 14px;
  820. color: #000;
  821. border-radius: 0;
  822. }
  823. span.help{
  824. position: absolute;
  825. right: -230px;
  826. top:0;
  827. font-size: 12px;
  828. color: #f00;
  829. }
  830. i.fa{
  831. position: absolute;
  832. top: 10px;
  833. right: 18px;
  834. font-size: 24px;
  835. color: #a0a0a0;
  836. cursor: pointer;
  837. }
  838. .pwd {
  839. margin: 6px 0 -15px 0;
  840. text-align: left;
  841. font-size: 13px;
  842. em{
  843. display: inline-block;
  844. margin: 0 8px 2px 0;
  845. width: 24px;
  846. height: 6px;
  847. &:first-child{
  848. margin-left: 10px;
  849. }
  850. }
  851. span{
  852. margin-left: 10px;
  853. font-size: 13px;
  854. }
  855. }
  856. .pwd.sm{
  857. color: #8c8c8c;
  858. em {
  859. background: #bfbfbf;
  860. &:first-child{
  861. background: #ff4e00;
  862. }
  863. }
  864. span{
  865. color: #ff4e00;
  866. }
  867. }
  868. .pwd.md{
  869. color: #8c8c8c;
  870. em {
  871. background: #22ac38;
  872. &:nth-child(3){
  873. background: #bfbfbf;
  874. }
  875. }
  876. span{
  877. color: #22ac38;
  878. }
  879. }
  880. .pwd.lar{
  881. color: #8c8c8c;
  882. em {
  883. background: #00a0e9;
  884. }
  885. span{
  886. color: #00a0e9;
  887. }
  888. }
  889. .pwd.low{
  890. color: #8c8c8c;
  891. em{
  892. background: #bfbfbf;
  893. }
  894. }
  895. span.tip{
  896. position: absolute;
  897. top: 3px;
  898. right: -190px;
  899. font-size: 13px;
  900. color: #8c8c8c;
  901. }
  902. span.tip.tip-mobile{
  903. top: 3px;
  904. right: -118px;
  905. color: #ff4949;
  906. font-size: 12px;
  907. }
  908. span.codeError-tip{
  909. position: absolute;
  910. top: 3px;
  911. left: 378px;
  912. width: 200px;
  913. text-align: left;
  914. color: #ff4949;
  915. font-size: 12px;
  916. }
  917. span.tip.passwordError{
  918. position: absolute;
  919. top: 3px;
  920. left: 380px;
  921. width: 200px;
  922. text-align: left;
  923. color: #ff4949;
  924. font-size: 12px;
  925. }
  926. input.msg{
  927. float: left;
  928. width: 210px;
  929. }
  930. button.msg{
  931. float: right;
  932. width: 130px;
  933. height: 44px;
  934. font-size: 14px;
  935. color: #5a5a5a;
  936. background: #f4f4f4;
  937. border: 1px solid #dcdcdc;
  938. cursor: pointer;
  939. &:disabled{
  940. cursor: not-allowed ;
  941. opacity: .7;
  942. }
  943. }
  944. span.msg.send{
  945. float: right;
  946. width: 130px;
  947. height: 44px;
  948. line-height: 44px;
  949. font-size: 14px;
  950. background: #d2d2d2;
  951. color: #fff;
  952. border: 1px solid #dcdcdc;
  953. }
  954. input[type='checkbox']{
  955. margin: 0 14px 0 55px;
  956. float: left;
  957. width: 16px;
  958. height: 16px;
  959. }
  960. span.agree{
  961. float: left;
  962. margin: 1px 0 0 10px;
  963. font-size: 14px;
  964. color: #8b8b8b;
  965. a{
  966. color: #0076ad;
  967. }
  968. }
  969. .form-group.agree{
  970. margin: 20px auto 0 !important;
  971. }
  972. .submitBtn {
  973. display: inline-block;
  974. width: 360px;
  975. height: 44px;
  976. line-height: 44px;
  977. font-size: 16px;
  978. color: #fff;
  979. background: #0076AD;
  980. border-radius: 3px;
  981. border: none;
  982. &:disabled{
  983. cursor: not-allowed ;
  984. opacity: .7;
  985. }
  986. }
  987. }
  988. }
  989. .login{
  990. margin-top: 20px;
  991. font-size: 14px;
  992. color: #8c8c8c;
  993. a{
  994. font-size: 14px;
  995. color: #0076ad;
  996. }
  997. }
  998. }
  999. }
  1000. .footer{
  1001. padding: 50px 0;
  1002. }
  1003. </style>