index.vue 8.3 KB

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