group.vue 12 KB

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