group.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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: '00000000-0000-0000-0000-000000000000',
  143. },
  144. params: {
  145. postId: route.params.id || '',
  146. },
  147. });
  148. if (data.code == 0 && data.data !== null) {
  149. return {
  150. detail: data.data,
  151. postBizData: JSON.parse(data.data.postBizData),
  152. };
  153. }
  154. },
  155. created() {
  156. this.setCookieMid();
  157. this.getConfig();
  158. },
  159. mounted() {
  160. this.checkBrowser();
  161. this.setNftInfo();
  162. this.isLoading = false;
  163. var clipboard = new ClipboardJS('.btn');
  164. let that = this;
  165. clipboard.on('success', function (e) {
  166. Toast('copy success');
  167. that.trackingClick();
  168. e.clearSelection();
  169. });
  170. // 埋点
  171. this.pageSource = Report.pageSource.newUserLandingPage;
  172. if (this.isMobile) {
  173. this.pageSource = Report.pageSource.mobileLandingPage;
  174. }
  175. Report.reportLog({
  176. baseInfo: {
  177. appVersionCode: appVersionCode,
  178. mid: this.mid,
  179. pageSource: this.pageSource,
  180. appType,
  181. machineCode: this.mid,
  182. },
  183. params: {
  184. eventData: {
  185. businessType: Report.businessType.pageView,
  186. postId: this.detail.postId,
  187. srcContentId: this.detail.srcContentId,
  188. senderId: this.detail.srcUserId,
  189. redPacketType: 3,
  190. },
  191. },
  192. });
  193. },
  194. methods: {
  195. trackingClick() {
  196. Report.reportLog({
  197. baseInfo: {
  198. appVersionCode: appVersionCode,
  199. mid: this.mid,
  200. pageSource: this.pageSource,
  201. appType,
  202. machineCode: this.mid,
  203. },
  204. params: {
  205. eventData: {
  206. businessType: Report.businessType.buttonClick,
  207. postId: this.detail.postId,
  208. objectType: Report.objectType.copyLinkButton,
  209. srcContentId: this.detail.srcContentId,
  210. senderId: this.detail.srcUserId,
  211. redPacketType: 3,
  212. },
  213. },
  214. });
  215. },
  216. guid() {
  217. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  218. var r = (Math.random() * 16) | 0,
  219. v = c == 'x' ? r : (r & 0x3) | 0x8;
  220. return v.toString(16);
  221. });
  222. },
  223. setCookieMid() {
  224. let _cookie_mid_arr = Cookies.get('mid') || [];
  225. if (_cookie_mid_arr.length > 0) {
  226. this.mid = JSON.parse(_cookie_mid_arr)[0].mid;
  227. } else {
  228. this.mid = this.guid();
  229. Cookies.set('mid', JSON.stringify([{ mid: this.mid }]), { expires: 1000 });
  230. }
  231. },
  232. installExtension() {
  233. // 埋点
  234. this.trackingClick();
  235. let { extensionsInstallUrl } = this.config;
  236. window.open(extensionsInstallUrl);
  237. },
  238. installChrome() {
  239. window.open('https://www.google.com/chrome');
  240. },
  241. async getConfig() {
  242. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  243. baseInfo: {
  244. appVersionCode: appVersionCode,
  245. mid: this.mid,
  246. },
  247. params: {},
  248. });
  249. if (data.code == 0) {
  250. this.config = data.data;
  251. }
  252. },
  253. checkBrowser() {
  254. this.linkHref = window.location.href;
  255. this.isChrome = isBrowser() == 'chrome';
  256. 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);
  257. },
  258. setNftInfo() {
  259. let nftGroupInfo = {
  260. twitterAccount: this.postBizData.defaultTwitterAccount || '',
  261. createTime: Date.now(),
  262. jump_type: 'nft_group_info',
  263. postId: this.detail.postId || '',
  264. };
  265. Cookies.set('jump_info', JSON.stringify(nftGroupInfo), { expires: 100 });
  266. },
  267. },
  268. };
  269. </script>
  270. <style lang="scss">
  271. html,
  272. body,
  273. #__nuxt,
  274. #__layout {
  275. width: 100%;
  276. height: 100%;
  277. padding: 0;
  278. margin: 0;
  279. }
  280. .nft-content {
  281. overflow: hidden;
  282. width: 100%;
  283. height: 100%;
  284. background: linear-gradient(180deg, #ffffff 0%, #f0f7fe 94.31%);
  285. .loading {
  286. position: absolute;
  287. transform: translate(-50%, -50%);
  288. top: 50%;
  289. left: 50%;
  290. margin: auto;
  291. width: 40px;
  292. border-radius: 50%;
  293. }
  294. .logo {
  295. display: flex;
  296. align-items: center;
  297. height: 70px;
  298. margin-left: 25px;
  299. img {
  300. width: 99px;
  301. height: 32px;
  302. }
  303. }
  304. .show {
  305. display: flex;
  306. align-items: center;
  307. height: calc(100% - 70px);
  308. .center {
  309. display: flex;
  310. flex-direction: column;
  311. width: 505px;
  312. margin: -50px auto 0;
  313. .header {
  314. display: flex;
  315. flex-direction: column;
  316. width: 100%;
  317. height: 180px;
  318. padding-left: 25px;
  319. justify-content: center;
  320. border-radius: 16px 16px 0 0;
  321. background: url('../../static/svg/icon-nft-group-pc.svg') no-repeat right bottom #48b1f7;
  322. .core {
  323. display: flex;
  324. align-items: center;
  325. .core_logo {
  326. overflow: hidden;
  327. width: 54px;
  328. height: 54px;
  329. border-radius: 6px;
  330. background-color: #fff;
  331. img {
  332. width: 100%;
  333. height: 100%;
  334. border-radius: 8px;
  335. }
  336. }
  337. .core_title {
  338. color: #fff;
  339. font-size: 26px;
  340. font-weight: 700;
  341. margin-left: 16px;
  342. }
  343. }
  344. .member {
  345. color: #fff;
  346. font-size: 12px;
  347. font-weight: 500;
  348. margin-top: 24px;
  349. label {
  350. margin-right: 17px;
  351. img {
  352. margin-top: -3px;
  353. vertical-align: middle;
  354. }
  355. }
  356. }
  357. }
  358. .footer {
  359. display: flex;
  360. align-items: center;
  361. flex-direction: row;
  362. justify-content: space-between;
  363. width: 100%;
  364. height: 90px;
  365. border-radius: 0 0 16px 16px;
  366. border: solid 1px #e2e2e2;
  367. .font {
  368. flex: 1;
  369. text-align: center;
  370. font-size: 16px;
  371. font-weight: 500;
  372. }
  373. .btn {
  374. width: 200px;
  375. box-sizing: unset;
  376. }
  377. }
  378. }
  379. }
  380. }
  381. .small {
  382. position: absolute;
  383. top: 40%;
  384. width: 100%;
  385. padding: 0 16px;
  386. box-sizing: border-box;
  387. transform: translateY(-50%);
  388. .banner {
  389. position: relative;
  390. overflow: hidden;
  391. height: 180px;
  392. border-radius: 10px;
  393. background: url('../../static/svg/icon-nft-group-mobile.svg') no-repeat right bottom #48b1f7;
  394. .logo {
  395. position: absolute;
  396. display: flex;
  397. align-items: center;
  398. justify-content: center;
  399. z-index: 2;
  400. margin: 0;
  401. top: 38px;
  402. left: 50%;
  403. width: 54px;
  404. height: 54px;
  405. transform: translateX(-50%);
  406. border-radius: 5px;
  407. background-color: #ffffff;
  408. .img {
  409. position: unset;
  410. width: 50px;
  411. height: 50px;
  412. border-radius: 5px;
  413. }
  414. }
  415. .desc {
  416. position: absolute;
  417. z-index: 2;
  418. top: 115px;
  419. width: 100%;
  420. color: #ffffff;
  421. font-weight: 600;
  422. font-size: 20px;
  423. padding: 0 12px;
  424. line-height: 24px;
  425. text-align: center;
  426. box-sizing: border-box;
  427. word-break: break-all;
  428. text-overflow: ellipsis;
  429. display: -webkit-box;
  430. -webkit-box-orient: vertical;
  431. -webkit-line-clamp: 2;
  432. overflow: hidden;
  433. }
  434. }
  435. .title {
  436. color: #000000;
  437. font-weight: 600;
  438. font-size: 20px;
  439. text-align: center;
  440. padding: 39px 0 7px;
  441. }
  442. .desc {
  443. color: #8a8a8a;
  444. font-size: 13px;
  445. padding: 0 22px;
  446. word-break: break-all;
  447. text-align: center;
  448. }
  449. .copy {
  450. margin-top: 35px;
  451. button {
  452. width: 100%;
  453. border: 0;
  454. height: 53px;
  455. color: #fff;
  456. font-size: 18px;
  457. font-weight: 700;
  458. border-radius: 55px;
  459. background: #1d9bf0;
  460. }
  461. }
  462. }
  463. </style>