index.vue 8.6 KB

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