PersonalRegistration.vue 36 KB

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