ttAd.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <div>
  3. </div>
  4. </template>
  5. <script>
  6. import { doAuthUser } from "@/api/accounts/ttAdapi";
  7. export default {
  8. created () {
  9. this.handleSubmit()
  10. },
  11. methods: {
  12. handleSubmit() {
  13. if (window.location.hash.indexOf('?') !== -1) {
  14. const loading = this.$loading({
  15. lock: true,
  16. text: '正在授权,请稍后。。。',
  17. spinner: 'el-icon-loading',
  18. background: 'rgba(0, 0, 0, 0.8)'
  19. });
  20. let query = {
  21. auth_code: this.$route.query.auth_code,
  22. state: this.$route.query.state
  23. }
  24. this.loading = true
  25. doAuthUser(query).then(response => {
  26. loading.close();
  27. let data = response.data
  28. if (data) {
  29. this.$message({
  30. message: '授权成功',
  31. type: 'success'
  32. });
  33. localStorage.setItem("ttAdMp", "ok");
  34. } else {
  35. this.$message({
  36. message: '授权失败',
  37. type: 'error'
  38. });
  39. localStorage.setItem("ttAdMp", "false");
  40. return
  41. }
  42. setTimeout(()=>{
  43. window.close()
  44. }, 200)
  45. }).catch(() => loading.close())
  46. }
  47. }
  48. }
  49. }
  50. </script>