group.vue 10 KB

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