MobileLandPage.vue 8.5 KB

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