MobileLandPage.vue 8.8 KB

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