MobileLandPage.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="mobile-land-page">
  3. <div class="mobile-land-page-invited-info">
  4. <img :src="detail.postBizData.postUserInfo.avatarUrl" class="invited-photo" />
  5. <div class="invited-name">{{ detail.postBizData.postUserInfo.nickName }}</div>
  6. <div class="invited-text">Send You Giveaway!</div>
  7. </div>
  8. <div class="mobile-land-page-icon">icon</div>
  9. <div class="mobile-land-page-prize-info">
  10. <template></template>
  11. </div>
  12. <div class="mobile-land-page-login-twitter" @click="toLogin">Login Twitter</div>
  13. </div>
  14. </template>
  15. <script>
  16. import { RewardType, PlayType } from '../types';
  17. import { getStorage, setStorage, removeStorage, storageKey, getOauthUrl, createWindow } from '../utils/help';
  18. import { postRequest } from '../http';
  19. export default {
  20. name: 'mobileLandPage',
  21. props: {
  22. detail: {
  23. type: Object,
  24. default: () => {
  25. return {
  26. postBizData: {},
  27. };
  28. },
  29. },
  30. extensionsInstallUrl: {
  31. type: String,
  32. default: '',
  33. },
  34. },
  35. data() {
  36. return {
  37. config: {},
  38. timer: {},
  39. };
  40. },
  41. computed: {
  42. isMoneyRewardCpd() {
  43. return this.rewardType === RewardType.money;
  44. },
  45. isLottaryCpd() {
  46. return this.playType === PlayType.lottery;
  47. },
  48. },
  49. methods: {
  50. toLogin() {
  51. let userInfo = getStorage(storageKey.userInfo);
  52. if (userInfo) {
  53. location.href = `/nft/list`;
  54. } else {
  55. this.twitterAuth();
  56. }
  57. },
  58. async twitterAuth() {
  59. postRequest(`/denet/user/twitterRequestToken`, {
  60. params: {
  61. oauthCallback: `${location.protocol}//${location.host}/authlogin`,
  62. },
  63. }).then(({ code, data }) => {
  64. if (code == 0) {
  65. console.log('%c [ data ]-78', 'font-size:13px; background:pink; color:#bf2c9f;', data);
  66. let url = getOauthUrl(data.authToken);
  67. let win = createWindow(url);
  68. this.timer.value = setInterval(() => {
  69. if (win && win.closed) {
  70. clearInterval(this.timer.value);
  71. this.twitterLogin(data);
  72. }
  73. }, 500);
  74. }
  75. });
  76. },
  77. async twitterLogin(authData) {
  78. let verifier = getStorage(storageKey.verifier);
  79. if (verifier) {
  80. postRequest(`/denet/user/twitterLogin`, {
  81. params: {
  82. consumerKey: authData.consumerKey,
  83. oauthToken: authData.authToken,
  84. oauthVerifier: verifier,
  85. },
  86. }).then(({ code, data }) => {
  87. if (code == 0) {
  88. console.log('%c [ data ]-100', 'font-size:13px; background:pink; color:#bf2c9f;', data);
  89. setStorage(storageKey.userInfo, data);
  90. removeStorage(storageKey.verifier);
  91. }
  92. });
  93. }
  94. },
  95. },
  96. };
  97. </script>
  98. <style lang="scss" scoped>
  99. .mobile-land-page {
  100. min-height: 100vh;
  101. max-height: 100vh;
  102. background: linear-gradient(180deg, #cceaff 0%, #ffffff 70.42%);
  103. display: flex;
  104. flex-direction: column;
  105. justify-content: space-between;
  106. align-items: center;
  107. &-invited-info {
  108. width: 300px;
  109. height: 70px;
  110. margin-top: 28px;
  111. position: relative;
  112. padding-left: 81px;
  113. border-radius: 35px;
  114. display: flex;
  115. flex-direction: column;
  116. align-items: flex-start;
  117. justify-content: flex-start;
  118. background: #ffffff;
  119. border: 1px solid #c0daeb;
  120. .invited-photo {
  121. width: 70px;
  122. height: 70px;
  123. border-radius: 50%;
  124. position: absolute;
  125. left: 0;
  126. top: 0;
  127. }
  128. .invited-name {
  129. margin: 13px 0 5px;
  130. font-weight: 500;
  131. font-size: 13px;
  132. line-height: 16px;
  133. letter-spacing: 0.3px;
  134. color: #000000;
  135. }
  136. .invited-text {
  137. font-weight: 700;
  138. font-size: 17px;
  139. line-height: 20px;
  140. letter-spacing: 0.3px;
  141. color: #f99d23;
  142. }
  143. }
  144. &-icon {
  145. flex: 1;
  146. }
  147. &-login-twitter {
  148. width: 100%;
  149. height: 54px;
  150. margin: 18px 16px 30px;
  151. border-radius: 54px;
  152. background: #1d9bf0;
  153. text-align: center;
  154. line-height: 54px;
  155. font-weight: 700;
  156. font-size: 18px;
  157. text-align: center;
  158. color: #fff;
  159. }
  160. }
  161. </style>