group.vue 11 KB

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