index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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: '00000000-0000-0000-0000-000000000000',
  119. },
  120. params: {
  121. nftProjectId: route.params.id || '',
  122. },
  123. });
  124. if (data.code == 0 && data.data !== null) {
  125. console.log(data.data);
  126. return {
  127. detail: data.data,
  128. };
  129. }
  130. },
  131. created() {
  132. this.setCookieMid();
  133. this.getConfig();
  134. },
  135. mounted() {
  136. this.checkBrowser();
  137. this.setNftInfo();
  138. this.isLoading = false;
  139. var clipboard = new ClipboardJS('.btn');
  140. let that = this;
  141. clipboard.on('success', function (e) {
  142. Toast('copy success');
  143. // 埋点
  144. that.trackingClick();
  145. e.clearSelection();
  146. });
  147. this.pageSource = Report.pageSource.newUserLandingPage;
  148. // 埋点
  149. if (this.isMobile) {
  150. this.pageSource = Report.pageSource.mobileLandingPage;
  151. Report.reportLog({
  152. baseInfo: {
  153. appVersionCode: appVersionCode,
  154. mid: this.mid,
  155. pageSource: this.pageSource,
  156. machineCode: this.mid,
  157. },
  158. params: {
  159. eventData: {
  160. businessType: Report.businessType.pageView,
  161. nftProjectId: this.detail.nftProjectId,
  162. redPacketType: 2,
  163. },
  164. },
  165. });
  166. } else {
  167. Report.reportLog({
  168. baseInfo: {
  169. appVersionCode: appVersionCode,
  170. mid: this.mid,
  171. pageSource: this.pageSource,
  172. machineCode: this.mid,
  173. },
  174. params: {
  175. eventData: {
  176. businessType: Report.businessType.pageView,
  177. nftProjectId: this.detail.nftProjectId,
  178. redPacketType: 2,
  179. },
  180. },
  181. });
  182. }
  183. },
  184. methods: {
  185. trackingClick() {
  186. Report.reportLog({
  187. baseInfo: {
  188. appVersionCode: appVersionCode,
  189. mid: this.mid,
  190. pageSource: this.pageSource,
  191. machineCode: this.mid,
  192. },
  193. params: {
  194. eventData: {
  195. businessType: Report.businessType.buttonClick,
  196. objectType: Report.objectType.installButton,
  197. nftProjectId: this.detail.nftProjectId,
  198. redPacketType: 2,
  199. },
  200. },
  201. });
  202. },
  203. guid() {
  204. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  205. var r = (Math.random() * 16) | 0,
  206. v = c == 'x' ? r : (r & 0x3) | 0x8;
  207. return v.toString(16);
  208. });
  209. },
  210. setCookieMid() {
  211. let _cookie_mid_arr = Cookies.get('mid') || [];
  212. if (_cookie_mid_arr.length > 0) {
  213. this.mid = JSON.parse(_cookie_mid_arr)[0].mid;
  214. } else {
  215. this.mid = this.guid();
  216. Cookies.set('mid', JSON.stringify([{ mid: this.mid }]), { expires: 1000 });
  217. }
  218. },
  219. installExtension() {
  220. // 埋点
  221. this.trackingClick();
  222. let { extensionsInstallUrl } = this.config;
  223. window.open(extensionsInstallUrl);
  224. },
  225. installChrome() {
  226. window.open('https://www.google.com/chrome');
  227. },
  228. async getConfig() {
  229. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  230. baseInfo: {
  231. appVersionCode: appVersionCode,
  232. mid: this.mid,
  233. },
  234. params: {},
  235. });
  236. if (data.code == 0) {
  237. this.config = data.data;
  238. }
  239. },
  240. checkBrowser() {
  241. this.linkHref = window.location.href;
  242. this.isChrome = isBrowser() == 'chrome';
  243. this.isSwipe = this.$route.params.type ? true : false;
  244. 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);
  245. },
  246. setNftInfo() {
  247. let nftInfo = {
  248. nftProjectId: this.detail.nftProjectId || '',
  249. twitterAccount: atob(this.$route.params.account || ''),
  250. createTime: Date.now(),
  251. jump_type: 'nft_info',
  252. };
  253. Cookies.set('jump_info', JSON.stringify(nftInfo), { expires: 100 });
  254. },
  255. },
  256. };
  257. </script>
  258. <style lang="scss">
  259. html,
  260. body,
  261. #__nuxt,
  262. #__layout {
  263. width: 100%;
  264. height: 100%;
  265. padding: 0;
  266. margin: 0;
  267. }
  268. .nft-content {
  269. width: 100%;
  270. height: 100%;
  271. background: linear-gradient(180deg, #ffffff 0%, #f0f7fe 94.31%);
  272. .loading {
  273. position: absolute;
  274. transform: translate(-50%, -50%);
  275. top: 50%;
  276. left: 50%;
  277. margin: auto;
  278. width: 40px;
  279. border-radius: 50%;
  280. }
  281. .logo {
  282. display: flex;
  283. align-items: center;
  284. height: 70px;
  285. margin-left: 25px;
  286. img {
  287. width: 99px;
  288. height: 32px;
  289. }
  290. }
  291. .show {
  292. display: flex;
  293. align-items: center;
  294. height: calc(100% - 70px);
  295. .center {
  296. display: flex;
  297. margin: -50px auto 0;
  298. width: 1000px;
  299. .img {
  300. width: 50%;
  301. margin-right: 6%;
  302. img {
  303. width: 100%;
  304. }
  305. }
  306. .info {
  307. display: flex;
  308. flex-direction: column;
  309. justify-content: center;
  310. width: 44%;
  311. .tag {
  312. width: 25%;
  313. margin-bottom: 6px;
  314. }
  315. .title {
  316. color: #3a4b56;
  317. font-size: 2.2vw;
  318. font-family: 'SF Pro Display';
  319. font-weight: bold;
  320. word-break: break-word;
  321. margin-bottom: 1vw;
  322. }
  323. .buy {
  324. width: 75%;
  325. max-width: 263px;
  326. max-height: 64px;
  327. cursor: pointer;
  328. }
  329. }
  330. }
  331. }
  332. }
  333. .small {
  334. padding: 30px 20px;
  335. .banner {
  336. width: 100%;
  337. img {
  338. width: 100%;
  339. }
  340. }
  341. .title {
  342. color: #000000;
  343. font-weight: 600;
  344. font-size: 20px;
  345. text-align: center;
  346. padding: 17px 0 12px;
  347. }
  348. .desc {
  349. color: #8a8a8a;
  350. font-size: 13px;
  351. padding: 0 22px;
  352. word-break: break-all;
  353. text-align: center;
  354. }
  355. .copy {
  356. margin-top: 35px;
  357. button {
  358. width: 100%;
  359. border: 0;
  360. height: 53px;
  361. color: #fff;
  362. font-size: 18px;
  363. font-weight: 700;
  364. border-radius: 55px;
  365. background: #1d9bf0;
  366. }
  367. }
  368. }
  369. </style>