index.vue 7.9 KB

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