index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <div class="nft-content">
  3. <template v-if="isLoading">
  4. <img class="loading" src="../../static/svg/icon-loading.svg" />
  5. </template>
  6. <template v-else>
  7. <template v-if="isMobile">
  8. <MobileLandPage v-if="isSwipe" :prizePicPath="detail.pageImagePath" :playType="PlayType.NFT" :prize="detail.nftProjectName" :useFul="false" :nftProjectId="detail.nftProjectId"></MobileLandPage>
  9. <mobileBuyNft :purchaseStatus="detail.purchaseStatus" v-else></mobileBuyNft>
  10. </template>
  11. <template v-else>
  12. <div class="logo">
  13. <img src="/img/icon-logo.png" alt />
  14. </div>
  15. <div class="show">
  16. <div class="center">
  17. <div class="img">
  18. <img :src="detail.pageImagePath" />
  19. </div>
  20. <div class="info">
  21. <template v-if="isChrome">
  22. <div class="title">Install DeNet Plugin<br />to Buy NFT</div>
  23. <img class="buy" @click="installExtension" src="../../static/img/icon-install-plugin.svg" />
  24. </template>
  25. <template v-else>
  26. <div class="title">Only Support to Use Chrome to buy NFT</div>
  27. <img class="buy" @click="installChrome" src="../../static/img/icon-install-chrome.svg" />
  28. </template>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. </template>
  34. </div>
  35. </template>
  36. <script>
  37. import axios from 'axios';
  38. import Cookies from 'js-cookie';
  39. import { Toast } from 'vant';
  40. import { isBrowser, appVersionCode } from '../../utils/help.js';
  41. import Report from '@/log-center/log';
  42. import { PlayType } from './../../types';
  43. const api = {
  44. prod: 'https://api.denetme.net',
  45. pre: 'https://preapi.denetme.net',
  46. test: 'https://testapi.denetme.net',
  47. };
  48. const page = {
  49. prod: 'https://h5.denetme.net',
  50. pre: 'https://preh5.denetme.net',
  51. test: 'https://testh5.denetme.net',
  52. };
  53. const jumpUrl = page[process.env.NUXT_ENV.MODE] + '/';
  54. const baseURL = api[process.env.NUXT_ENV.MODE];
  55. const ClipboardJS = require('clipboard');
  56. export default {
  57. name: 'ntf',
  58. data() {
  59. return {
  60. PlayType,
  61. isLoading: true,
  62. appVersionCode: appVersionCode,
  63. jumpUrl: jumpUrl,
  64. detail: {},
  65. config: {},
  66. title: 'DeNet Giveaway',
  67. isMobile: false,
  68. isChrome: false,
  69. isSwipe: false,
  70. linkHref: '',
  71. metaTitle: 'DeNet: An Easy Web3 Tool For GIVEAWAY / AIRDROP',
  72. };
  73. },
  74. head() {
  75. return {
  76. type: '',
  77. title: this.title,
  78. appVersionCode: appVersionCode,
  79. meta: [
  80. // facebook
  81. {
  82. name: 'og:url',
  83. content: this.jumpUrl + 'nft/' + this.$route.params.id + `/${this.$route.params.account}`,
  84. },
  85. {
  86. name: 'og:title',
  87. content: this.metaTitle,
  88. },
  89. {
  90. name: 'og:image',
  91. content: this.detail.linkImagePath || '',
  92. },
  93. // twitter
  94. {
  95. name: 'twitter:card',
  96. content: 'summary_large_image',
  97. },
  98. {
  99. name: 'twitter:url',
  100. content: this.jumpUrl + 'nft/' + this.$route.params.id + `/${this.$route.params.account}`,
  101. },
  102. {
  103. name: 'twitter:title',
  104. content: this.metaTitle,
  105. },
  106. {
  107. name: 'twitter:image',
  108. content: this.detail.linkImagePath || '',
  109. },
  110. ],
  111. };
  112. },
  113. async asyncData(params) {
  114. let { route } = params;
  115. let { data } = await axios.post(`${baseURL}/denet/nft/project/getNftProjectInfo`, {
  116. baseInfo: {
  117. appVersionCode: appVersionCode,
  118. mid: (function () {
  119. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  120. var r = (Math.random() * 16) | 0,
  121. v = c == 'x' ? r : (r & 0x3) | 0x8;
  122. return v.toString(16);
  123. });
  124. })(),
  125. },
  126. params: {
  127. nftProjectId: route.params.id || '',
  128. },
  129. });
  130. if (data.code == 0 && data.data !== null) {
  131. console.log(data.data);
  132. return {
  133. detail: data.data,
  134. };
  135. }
  136. },
  137. created() {
  138. this.setCookieMid();
  139. this.getConfig();
  140. },
  141. mounted() {
  142. this.checkBrowser();
  143. this.setNftInfo();
  144. this.isLoading = false;
  145. var clipboard = new ClipboardJS('.btn');
  146. let that = this;
  147. clipboard.on('success', function (e) {
  148. Toast('copy success');
  149. // 埋点
  150. that.trackingClick();
  151. e.clearSelection();
  152. });
  153. this.pageSource = Report.pageSource.newUserLandingPage;
  154. // 埋点
  155. if (this.isMobile) {
  156. this.pageSource = Report.pageSource.mobileLandingPage;
  157. Report.reportLog({
  158. baseInfo: {
  159. appVersionCode: appVersionCode,
  160. mid: this.mid,
  161. pageSource: this.pageSource,
  162. machineCode: this.mid,
  163. },
  164. params: {
  165. eventData: {
  166. businessType: Report.businessType.pageView,
  167. nftProjectId: this.detail.nftProjectId,
  168. redPacketType: 2,
  169. },
  170. },
  171. });
  172. } else {
  173. Report.reportLog({
  174. baseInfo: {
  175. appVersionCode: appVersionCode,
  176. mid: this.mid,
  177. pageSource: this.pageSource,
  178. machineCode: this.mid,
  179. },
  180. params: {
  181. eventData: {
  182. businessType: Report.businessType.pageView,
  183. nftProjectId: this.detail.nftProjectId,
  184. redPacketType: 2,
  185. },
  186. },
  187. });
  188. }
  189. },
  190. methods: {
  191. trackingClick() {
  192. Report.reportLog({
  193. baseInfo: {
  194. appVersionCode: appVersionCode,
  195. mid: this.mid,
  196. pageSource: this.pageSource,
  197. machineCode: this.mid,
  198. },
  199. params: {
  200. eventData: {
  201. businessType: Report.businessType.buttonClick,
  202. objectType: Report.objectType.installButton,
  203. nftProjectId: this.detail.nftProjectId,
  204. redPacketType: 2,
  205. },
  206. },
  207. });
  208. },
  209. guid() {
  210. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  211. var r = (Math.random() * 16) | 0,
  212. v = c == 'x' ? r : (r & 0x3) | 0x8;
  213. return v.toString(16);
  214. });
  215. },
  216. setCookieMid() {
  217. let _cookie_mid_arr = Cookies.get('mid') || [];
  218. if (_cookie_mid_arr.length > 0) {
  219. this.mid = JSON.parse(_cookie_mid_arr)[0].mid;
  220. } else {
  221. this.mid = this.guid();
  222. Cookies.set('mid', JSON.stringify([{ mid: this.mid }]), { expires: 1000 });
  223. }
  224. },
  225. installExtension() {
  226. // 埋点
  227. this.trackingClick();
  228. let { extensionsInstallUrl } = this.config;
  229. window.open(extensionsInstallUrl);
  230. },
  231. installChrome() {
  232. window.open('https://www.google.com/chrome');
  233. },
  234. async getConfig() {
  235. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  236. baseInfo: {
  237. appVersionCode: appVersionCode,
  238. mid: this.mid,
  239. },
  240. params: {},
  241. });
  242. if (data.code == 0) {
  243. this.config = data.data;
  244. }
  245. },
  246. checkBrowser() {
  247. this.linkHref = window.location.href;
  248. this.isChrome = isBrowser() == 'chrome';
  249. this.isSwipe = this.$route.params.type ? true : false;
  250. this.isMobile = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
  251. },
  252. setNftInfo() {
  253. let nftInfo = {
  254. nftProjectId: this.detail.nftProjectId || '',
  255. twitterAccount: atob(this.$route.params.account || ''),
  256. createTime: Date.now(),
  257. jump_type: 'nft_info',
  258. };
  259. Cookies.set('jump_info', JSON.stringify(nftInfo), { expires: 100 });
  260. },
  261. },
  262. };
  263. </script>
  264. <style lang="scss">
  265. html,
  266. body,
  267. #__nuxt,
  268. #__layout {
  269. width: 100%;
  270. height: 100%;
  271. padding: 0;
  272. margin: 0;
  273. }
  274. .nft-content {
  275. width: 100%;
  276. height: 100%;
  277. background: linear-gradient(180deg, #ffffff 0%, #f0f7fe 94.31%);
  278. .loading {
  279. position: absolute;
  280. transform: translate(-50%, -50%);
  281. top: 50%;
  282. left: 50%;
  283. margin: auto;
  284. width: 40px;
  285. border-radius: 50%;
  286. }
  287. .logo {
  288. display: flex;
  289. align-items: center;
  290. height: 70px;
  291. margin-left: 25px;
  292. img {
  293. width: 99px;
  294. height: 32px;
  295. }
  296. }
  297. .show {
  298. display: flex;
  299. align-items: center;
  300. height: calc(100% - 70px);
  301. .center {
  302. display: flex;
  303. margin: -50px auto 0;
  304. width: 1000px;
  305. .img {
  306. width: 50%;
  307. margin-right: 6%;
  308. img {
  309. width: 100%;
  310. }
  311. }
  312. .info {
  313. display: flex;
  314. flex-direction: column;
  315. justify-content: center;
  316. width: 44%;
  317. .tag {
  318. width: 25%;
  319. margin-bottom: 6px;
  320. }
  321. .title {
  322. color: #3a4b56;
  323. font-size: 2.2vw;
  324. font-family: 'SF Pro Display';
  325. font-weight: bold;
  326. word-break: break-word;
  327. margin-bottom: 1vw;
  328. }
  329. .buy {
  330. width: 75%;
  331. max-width: 263px;
  332. max-height: 64px;
  333. cursor: pointer;
  334. }
  335. }
  336. }
  337. }
  338. }
  339. .small {
  340. padding: 30px 20px;
  341. .banner {
  342. width: 100%;
  343. img {
  344. width: 100%;
  345. }
  346. }
  347. .title {
  348. color: #000000;
  349. font-weight: 600;
  350. font-size: 20px;
  351. text-align: center;
  352. padding: 17px 0 12px;
  353. }
  354. .desc {
  355. color: #8a8a8a;
  356. font-size: 13px;
  357. padding: 0 22px;
  358. word-break: break-all;
  359. text-align: center;
  360. }
  361. .copy {
  362. margin-top: 35px;
  363. button {
  364. width: 100%;
  365. border: 0;
  366. height: 53px;
  367. color: #fff;
  368. font-size: 18px;
  369. font-weight: 700;
  370. border-radius: 55px;
  371. background: #1d9bf0;
  372. }
  373. }
  374. }
  375. </style>