nft.vue 5.7 KB

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