PersonalRegistration.vue 37 KB

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