EmailValidationSecondStep.vue 12 KB

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