index.vue 8.3 KB

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