PersonalRegistration.vue 33 KB

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