index.vue 8.0 KB

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