MobileLandPage.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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">{{ isLoginCpd || loginSuccessBack ? 'Claim Prize' : 'Login Twitter' }}</div>
  68. </div>
  69. </template>
  70. <script>
  71. import { RewardType, PlayType } from '../types';
  72. import { getStorage, setStorage, removeStorage, storageKey, getOauthUrl } from '../utils/help';
  73. import { postRequest } from '../http';
  74. import FontZoom from './FontZoom';
  75. const overTimePic = require('../static/img/icon-h5-denet.svg');
  76. const giveawayPic = require('../static/img/icon-h5-giveaway.svg');
  77. const redpackPic = require('../static/img/icon-h5-redpack.svg');
  78. const treasurePic = require('../static/img/icon-h5-treasure.svg');
  79. export default {
  80. name: 'mobileLandPage',
  81. props: {
  82. playType: {
  83. // 玩法类型, 红包 / 抽奖 / 夺宝 / NFT
  84. type: Number,
  85. },
  86. rewardType: {
  87. // 奖品类型 货币/ 自定义奖品
  88. type: Number,
  89. default: 1,
  90. },
  91. useFul: {
  92. // 红包仍在有效期,可领取
  93. type: Boolean,
  94. default: true,
  95. },
  96. userInfo: {
  97. type: Object,
  98. default: () => {
  99. return {};
  100. },
  101. },
  102. currencyIconPath: {
  103. // 货币头像
  104. type: String,
  105. default: '',
  106. },
  107. amountValue: {
  108. // 奖品数量
  109. type: String,
  110. default: '1',
  111. },
  112. usValue: {
  113. // 转换为美金 的价值
  114. type: String,
  115. default: '',
  116. },
  117. prize: {
  118. // 奖品 描述
  119. type: String,
  120. default: '',
  121. },
  122. postId: {
  123. // 推文ID,用于retweer
  124. type: String,
  125. default: '',
  126. },
  127. prizePicPath: {
  128. // NFT图片
  129. type: String,
  130. default: '',
  131. },
  132. },
  133. data() {
  134. return {
  135. timer: {},
  136. loginSuccessBack: false,
  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. isLoginCpd() {
  183. return !!getStorage(storageKey.userInfo);
  184. },
  185. },
  186. methods: {
  187. toLogin() {
  188. let userInfo = getStorage(storageKey.userInfo);
  189. if (userInfo) {
  190. location.href = `/course?useful=${this.useFul ? '1' : '0'}&playType=${this.playType}&rewardType=${this.rewardType}&postId=${this.postId}`;
  191. } else {
  192. this.twitterAuth();
  193. }
  194. },
  195. cancelLogin() {
  196. location.href = `/course?useful=${this.useFul ? '1' : '0'}&playType=${this.playType}&rewardType=${this.rewardType}&postId=${this.postId}`;
  197. },
  198. async twitterAuth() {
  199. let win = window.open();
  200. win.opener = null;
  201. postRequest(`/denet/user/twitterRequestToken`, {
  202. params: {
  203. oauthCallback: `${location.protocol}//${location.host}/authlogin`,
  204. },
  205. }).then(({ code, data }) => {
  206. if (code == 0) {
  207. let url = getOauthUrl(data.authToken);
  208. win.location.href = url;
  209. this.timer.value = setInterval(() => {
  210. if (win && win.closed) {
  211. clearInterval(this.timer.value);
  212. this.twitterLogin(data);
  213. if (getStorage(storageKey.backFromTwitterLogin)) {
  214. removeStorage(storageKey.backFromTwitterLogin);
  215. this.cancelLogin();
  216. }
  217. }
  218. }, 500);
  219. }
  220. });
  221. },
  222. async twitterLogin(authData) {
  223. let verifier = getStorage(storageKey.verifier);
  224. if (verifier) {
  225. postRequest(`/denet/user/twitterLogin`, {
  226. params: {
  227. consumerKey: authData.consumerKey,
  228. oauthToken: authData.authToken,
  229. oauthVerifier: verifier,
  230. },
  231. }).then(({ code, data }) => {
  232. if (code == 0) {
  233. setStorage(storageKey.userInfo, data);
  234. removeStorage(storageKey.verifier);
  235. this.loginSuccessBack = true;
  236. location.href = `/course?useful=${this.useFul ? '1' : '0'}&playType=${this.playType}&rewardType=${this.rewardType}&postId=${this.postId}`;
  237. }
  238. });
  239. }
  240. },
  241. },
  242. unmounted() {
  243. removeStorage(storageKey.backFromTwitterLogin);
  244. },
  245. components: { FontZoom },
  246. };
  247. </script>
  248. <style lang="scss" scoped>
  249. .mobile-land-page {
  250. min-height: 100%;
  251. max-height: 100%;
  252. background: linear-gradient(180deg, #cceaff 0%, #ffffff 70.42%);
  253. display: flex;
  254. flex-direction: column;
  255. justify-content: space-between;
  256. align-items: center;
  257. padding: 0 16px;
  258. &-invited-info {
  259. width: 302px;
  260. height: 72px;
  261. margin-top: 28px;
  262. position: relative;
  263. padding-left: 81px;
  264. border-radius: 35px;
  265. display: flex;
  266. flex-direction: column;
  267. align-items: flex-start;
  268. justify-content: flex-start;
  269. background: #ffffff;
  270. border: 1px solid #c0daeb;
  271. .invited-photo {
  272. width: 70px;
  273. height: 70px;
  274. border-radius: 50%;
  275. position: absolute;
  276. left: 0;
  277. top: 0;
  278. }
  279. .invited-name {
  280. margin: 13px 0 5px;
  281. font-weight: 500;
  282. font-size: 13px;
  283. line-height: 16px;
  284. letter-spacing: 0.3px;
  285. color: #000000;
  286. max-width: 210px;
  287. text-overflow: ellipsis;
  288. white-space: nowrap;
  289. overflow: hidden;
  290. }
  291. .invited-text {
  292. font-weight: 700;
  293. font-size: 17px;
  294. line-height: 20px;
  295. letter-spacing: 0.3px;
  296. color: #f99d23;
  297. }
  298. }
  299. &-icon-wrap {
  300. display: flex;
  301. flex: 1;
  302. align-items: center;
  303. .mobile-land-page-icon {
  304. width: 100%;
  305. }
  306. }
  307. &-prize-info {
  308. font-style: normal;
  309. font-weight: 700;
  310. font-size: 18px;
  311. line-height: 21px;
  312. color: #000000;
  313. &-test {
  314. display: flex;
  315. align-items: center;
  316. justify-content: center;
  317. .pre-amount-value {
  318. margin-left: 3px;
  319. }
  320. .icon {
  321. width: 22px;
  322. height: 22px;
  323. margin-left: 3px;
  324. }
  325. .prize-name {
  326. margin: 0 3px;
  327. }
  328. }
  329. }
  330. &-tip {
  331. font-weight: 400;
  332. font-size: 13px;
  333. line-height: 16px;
  334. text-align: center;
  335. color: #7b7b7b;
  336. margin-top: 10px;
  337. }
  338. &-login-twitter {
  339. width: 100%;
  340. height: 54px;
  341. margin: 18px 16px 30px;
  342. border-radius: 54px;
  343. background: #1d9bf0;
  344. text-align: center;
  345. line-height: 54px;
  346. font-weight: 700;
  347. font-size: 18px;
  348. text-align: center;
  349. color: #fff;
  350. }
  351. }
  352. </style>