MobileLandPage.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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 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. };
  137. },
  138. computed: {
  139. isCustomRewardCpd() {
  140. return this.rewardType === RewardType.custom;
  141. },
  142. isLottaryCpd() {
  143. return this.playType === PlayType.lottery;
  144. },
  145. isCommonCpd() {
  146. return this.playType === PlayType.common;
  147. },
  148. isTreasureCpd() {
  149. return this.playType === PlayType.Treasure;
  150. },
  151. isNFTCpd() {
  152. return this.playType === PlayType.NFT;
  153. },
  154. iconCpd() {
  155. if (!this.useFul) {
  156. return overTimePic;
  157. } else if (this.isCommonCpd) {
  158. return giveawayPic;
  159. } else if (this.isLottaryCpd) {
  160. return redpackPic;
  161. } else if (this.isTreasureCpd) {
  162. return treasurePic;
  163. } else if (this.isNFTCpd) {
  164. return this.prizePicPath;
  165. }
  166. {
  167. return overTimePic;
  168. }
  169. },
  170. tipCpd() {
  171. if (this.isCommonCpd) {
  172. return 'to claim, log in twitter to install Denet Chrome Extension';
  173. } else if (this.isLottaryCpd) {
  174. return 'To participate, login Twitter to install DeNet Chrome Extension';
  175. } else if (this.isTreasureCpd) {
  176. return 'To complete, log in twitter to install Denet Chrome Extension';
  177. } else {
  178. return 'login Twitter to install DeNet Chrome Extension';
  179. }
  180. },
  181. },
  182. methods: {
  183. toLogin() {
  184. let userInfo = getStorage(storageKey.userInfo);
  185. if (userInfo) {
  186. location.href = `/course?useful=${this.useFul ? '0' : '1'}&playType=${this.playType}&rewardType=${this.rewardType}&postId=${this.postId}`;
  187. } else {
  188. this.twitterAuth();
  189. }
  190. },
  191. async twitterAuth() {
  192. postRequest(`/denet/user/twitterRequestToken`, {
  193. params: {
  194. oauthCallback: `${location.protocol}//${location.host}/authlogin`,
  195. },
  196. }).then(({ code, data }) => {
  197. if (code == 0) {
  198. console.log('%c [ data ]-78', 'font-size:13px; background:pink; color:#bf2c9f;', data);
  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. console.log('%c [ data ]-100', 'font-size:13px; background:pink; color:#bf2c9f;', data);
  222. setStorage(storageKey.userInfo, data);
  223. removeStorage(storageKey.verifier);
  224. }
  225. });
  226. }
  227. },
  228. },
  229. components: { FontZoom },
  230. };
  231. </script>
  232. <style lang="scss" scoped>
  233. .mobile-land-page {
  234. min-height: 100vh;
  235. max-height: 100vh;
  236. background: linear-gradient(180deg, #cceaff 0%, #ffffff 70.42%);
  237. display: flex;
  238. flex-direction: column;
  239. justify-content: space-between;
  240. align-items: center;
  241. padding: 0 16px;
  242. &-invited-info {
  243. width: 302px;
  244. height: 72px;
  245. margin-top: 28px;
  246. position: relative;
  247. padding-left: 81px;
  248. border-radius: 35px;
  249. display: flex;
  250. flex-direction: column;
  251. align-items: flex-start;
  252. justify-content: flex-start;
  253. background: #ffffff;
  254. border: 1px solid #c0daeb;
  255. .invited-photo {
  256. width: 70px;
  257. height: 70px;
  258. border-radius: 50%;
  259. position: absolute;
  260. left: 0;
  261. top: 0;
  262. }
  263. .invited-name {
  264. margin: 13px 0 5px;
  265. font-weight: 500;
  266. font-size: 13px;
  267. line-height: 16px;
  268. letter-spacing: 0.3px;
  269. color: #000000;
  270. max-width: 210px;
  271. text-overflow: ellipsis;
  272. white-space: nowrap;
  273. overflow: hidden;
  274. }
  275. .invited-text {
  276. font-weight: 700;
  277. font-size: 17px;
  278. line-height: 20px;
  279. letter-spacing: 0.3px;
  280. color: #f99d23;
  281. }
  282. }
  283. &-icon-wrap {
  284. display: flex;
  285. flex: 1;
  286. align-items: center;
  287. .mobile-land-page-icon {
  288. width: 100%;
  289. }
  290. }
  291. &-prize-info {
  292. font-style: normal;
  293. font-weight: 700;
  294. font-size: 18px;
  295. line-height: 21px;
  296. color: #000000;
  297. &-test {
  298. display: flex;
  299. align-items: center;
  300. justify-content: center;
  301. .pre-amount-value {
  302. margin-left: 3px;
  303. }
  304. .icon {
  305. width: 22px;
  306. height: 22px;
  307. margin-left: 3px;
  308. }
  309. .prize-name {
  310. margin: 0 3px;
  311. }
  312. }
  313. }
  314. &-tip {
  315. font-weight: 400;
  316. font-size: 13px;
  317. line-height: 16px;
  318. text-align: center;
  319. color: #7b7b7b;
  320. margin-top: 10px;
  321. }
  322. &-login-twitter {
  323. width: 100%;
  324. height: 54px;
  325. margin: 18px 16px 30px;
  326. border-radius: 54px;
  327. background: #1d9bf0;
  328. text-align: center;
  329. line-height: 54px;
  330. font-weight: 700;
  331. font-size: 18px;
  332. text-align: center;
  333. color: #fff;
  334. }
  335. }
  336. </style>