index.vue 8.1 KB

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