EmailValidationSecondStep.vue 12 KB

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