MailBinding.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div>
  3. <div class="right-modifyPsw">
  4. <div>
  5. <div class="right-modifyPsw-title">
  6. <span style="font-size: 18px;font-weight: bold">邮箱绑定</span>
  7. </div>
  8. <div>
  9. <div v-if="!user.email">
  10. <div style="background-color: rgba(233,239,249,1);padding: 10px;margin-bottom: 30px">
  11. <img src="../../assets/img/phoneUnbinding.png"></img>
  12. <span style="font-size: 16px">您还未绑定邮箱,为保护您帐号,建议您</span>
  13. <el-button type="primary" plain size="mini" @click="handleBindingEmail">立即绑定
  14. </el-button>
  15. </div>
  16. <div>
  17. 邮箱绑定成功后,您将享受以下服务:
  18. </div>
  19. <div>①邮箱地址登录 可直接使用“邮箱地址”登录到众测服务平台</div>
  20. <div>②重要事件提醒 进行(支付/提现/众测/中标)时,可及时收到邮件提醒</div>
  21. <div>③找回账号密码 忘记密码时,可使用邮件找回密码</div>
  22. </div>
  23. <div v-if="user.email">
  24. <div style="background-color: rgba(233,239,249,1);padding: 10px;margin-bottom: 30px">
  25. <img src="../../assets/img/phoneBinding.png"></img>
  26. <span style="font-size: 16px">您绑定的邮箱是:{{this.user.email}}</span>
  27. <el-button type="primary" plain size="mini" @click="handleChangeEmail" style="margin-left: 20px">修改邮箱</el-button>
  28. </div>
  29. </div>
  30. <router-view></router-view>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import Http from '@/js/http.js'
  38. import {storageGet} from '@/js/index'
  39. import {notify} from '@/constants/index'
  40. export default {
  41. name: "MailBinding",
  42. data() {
  43. return {
  44. hasVerifyCode: false,
  45. bindingEmail: false,
  46. codeTime: 10,
  47. emailBindingForm: {
  48. email: '',
  49. verifyCode: ''
  50. },
  51. user: {}
  52. }
  53. },
  54. methods: {
  55. setUserInfo() {
  56. let userId = storageGet('user')&&storageGet('user').userVO.id;
  57. Http.get(`/api/user/${userId}`).then(res=>{
  58. this.user = res.userVO
  59. })
  60. },
  61. handleBindingEmail(){
  62. this.$router.push({
  63. path: '/personal/mailBinding/binding',
  64. });
  65. },
  66. handleChangeEmail(){
  67. this.$router.push({
  68. path: '/personal/mailBinding/rebinding',
  69. });
  70. },
  71. getVerifyCode() {
  72. let params = {
  73. id: this.user.id,
  74. email: this.emailBindingForm.email
  75. }
  76. Http.put('/api/verify/email', params).then((res) => {
  77. this.hasVerifyCode = true;
  78. let _this = this;
  79. let codeTimer = setInterval(function () {
  80. if (_this.codeTime > 0) {
  81. _this.codeTime--;
  82. } else {
  83. clearInterval(codeTimer);
  84. _this.hasVerifyCode = false;
  85. this.codeTime = 10;
  86. this.setUserInfo()
  87. }
  88. }, 1000)
  89. }).catch(err => {
  90. notify('error', '获取验证码失败:' + err.data);
  91. })
  92. }
  93. },
  94. mounted() {
  95. this.setUserInfo();
  96. },
  97. watch:{
  98. '$route' (to, from) {
  99. if(to.path==='/personal/mailBinding'){
  100. this.$router.go(0);
  101. }
  102. }
  103. }
  104. }
  105. </script>
  106. <style scoped lang="less">
  107. .right-modifyPsw {
  108. padding: 20px;
  109. background: rgba(255, 255, 255, 1);
  110. box-shadow: 0px 1px 6px 0px rgba(8, 6, 6, 0.13);
  111. .right-modifyPsw-title {
  112. padding: 10px;
  113. border-bottom: 1px solid #ccc;
  114. margin-bottom: 20px;
  115. }
  116. }
  117. </style>