group.vue 10 KB

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