EmailValidationSecondStep.vue 12 KB

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