EmailValidationSecondStep.vue 12 KB

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