index.vue 7.0 KB

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