MobileLandPage.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <div class="mobile-land-page">
  3. <div class="mobile-land-page-invited-info" v-if="useFul && !isNFTCpd">
  4. <img :src="userInfo.avatarUrl" class="invited-photo" />
  5. <div class="invited-name">{{ userInfo.nickName }}</div>
  6. <div class="invited-text">{{ isTreasureCpd ? 'Invite You to Hunt the Treasure' : 'Send You Giveaway!' }}</div>
  7. </div>
  8. <div class="mobile-land-page-icon-wrap">
  9. <img class="mobile-land-page-icon" :src="iconCpd" />
  10. </div>
  11. <div class="mobile-land-page-prize-info">
  12. <template v-if="!useFul">
  13. <div class="mobile-land-page-prize-info-test">
  14. <!-- time-expired -->
  15. </div>
  16. </template>
  17. <!-- 红包 -->
  18. <template v-else-if="isCommonCpd">
  19. <div class="mobile-land-page-prize-info-test">You are gifted an entries to earn</div>
  20. <div class="mobile-land-page-prize-info-test">
  21. <img v-if="!isCustomRewardCpd" class="icon" :src="currencyIconPath" />
  22. <span class="pre-amount-value">{{ isCustomRewardCpd ? 1 : amountValue }}</span>
  23. <span class="prize-name">{{ prize }}</span>
  24. <span class="usd-amount" v-if="!isCustomRewardCpd"> (${{ usValue }})</span>
  25. </div>
  26. </template>
  27. <!-- 抽奖 -->
  28. <template v-else-if="isLottaryCpd">
  29. <div class="mobile-land-page-prize-info-test">
  30. You Won
  31. <img v-if="!isCustomRewardCpd" class="icon" :src="currencyIconPath" />
  32. <span class="pre-amount-value">{{ isCustomRewardCpd ? 1 : amountValue }}</span>
  33. <FontZoom width="240" style="color: #000">
  34. <span class="prize-name">{{ prize }}</span>
  35. </FontZoom>
  36. <span class="usd-amount" v-if="!isCustomRewardCpd"> (${{ usValue }})</span>
  37. </div>
  38. <div class="mobile-land-page-prize-info-test">in the Giveaway!</div>
  39. </template>
  40. <!-- 夺宝 -->
  41. <template v-else-if="isTreasureCpd">
  42. <div class="mobile-land-page-prize-info-test">Complete the quest to win</div>
  43. <div class="mobile-land-page-prize-info-test">
  44. <img class="icon" :src="currencyIconPath" />
  45. <span class="pre-amount-value">{{ amountValue }}</span>
  46. <span class="prize-name">{{ prize }}</span>
  47. <span class="usd-amount"> (${{ usValue }})</span>
  48. for you two!
  49. </div>
  50. </template>
  51. <!-- NFT -->
  52. <template v-else-if="isNFTCpd">
  53. <div class="mobile-land-page-prize-info-test">
  54. <span class="prize-name">{{ prize }}</span>
  55. is in your
  56. </div>
  57. <div class="mobile-land-page-prize-info-test">DeNet NFT wallet!</div>
  58. </template>
  59. <!-- 兜底显示 -->
  60. <template v-else>
  61. <div class="mobile-land-page-prize-info-test"></div>
  62. </template>
  63. </div>
  64. <FontZoom width="330">
  65. <div class="mobile-land-page-tip">{{ tipCpd }}</div>
  66. </FontZoom>
  67. <div class="mobile-land-page-login-twitter" @click="toLogin">Login Twitter</div>
  68. </div>
  69. </template>
  70. <script>
  71. import { RewardType, PlayType } from '../types';
  72. import { getStorage, setStorage, removeStorage, storageKey, getOauthUrl, createWindow } from '../utils/help';
  73. import { postRequest } from '../http';
  74. import FontZoom from './FontZoom';
  75. const TO_LOGIN_KEY = 'twitter-login-from-denet-mobile-h5-landpage';
  76. const overTimePic = require('../static/img/icon-h5-denet.svg');
  77. const giveawayPic = require('../static/img/icon-h5-giveaway.svg');
  78. const redpackPic = require('../static/img/icon-h5-redpack.svg');
  79. const treasurePic = require('../static/img/icon-h5-treasure.svg');
  80. export default {
  81. name: 'mobileLandPage',
  82. props: {
  83. playType: {
  84. // 玩法类型, 红包 / 抽奖 / 夺宝 / NFT
  85. type: Number,
  86. },
  87. rewardType: {
  88. // 奖品类型 货币/ 自定义奖品
  89. type: Number,
  90. default: 1,
  91. },
  92. useFul: {
  93. // 红包仍在有效期,可领取
  94. type: Boolean,
  95. default: true,
  96. },
  97. userInfo: {
  98. type: Object,
  99. default: () => {
  100. return {};
  101. },
  102. },
  103. currencyIconPath: {
  104. // 货币头像
  105. type: String,
  106. default: '',
  107. },
  108. amountValue: {
  109. // 奖品数量
  110. type: String,
  111. default: '1',
  112. },
  113. usValue: {
  114. // 转换为美金 的价值
  115. type: String,
  116. default: '',
  117. },
  118. prize: {
  119. // 奖品 描述
  120. type: String,
  121. default: '',
  122. },
  123. postId: {
  124. // 推文ID,用于retweer
  125. type: String,
  126. default: '',
  127. },
  128. prizePicPath: {
  129. // NFT图片
  130. type: String,
  131. default: '',
  132. },
  133. },
  134. data() {
  135. return {
  136. timer: {},
  137. };
  138. },
  139. computed: {
  140. isCustomRewardCpd() {
  141. return this.rewardType === RewardType.custom;
  142. },
  143. isLottaryCpd() {
  144. return this.playType === PlayType.lottery;
  145. },
  146. isCommonCpd() {
  147. return this.playType === PlayType.common;
  148. },
  149. isTreasureCpd() {
  150. return this.playType === PlayType.Treasure;
  151. },
  152. isNFTCpd() {
  153. return this.playType === PlayType.NFT;
  154. },
  155. iconCpd() {
  156. if (!this.useFul) {
  157. return overTimePic;
  158. } else if (this.isCommonCpd) {
  159. return giveawayPic;
  160. } else if (this.isLottaryCpd) {
  161. return redpackPic;
  162. } else if (this.isTreasureCpd) {
  163. return treasurePic;
  164. } else if (this.isNFTCpd) {
  165. return this.prizePicPath;
  166. }
  167. {
  168. return overTimePic;
  169. }
  170. },
  171. tipCpd() {
  172. if (this.isCommonCpd) {
  173. return 'to claim, log in twitter to install Denet Chrome Extension';
  174. } else if (this.isLottaryCpd) {
  175. return 'To participate, login Twitter to install DeNet Chrome Extension';
  176. } else if (this.isTreasureCpd) {
  177. return 'To complete, log in twitter to install Denet Chrome Extension';
  178. } else {
  179. return 'login Twitter to install DeNet Chrome Extension';
  180. }
  181. },
  182. },
  183. methods: {
  184. toLogin() {
  185. let userInfo = getStorage(storageKey.userInfo);
  186. if (userInfo) {
  187. setStorage(TO_LOGIN_KEY, 1);
  188. location.href = `/course?useful=${this.useFul ? '1' : '0'}&playType=${this.playType}&rewardType=${this.rewardType}&postId=${this.postId}`;
  189. } else {
  190. this.twitterAuth();
  191. }
  192. },
  193. async twitterAuth() {
  194. postRequest(`/denet/user/twitterRequestToken`, {
  195. params: {
  196. oauthCallback: `${location.protocol}//${location.host}/authlogin`,
  197. },
  198. }).then(({ code, data }) => {
  199. if (code == 0) {
  200. console.log('%c [ data ]-78', 'font-size:13px; background:pink; color:#bf2c9f;', data);
  201. let url = getOauthUrl(data.authToken);
  202. let win = createWindow(url);
  203. this.timer.value = setInterval(() => {
  204. if (win && win.closed) {
  205. clearInterval(this.timer.value);
  206. this.twitterLogin(data);
  207. }
  208. }, 500);
  209. }
  210. });
  211. },
  212. async twitterLogin(authData) {
  213. let verifier = getStorage(storageKey.verifier);
  214. if (verifier) {
  215. postRequest(`/denet/user/twitterLogin`, {
  216. params: {
  217. consumerKey: authData.consumerKey,
  218. oauthToken: authData.authToken,
  219. oauthVerifier: verifier,
  220. },
  221. }).then(({ code, data }) => {
  222. if (code == 0) {
  223. console.log('%c [ data ]-100', 'font-size:13px; background:pink; color:#bf2c9f;', data);
  224. setStorage(storageKey.userInfo, data);
  225. removeStorage(storageKey.verifier);
  226. }
  227. });
  228. }
  229. },
  230. },
  231. mounted() {
  232. const fromTwitterLoginPage = getStorage(TO_LOGIN_KEY);
  233. if (fromTwitterLoginPage) {
  234. removeStorage(TO_LOGIN_KEY);
  235. location.href = `/course?useful=${this.useFul ? '1' : '0'}&playType=${this.playType}&rewardType=${this.rewardType}&postId=${this.postId}`;
  236. }
  237. },
  238. components: { FontZoom },
  239. };
  240. </script>
  241. <style lang="scss" scoped>
  242. .mobile-land-page {
  243. min-height: 100vh;
  244. max-height: 100vh;
  245. background: linear-gradient(180deg, #cceaff 0%, #ffffff 70.42%);
  246. display: flex;
  247. flex-direction: column;
  248. justify-content: space-between;
  249. align-items: center;
  250. padding: 0 16px;
  251. &-invited-info {
  252. width: 302px;
  253. height: 72px;
  254. margin-top: 28px;
  255. position: relative;
  256. padding-left: 81px;
  257. border-radius: 35px;
  258. display: flex;
  259. flex-direction: column;
  260. align-items: flex-start;
  261. justify-content: flex-start;
  262. background: #ffffff;
  263. border: 1px solid #c0daeb;
  264. .invited-photo {
  265. width: 70px;
  266. height: 70px;
  267. border-radius: 50%;
  268. position: absolute;
  269. left: 0;
  270. top: 0;
  271. }
  272. .invited-name {
  273. margin: 13px 0 5px;
  274. font-weight: 500;
  275. font-size: 13px;
  276. line-height: 16px;
  277. letter-spacing: 0.3px;
  278. color: #000000;
  279. max-width: 210px;
  280. text-overflow: ellipsis;
  281. white-space: nowrap;
  282. overflow: hidden;
  283. }
  284. .invited-text {
  285. font-weight: 700;
  286. font-size: 17px;
  287. line-height: 20px;
  288. letter-spacing: 0.3px;
  289. color: #f99d23;
  290. }
  291. }
  292. &-icon-wrap {
  293. display: flex;
  294. flex: 1;
  295. align-items: center;
  296. .mobile-land-page-icon {
  297. width: 100%;
  298. }
  299. }
  300. &-prize-info {
  301. font-style: normal;
  302. font-weight: 700;
  303. font-size: 18px;
  304. line-height: 21px;
  305. color: #000000;
  306. &-test {
  307. display: flex;
  308. align-items: center;
  309. justify-content: center;
  310. .pre-amount-value {
  311. margin-left: 3px;
  312. }
  313. .icon {
  314. width: 22px;
  315. height: 22px;
  316. margin-left: 3px;
  317. }
  318. .prize-name {
  319. margin: 0 3px;
  320. }
  321. }
  322. }
  323. &-tip {
  324. font-weight: 400;
  325. font-size: 13px;
  326. line-height: 16px;
  327. text-align: center;
  328. color: #7b7b7b;
  329. margin-top: 10px;
  330. }
  331. &-login-twitter {
  332. width: 100%;
  333. height: 54px;
  334. margin: 18px 16px 30px;
  335. border-radius: 54px;
  336. background: #1d9bf0;
  337. text-align: center;
  338. line-height: 54px;
  339. font-weight: 700;
  340. font-size: 18px;
  341. text-align: center;
  342. color: #fff;
  343. }
  344. }
  345. </style>