index.vue 8.2 KB

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