EmailValidationSecondStep.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <div class="validation">
  3. <div class="container">
  4. <div class="content">
  5. <div class="content-top">
  6. <h3>验证邮箱</h3>
  7. <div class="step">
  8. <img src="/images/all/step02.png" alt=""/>
  9. <div class="step-item"><span class="active">账号验证</span><span class="active">新邮箱地址</span><span>设置完成</span></div>
  10. </div>
  11. </div>
  12. <div class="content-bottom">
  13. <div>
  14. <el-form :model="valid2" :rules="rules2" ref="valid2" label-width="100px" class="demo-ruleForm">
  15. <el-form-item prop="email">
  16. <el-input v-model="valid2.email"
  17. v-bind:class="{ active: emailSecondExit }"
  18. placeholder="新邮箱地址"></el-input>
  19. <span class="tip tip-mobile" v-show="emailSecondExit">该邮箱已被注册</span>
  20. </el-form-item>
  21. <el-form-item>
  22. <a class="btn finish"
  23. v-show="!sendEmailSuccess"
  24. :disabled="!emailSecondChecked"
  25. @click="sendVerificationRequest">发送验证请求</a>
  26. <a class="btn finish"
  27. v-show="sendEmailSuccess"
  28. :disabled="sendEmailSuccess">已发送验证邮件,请查收</a>
  29. </el-form-item>
  30. </el-form>
  31. </div>
  32. </div>
  33. </div>
  34. <loading v-show="isShowLoading"/>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import Loading from '~components/common/loading/Loading.vue'
  40. export default {
  41. name: 'validation',
  42. components: {
  43. Loading
  44. },
  45. data () {
  46. // 第二步验证邮箱
  47. var validateSecondEmail = (rule, value, callback) => {
  48. if (value === '') {
  49. callback(new Error('请填写正确的邮箱号'))
  50. this.emailSecondChecked = false
  51. this.emailSecondExit = false
  52. } else {
  53. if (this.valid2.email !== '') {
  54. var reg = /^([\w-])+(\.\w+)*@([\w-])+((\.\w{2,3}){1,3})$/
  55. if (!reg.test(value)) {
  56. callback(new Error('请填写正确的邮箱号'))
  57. this.emailSecondChecked = false
  58. this.emailSecondExit = false
  59. } else {
  60. this.$http.get(`/update/user/email/hasRegister`, {params: {email: this.valid2.email}})
  61. .then(response => {
  62. if (response.data.content.hasRegister) {
  63. this.emailSecondChecked = false
  64. this.emailSecondExit = true
  65. } else {
  66. this.emailSecondChecked = true
  67. this.emailSecondExit = false
  68. }
  69. })
  70. }
  71. }
  72. callback()
  73. }
  74. }
  75. return {
  76. isShowLoading: false,
  77. sendEmailSuccess: false,
  78. emailSecondChecked: false,
  79. emailSecondExit: false,
  80. valid2: {
  81. email: ''
  82. },
  83. rules2: {
  84. email: [
  85. {validator: validateSecondEmail, trigger: 'blur'}
  86. ]
  87. }
  88. }
  89. },
  90. computed: {
  91. firstStepToken () {
  92. return this.$store.state.login.token.data
  93. }
  94. },
  95. mounted () {
  96. // 获取邮箱token
  97. this.$nextTick(() => {
  98. this.getEmailLinkToken()
  99. })
  100. },
  101. methods: {
  102. // 设置新邮箱
  103. sendVerificationRequest () {
  104. if (this.emailSecondChecked) {
  105. this.isShowLoading = true
  106. this.$http.get(`/update/user/setEmail`, {params: {email: this.valid2.email, token: this.firstStepToken}})
  107. .then(response => {
  108. this.isShowLoading = false
  109. if (response.data.success) {
  110. this.sendEmailSuccess = true
  111. } else {
  112. this.sendEmailSuccess = false
  113. return Promise.reject(response.data)
  114. }
  115. }).catch(err => {
  116. this.isShowLoading = false
  117. // console.log(err)
  118. this.$message.error(err.errMsg)
  119. })
  120. }
  121. },
  122. // 获得邮箱token
  123. getEmailLinkToken () {
  124. var url = window.location.search
  125. var request = {}
  126. if (url.indexOf('?' !== -1)) {
  127. var str = url.substr(1)
  128. var strs = str.split('&')
  129. for (var i = 0; i < strs.length; i++) {
  130. request[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1])
  131. }
  132. }
  133. this.Token = request['token'] || ''
  134. if (this.Token) {
  135. this.$store.commit('login/GET_TOKEN', this.Token)
  136. }
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .validation {
  143. margin: 0 auto;
  144. width: 100%;
  145. background: #eee;
  146. .container{
  147. padding-top: 50px;
  148. margin: 0 auto;
  149. width: 980px;
  150. text-align: center;
  151. .content{
  152. padding: 0 50px;
  153. margin: 50px auto 0;
  154. width: 100%;
  155. /*height: 540px;*/
  156. text-align: center;
  157. background: #fff;
  158. .content-top{
  159. height: 80px;
  160. line-height: 80px;
  161. h3{
  162. margin-bottom: 0;
  163. font-size: 24px;
  164. color: #000;
  165. border-bottom: 1px solid #dcdcdc;
  166. }
  167. .step{
  168. position: relative;
  169. margin-top: 10px;
  170. img{
  171. width: 315px;
  172. height: 46px;
  173. }
  174. .step-item{
  175. position: absolute;
  176. top: 45px;
  177. left: 265px;
  178. span{
  179. margin-right: 78px;
  180. font-size: 14px;
  181. color: #b4b4b4;
  182. }
  183. span.active {
  184. color: #0076ad;
  185. }
  186. }
  187. }
  188. }
  189. form {
  190. margin-top: 150px;
  191. padding-bottom: 44px;
  192. input{
  193. padding: 0 0 0 18px;
  194. width: 360px;
  195. height: 44px;
  196. line-height: 44px;
  197. font-size: 14px;
  198. color: #000;
  199. border-radius: 0;
  200. }
  201. input.answer {
  202. background: url("/images/all/more.png") no-repeat 325px center;
  203. cursor: pointer;
  204. }
  205. ul{
  206. display: none;
  207. position: absolute;
  208. top: 44px;
  209. left: 0;
  210. width: 360px;
  211. background: #fff;
  212. box-shadow: 0 0 5px rgba(0,0,0,.5);
  213. -moz-box-shadow: 0 0 5px rgba(0,0,0,.5);
  214. -o-box-shadow: 0 0 5px rgba(0,0,0,.5);
  215. -webkit-box-shadow: 0 0 5px rgba(0,0,0,.5);
  216. z-index: 10;
  217. li{
  218. padding-left: 18px;
  219. width: 100%;
  220. height: 30px;
  221. line-height: 30px;
  222. text-align: left;
  223. font-size: 14px;
  224. color: #000;
  225. cursor: pointer;
  226. &:hover{
  227. background: #0076ad;
  228. color: #fff;
  229. }
  230. }
  231. }
  232. span.tip{
  233. position: absolute;
  234. top: 0;
  235. right: -238px;
  236. font-size: 13px;
  237. color: #8c8c8c;
  238. a{
  239. font-size: 13px;
  240. color: #0076ad;
  241. }
  242. }
  243. span.tip.tip-mobile{
  244. top: 3px;
  245. right: -105px;
  246. color: #ff4949;
  247. font-size: 12px;
  248. }
  249. span.tip.codeError-tip{
  250. position: absolute;
  251. top: 3px;
  252. left: 378px;
  253. width: 200px;
  254. text-align: left;
  255. color: #ff4949;
  256. font-size: 12px;
  257. }
  258. i{
  259. position: absolute;
  260. top: 13px;
  261. left: 20px;
  262. font-size: 20px;
  263. color: #a0a0a0;
  264. }
  265. .btn {
  266. margin: 34px 0 16px 0;
  267. width: 360px;
  268. height: 44px;
  269. line-height: 44px;
  270. font-size: 16px;
  271. color: #fff;
  272. background: #0076AD;
  273. border-radius: 3px;
  274. }
  275. }
  276. .content-bottom{
  277. margin: 155px auto 0;
  278. padding-bottom: 50px;
  279. width: 360px;
  280. div.warp{
  281. padding-bottom: 65px;
  282. }
  283. p{
  284. font-size: 24px;
  285. color: #323232;
  286. img{
  287. margin-right: 20px;
  288. width: 30px;
  289. height: 28px;
  290. }
  291. }
  292. p.pass{
  293. font-size: 24px;
  294. color: #e77405;
  295. img{
  296. height: 30px;
  297. }
  298. }
  299. p.passed {
  300. color: #2ab300;
  301. img{
  302. height: 30px;
  303. }
  304. }
  305. span{
  306. display: inline-block;
  307. font-size: 14px;
  308. color: #8b8b8b;
  309. }
  310. span.close-tip{
  311. margin: 15px 0 140px 0;
  312. }
  313. .close-btn{
  314. margin: 0 auto;
  315. width: 200px;
  316. height: 36px;
  317. line-height: 36px;
  318. font-size: 14px;
  319. text-align: center;
  320. color: #323232;
  321. border: 1px solid #d2d2d2;
  322. border-radius: 3px;
  323. cursor: pointer ;
  324. }
  325. span.use{
  326. display: inline-block;
  327. margin-bottom: 30px;
  328. width: 360px;
  329. font-size: 14px;
  330. color: #000;
  331. text-align: left;
  332. em{
  333. font-size: 14px;
  334. font-style: normal;
  335. color: #000;
  336. }
  337. }
  338. .form-group {
  339. margin: 0 auto 16px;
  340. position: relative;
  341. width: 360px;
  342. height: 44px;
  343. line-height: 44px;
  344. input{
  345. padding: 0 0 0 18px;
  346. width: 360px;
  347. height: 44px;
  348. line-height: 44px;
  349. font-size: 14px;
  350. color: #000;
  351. border-radius: 0;
  352. }
  353. input.msg{
  354. float: left;
  355. width: 210px;
  356. padding: 0 0 0 18px;
  357. height: 44px;
  358. line-height: 44px;
  359. font-size: 14px;
  360. color: #000;
  361. border-radius: 0;
  362. }
  363. span.msg{
  364. float: right;
  365. margin: 0;
  366. width: 130px;
  367. height: 44px;
  368. line-height: 44px;
  369. text-align: center ;
  370. font-size: 14px;
  371. color: #5a5a5a;
  372. background: #f4f4f4;
  373. border: 1px solid #dcdcdc;
  374. cursor: pointer;
  375. }
  376. span.msg.send{
  377. background: #d2d2d2;
  378. color: #fff;
  379. }
  380. }
  381. .btn {
  382. margin: 34px 0 10px 0;
  383. width: 360px;
  384. height: 44px;
  385. line-height: 44px;
  386. font-size: 16px;
  387. color: #fff;
  388. background: #0076AD;
  389. border-radius: 3px;
  390. }
  391. }
  392. .choose{
  393. margin: 155px auto 0;
  394. padding-bottom: 44px;
  395. div{
  396. padding: 0 15px;
  397. margin: 0 auto 16px;
  398. width: 360px;
  399. height: 60px;
  400. line-height: 60px;
  401. text-align: left;
  402. overflow: hidden;
  403. border: 1px solid #d2d2d2;
  404. cursor: pointer;
  405. &:hover,&.active{
  406. border-color: #0076ad;
  407. span{
  408. color: #0076ad;
  409. }
  410. i.second {
  411. color: #0076ad;
  412. }
  413. }
  414. img.first{
  415. float: left;
  416. margin: 24px 20px 0 0;
  417. font-size: 20px;
  418. color: #323232;
  419. }
  420. img.first.mob{
  421. margin: 22px 20px 0 5px;
  422. font-size: 28px;
  423. }
  424. i.second {
  425. float: right;
  426. margin: 20px 0 0 5px;
  427. font-size: 20px;
  428. color: #323232;
  429. }
  430. span{
  431. float: left;
  432. font-size: 14px;
  433. color: #323232;
  434. }
  435. }
  436. }
  437. a.return{
  438. position: absolute;
  439. left: 0;
  440. top: -15px;
  441. img{
  442. width: 34px !important;
  443. height: 34px !important;
  444. }
  445. }
  446. }
  447. }
  448. }
  449. </style>