MobileLandPage.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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, createWindow } 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. async twitterAuth() {
  196. postRequest(`/denet/user/twitterRequestToken`, {
  197. params: {
  198. oauthCallback: `${location.protocol}//${location.host}/authlogin`,
  199. },
  200. }).then(({ code, data }) => {
  201. if (code == 0) {
  202. let url = getOauthUrl(data.authToken);
  203. let win = createWindow(url);
  204. this.timer.value = setInterval(() => {
  205. if (win && win.closed) {
  206. clearInterval(this.timer.value);
  207. this.twitterLogin(data);
  208. }
  209. }, 500);
  210. }
  211. });
  212. },
  213. async twitterLogin(authData) {
  214. let verifier = getStorage(storageKey.verifier);
  215. if (verifier) {
  216. postRequest(`/denet/user/twitterLogin`, {
  217. params: {
  218. consumerKey: authData.consumerKey,
  219. oauthToken: authData.authToken,
  220. oauthVerifier: verifier,
  221. },
  222. }).then(({ code, data }) => {
  223. if (code == 0) {
  224. setStorage(storageKey.userInfo, data);
  225. removeStorage(storageKey.verifier);
  226. this.loginSuccessBack = true;
  227. location.href = `/course?useful=${this.useFul ? '1' : '0'}&playType=${this.playType}&rewardType=${this.rewardType}&postId=${this.postId}`;
  228. }
  229. });
  230. }
  231. },
  232. },
  233. components: { FontZoom },
  234. };
  235. </script>
  236. <style lang="scss" scoped>
  237. .mobile-land-page {
  238. min-height: 100%;
  239. max-height: 100%;
  240. background: linear-gradient(180deg, #cceaff 0%, #ffffff 70.42%);
  241. display: flex;
  242. flex-direction: column;
  243. justify-content: space-between;
  244. align-items: center;
  245. padding: 0 16px;
  246. &-invited-info {
  247. width: 302px;
  248. height: 72px;
  249. margin-top: 28px;
  250. position: relative;
  251. padding-left: 81px;
  252. border-radius: 35px;
  253. display: flex;
  254. flex-direction: column;
  255. align-items: flex-start;
  256. justify-content: flex-start;
  257. background: #ffffff;
  258. border: 1px solid #c0daeb;
  259. .invited-photo {
  260. width: 70px;
  261. height: 70px;
  262. border-radius: 50%;
  263. position: absolute;
  264. left: 0;
  265. top: 0;
  266. }
  267. .invited-name {
  268. margin: 13px 0 5px;
  269. font-weight: 500;
  270. font-size: 13px;
  271. line-height: 16px;
  272. letter-spacing: 0.3px;
  273. color: #000000;
  274. max-width: 210px;
  275. text-overflow: ellipsis;
  276. white-space: nowrap;
  277. overflow: hidden;
  278. }
  279. .invited-text {
  280. font-weight: 700;
  281. font-size: 17px;
  282. line-height: 20px;
  283. letter-spacing: 0.3px;
  284. color: #f99d23;
  285. }
  286. }
  287. &-icon-wrap {
  288. display: flex;
  289. flex: 1;
  290. align-items: center;
  291. .mobile-land-page-icon {
  292. width: 100%;
  293. }
  294. }
  295. &-prize-info {
  296. font-style: normal;
  297. font-weight: 700;
  298. font-size: 18px;
  299. line-height: 21px;
  300. color: #000000;
  301. &-test {
  302. display: flex;
  303. align-items: center;
  304. justify-content: center;
  305. .pre-amount-value {
  306. margin-left: 3px;
  307. }
  308. .icon {
  309. width: 22px;
  310. height: 22px;
  311. margin-left: 3px;
  312. }
  313. .prize-name {
  314. margin: 0 3px;
  315. }
  316. }
  317. }
  318. &-tip {
  319. font-weight: 400;
  320. font-size: 13px;
  321. line-height: 16px;
  322. text-align: center;
  323. color: #7b7b7b;
  324. margin-top: 10px;
  325. }
  326. &-login-twitter {
  327. width: 100%;
  328. height: 54px;
  329. margin: 18px 16px 30px;
  330. border-radius: 54px;
  331. background: #1d9bf0;
  332. text-align: center;
  333. line-height: 54px;
  334. font-weight: 700;
  335. font-size: 18px;
  336. text-align: center;
  337. color: #fff;
  338. }
  339. }
  340. </style>