nft.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <div class="nft-content">
  3. <div class="logo">
  4. <img src="/img/icon-logo.png" alt />
  5. </div>
  6. <div class="show">
  7. <img
  8. v-if="isLoading"
  9. class="loading"
  10. src="../static/svg/icon-loading.svg" />
  11. <div class="center" v-else>
  12. <div class="img">
  13. <img :src="detail.pageImagePath" />
  14. </div>
  15. <div class="info">
  16. <img class="tag" src="../static/svg/icon-nft.svg" />
  17. <div class="title">{{detail.nftProjectName}}</div>
  18. <button class="buy" @click="installExtension">Install Denet to Buy</button>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import axios from 'axios'
  26. import Cookies from 'js-cookie'
  27. const api = {
  28. prod: 'https://api.denetme.net',
  29. pre: 'https://preapi.denetme.net',
  30. test: 'https://testapi.denetme.net'
  31. }
  32. const page = {
  33. prod: "https://h5.denetme.net",
  34. pre: "https://preh5.denetme.net",
  35. test: 'https://testh5.denetme.net'
  36. }
  37. const jumpUrl = page[process.env.NUXT_ENV.MODE] + '/'
  38. const baseURL = api[process.env.NUXT_ENV.MODE]
  39. export default {
  40. name: 'ntf',
  41. data() {
  42. return {
  43. isLoading: true,
  44. appVersionCode: 3,
  45. jumpUrl: jumpUrl,
  46. detail: {},
  47. config: {},
  48. title: 'DeNet Giveaway',
  49. metaTitle: 'DeNet: An Easy Web3 Tool For GIVEAWAY / AIRDROP',
  50. }
  51. },
  52. head() {
  53. return {
  54. type: '',
  55. title: this.title,
  56. appVersionCode: 3,
  57. meta: [
  58. // facebook
  59. {
  60. name: 'og:url',
  61. content: this.jumpUrl + 'nft/' + this.$route.params.id
  62. },
  63. {
  64. name: 'og:title',
  65. content: this.metaTitle
  66. },
  67. {
  68. name: 'og:image',
  69. content: this.detail.linkImagePath || ''
  70. },
  71. // twitter
  72. {
  73. name: 'twitter:card',
  74. content: 'summary_large_image'
  75. },
  76. {
  77. name: 'twitter:url',
  78. content: this.jumpUrl + 'nft/' + this.$route.params.id
  79. },
  80. {
  81. name: 'twitter:title',
  82. content: this.metaTitle
  83. },
  84. {
  85. name: 'twitter:image',
  86. content: this.detail.linkImagePath || ''
  87. }
  88. ]
  89. }
  90. },
  91. mounted() {
  92. this.setCookieMid();
  93. this.getConfig();
  94. this.getData();
  95. },
  96. methods: {
  97. getData() {
  98. if (this.$route.params && this.$route.params.id) {
  99. axios.post(`${baseURL}/denet/nft/project/getNftProjectInfo`, {
  100. baseInfo: {
  101. appVersionCode: this.appVersionCode,
  102. mid: this.mid
  103. },
  104. params: {
  105. nftProjectId: this.$route.params.id || ''
  106. }
  107. }).then(res => {
  108. let { code, data } = res.data;
  109. if (code === 0) {
  110. this.detail = data;
  111. this.isLoading = false;
  112. }
  113. })
  114. }
  115. },
  116. guid() {
  117. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  118. var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
  119. return v.toString(16);
  120. });
  121. },
  122. setCookieMid() {
  123. let _cookie_mid_arr = Cookies.get('mid') || []
  124. if (_cookie_mid_arr.length > 0) {
  125. this.mid = JSON.parse(_cookie_mid_arr)[0].mid
  126. } else {
  127. this.mid = this.guid()
  128. Cookies.set('mid', JSON.stringify([{ mid: this.mid }]), { expires: 1000 })
  129. }
  130. },
  131. installExtension() {
  132. let { extensionsInstallUrl } = this.config;
  133. window.open(extensionsInstallUrl)
  134. },
  135. async getConfig() {
  136. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  137. baseInfo: {
  138. appVersionCode: this.appVersionCode,
  139. mid: this.mid
  140. },
  141. params: {}
  142. })
  143. if (data.code == 0) {
  144. this.config = data.data;
  145. }
  146. },
  147. }
  148. }
  149. </script>
  150. <style lang="scss">
  151. html,
  152. body,
  153. #__nuxt,
  154. #__layout {
  155. width: 100%;
  156. height: 100%;
  157. padding: 0;
  158. margin: 0;
  159. }
  160. .nft-content {
  161. overflow: hidden;
  162. width: 100%;
  163. height: 100%;
  164. background: linear-gradient(180deg, #FFFFFF 0%, #F0F7FE 94.31%);
  165. .logo {
  166. display: flex;
  167. align-items: center;
  168. height: 70px;
  169. margin-left: 25px;
  170. img {
  171. width: 99px;
  172. height: 32px;
  173. }
  174. }
  175. .show {
  176. display: flex;
  177. align-items: center;
  178. height: calc(100% - 70px);
  179. .loading {
  180. margin: auto;
  181. width: 40px;
  182. border-radius: 50%;
  183. }
  184. .center {
  185. display: flex;
  186. margin: -50px auto 0;
  187. max-width: 1000px;
  188. .img {
  189. width: 50%;
  190. margin-right: 6%;
  191. img {
  192. width: 100%;
  193. }
  194. }
  195. .info {
  196. display: flex;
  197. flex-direction: column;
  198. justify-content: center;
  199. width: 44%;
  200. .tag {
  201. width: 25%;
  202. margin-bottom: 6px;
  203. }
  204. .title {
  205. font-size: 3.6vw;
  206. font-family: 'SF Pro Display';
  207. font-weight: bold;
  208. word-break: break-word;
  209. }
  210. .buy {
  211. overflow: hidden;
  212. width: 55%;
  213. height: 3.5vw;
  214. border: 0;
  215. margin-top: .6vw;
  216. color: #FFFFFF;
  217. font-size: 1vw;
  218. font-weight: 700;
  219. background: #1D9BF0;
  220. border-radius: 1000px;
  221. }
  222. }
  223. }
  224. }
  225. }
  226. </style>