group.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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">
  12. <div class="logo">
  13. <img class="img" src="" />
  14. </div>
  15. <div class="desc">DeNet Core Member Group DeNet Core Member Group</div>
  16. </div>
  17. <div class="title">Open link on PC to Buy NFT</div>
  18. <div class="desc">{{ linkHref }}</div>
  19. <div class="copy">
  20. <button class="btn" :data-clipboard-text="linkHref">Copy Link</button>
  21. </div>
  22. </div>
  23. </template>
  24. <template v-else>
  25. <div class="logo">
  26. <img src="/img/icon-logo.png" alt />
  27. </div>
  28. <div class="show">
  29. <div class="center">
  30. <div class="header">
  31. <div class="core">
  32. <div class="core_logo"><img src="" /></div>
  33. <div class="core_title">DeNet Core Member Group</div>
  34. </div>
  35. <div class="member">
  36. <label>
  37. <img src="../../static/svg/icon-nft-member.svg" />
  38. <span>63 Member</span>
  39. </label>
  40. <label>
  41. <img src="../../static/svg/icon-nft-post.svg" />
  42. <span>37 Posts</span>
  43. </label>
  44. </div>
  45. </div>
  46. <div class="footer">
  47. <template v-if="isChrome">
  48. <div class="font">Install DeNet to Join The Group</div>
  49. <img class="btn" @click="installExtension" src="../../static/svg/icon-install-nft-plugin.svg" />
  50. </template>
  51. <template v-else>
  52. <div class="font">Only Support to Use Chrome<br/>to Join Group</div>
  53. <img class="btn" @click="installChrome" src="../../static/svg/icon-install-nft-chrome.svg" />
  54. </template>
  55. </div>
  56. </div>
  57. </div>
  58. </template>
  59. </template>
  60. </div>
  61. </template>
  62. <script>
  63. import axios from 'axios'
  64. import Cookies from 'js-cookie'
  65. import { Toast } from 'vant';
  66. import { isBrowser } from '../../utils/help.js'
  67. const api = {
  68. prod: 'https://api.denetme.net',
  69. pre: 'https://preapi.denetme.net',
  70. test: 'https://testapi.denetme.net'
  71. }
  72. const page = {
  73. prod: "https://h5.denetme.net",
  74. pre: "https://preh5.denetme.net",
  75. test: 'https://testh5.denetme.net'
  76. }
  77. const jumpUrl = page[process.env.NUXT_ENV.MODE] + '/'
  78. const baseURL = api[process.env.NUXT_ENV.MODE]
  79. const appVersionCode = 6;
  80. const ClipboardJS = require('clipboard')
  81. export default {
  82. name: 'ntf',
  83. data() {
  84. return {
  85. isLoading: true,
  86. appVersionCode: appVersionCode,
  87. jumpUrl: jumpUrl,
  88. detail: {},
  89. config: {},
  90. title: 'DeNet Giveaway',
  91. isMobile: false,
  92. isChrome: false,
  93. linkHref: '',
  94. metaTitle: 'DeNet: An Easy Web3 Tool For GIVEAWAY / AIRDROP',
  95. }
  96. },
  97. head() {
  98. return {
  99. type: '',
  100. title: this.title,
  101. appVersionCode: appVersionCode,
  102. meta: [
  103. // facebook
  104. {
  105. name: 'og:url',
  106. content: this.jumpUrl + 'nft/' + this.$route.params.id
  107. },
  108. {
  109. name: 'og:title',
  110. content: this.metaTitle
  111. },
  112. {
  113. name: 'og:image',
  114. content: this.detail.linkImagePath || ''
  115. },
  116. // twitter
  117. {
  118. name: 'twitter:card',
  119. content: 'summary_large_image'
  120. },
  121. {
  122. name: 'twitter:url',
  123. content: this.jumpUrl + 'nft/' + this.$route.params.id
  124. },
  125. {
  126. name: 'twitter:title',
  127. content: this.metaTitle
  128. },
  129. {
  130. name: 'twitter:image',
  131. content: this.detail.linkImagePath || ''
  132. }
  133. ]
  134. }
  135. },
  136. async asyncData(params) {
  137. let { route } = params;
  138. let { data } = await axios.post(`${baseURL}/denet/nft/project/getNftProjectInfo`, {
  139. baseInfo: {
  140. appVersionCode: appVersionCode,
  141. mid: function () {
  142. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  143. var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
  144. return v.toString(16);
  145. });
  146. }()
  147. },
  148. params: {
  149. nftProjectId: route.params.id || ''
  150. }
  151. })
  152. if (data.code == 0 && data.data !== null) {
  153. return {
  154. detail: data.data,
  155. }
  156. }
  157. },
  158. created() {
  159. this.setCookieMid();
  160. this.getConfig();
  161. },
  162. mounted() {
  163. this.checkBrowser();
  164. this.setNftInfo();
  165. this.isLoading = false;
  166. var clipboard = new ClipboardJS('.btn');
  167. clipboard.on('success', function (e) {
  168. Toast('copy success');
  169. e.clearSelection();
  170. });
  171. },
  172. methods: {
  173. guid() {
  174. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  175. var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
  176. return v.toString(16);
  177. });
  178. },
  179. setCookieMid() {
  180. let _cookie_mid_arr = Cookies.get('mid') || []
  181. if (_cookie_mid_arr.length > 0) {
  182. this.mid = JSON.parse(_cookie_mid_arr)[0].mid
  183. } else {
  184. this.mid = this.guid()
  185. Cookies.set('mid', JSON.stringify([{ mid: this.mid }]), { expires: 1000 })
  186. }
  187. },
  188. installExtension() {
  189. let { extensionsInstallUrl } = this.config;
  190. window.open(extensionsInstallUrl)
  191. },
  192. installChrome() {
  193. window.open('https://www.google.com/chrome')
  194. },
  195. async getConfig() {
  196. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  197. baseInfo: {
  198. appVersionCode: appVersionCode,
  199. mid: this.mid
  200. },
  201. params: {}
  202. })
  203. if (data.code == 0) {
  204. this.config = data.data;
  205. }
  206. },
  207. checkBrowser() {
  208. this.linkHref = window.location.href;
  209. this.isChrome = isBrowser() == 'chrome';
  210. 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);
  211. },
  212. setNftInfo() {
  213. let nftInfo = {
  214. nftProjectId: this.detail.nftProjectId,
  215. twitterAccount: atob(this.$route.params.account || ''),
  216. createTime: Date.now(),
  217. };
  218. Cookies.set('nft_info', JSON.stringify(nftInfo), { expires: 100 });
  219. },
  220. }
  221. }
  222. </script>
  223. <style lang="scss">
  224. html,
  225. body,
  226. #__nuxt,
  227. #__layout {
  228. width: 100%;
  229. height: 100%;
  230. padding: 0;
  231. margin: 0;
  232. }
  233. .nft-content {
  234. overflow: hidden;
  235. width: 100%;
  236. height: 100%;
  237. background: linear-gradient(180deg, #FFFFFF 0%, #F0F7FE 94.31%);
  238. .loading {
  239. position: absolute;
  240. transform: translate(-50%, -50%);
  241. top: 50%;
  242. left: 50%;
  243. margin: auto;
  244. width: 40px;
  245. border-radius: 50%;
  246. }
  247. .logo {
  248. display: flex;
  249. align-items: center;
  250. height: 70px;
  251. margin-left: 25px;
  252. img {
  253. width: 99px;
  254. height: 32px;
  255. }
  256. }
  257. .show {
  258. display: flex;
  259. align-items: center;
  260. height: calc(100% - 70px);
  261. .center {
  262. display: flex;
  263. flex-direction: column;
  264. width: 505px;
  265. margin: -50px auto 0;
  266. .header {
  267. display: flex;
  268. flex-direction: column;
  269. width: 100%;
  270. height: 180px;
  271. padding-left: 25px;
  272. justify-content: center;
  273. border-radius: 16px 16px 0 0;
  274. background: url('../../static/svg/icon-nft-group-pc.svg') no-repeat right bottom #48B1F7;
  275. .core {
  276. display: flex;
  277. align-items: center;
  278. .core_logo {
  279. width: 54px;
  280. height: 54px;
  281. border-radius: 6px;
  282. background-color: #fff;
  283. }
  284. .core_title {
  285. color: #fff;
  286. font-size: 26px;
  287. font-weight: 700;
  288. margin-left: 16px;
  289. }
  290. }
  291. .member {
  292. color: #fff;
  293. font-size: 12px;
  294. font-weight: 500;
  295. margin-top: 24px;
  296. label {
  297. margin-right: 17px;
  298. img {
  299. margin-top: -3px;
  300. vertical-align: middle;
  301. }
  302. }
  303. }
  304. }
  305. .footer {
  306. display: flex;
  307. align-items: center;
  308. flex-direction: row;
  309. justify-content: space-between;
  310. width: 100%;
  311. height: 90px;
  312. border-radius: 0 0 16px 16px;
  313. border: solid 1px #E2E2E2;
  314. .font {
  315. flex: 1;
  316. text-align: center;
  317. font-size: 16px;
  318. font-weight: 500;
  319. }
  320. .btn {
  321. width: 200px;
  322. box-sizing: unset;
  323. }
  324. }
  325. }
  326. }
  327. }
  328. .small {
  329. position: absolute;
  330. top: 40%;
  331. width: 100%;
  332. padding: 0 16px;
  333. box-sizing: border-box;
  334. transform: translateY(-50%);
  335. .banner {
  336. position: relative;
  337. overflow: hidden;
  338. height: 180px;
  339. border-radius: 10px;
  340. background: url('../../static/svg/icon-nft-group-mobile.svg') no-repeat right bottom #48B1F7;
  341. .logo {
  342. position: absolute;
  343. display: flex;
  344. align-items: center;
  345. justify-content: center;
  346. z-index: 2;
  347. margin: 0;
  348. top: 38px;
  349. left: 50%;
  350. width: 54px;
  351. height: 54px;
  352. transform: translateX(-50%);
  353. border-radius: 5px;
  354. background-color: #FFFFFF;
  355. .img {
  356. position: unset;
  357. width: 50px;
  358. height: 50px;
  359. }
  360. }
  361. .desc {
  362. position: absolute;
  363. z-index: 2;
  364. top: 115px;
  365. width: 100%;
  366. color: #FFFFFF;
  367. font-weight: 600;
  368. font-size: 20px;
  369. padding: 0 12px;
  370. line-height: 24px;
  371. text-align: center;
  372. box-sizing: border-box;
  373. word-break: break-all;
  374. text-overflow: ellipsis;
  375. display: -webkit-box;
  376. -webkit-box-orient: vertical;
  377. -webkit-line-clamp: 2;
  378. overflow: hidden;
  379. }
  380. }
  381. .title {
  382. color: #000000;
  383. font-weight: 600;
  384. font-size: 20px;
  385. text-align: center;
  386. padding: 39px 0 7px;
  387. }
  388. .desc {
  389. color: #8A8A8A;
  390. font-size: 13px;
  391. padding: 0 22px;
  392. word-break: break-all;
  393. text-align: center;
  394. }
  395. .copy {
  396. margin-top: 35px;
  397. button {
  398. width: 100%;
  399. border: 0;
  400. height: 53px;
  401. color: #fff;
  402. font-size: 18px;
  403. font-weight: 700;
  404. border-radius: 55px;
  405. background: #1D9BF0;
  406. }
  407. }
  408. }
  409. </style>