index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. <template>
  2. <div class="main">
  3. <!-- pc -->
  4. <template v-if="device == 'chrome' || device == 'no-chrome'">
  5. <div class="content">
  6. <div></div><div></div><div></div>
  7. <div class="twCard" ref="twCard">
  8. <div class="twLine" :style=" { zoom: scale } ">
  9. <div class="twTitle">
  10. <div class="twHead">
  11. <img :src="userInfo.avatarUrl" />
  12. </div>
  13. <div class="twName">
  14. <span><strong>@{{ detail.srcUserId }}</strong></span>
  15. </div>
  16. </div>
  17. <div class="twShow">
  18. <div class="showTit">{{ detail.postBizData.linkTitle || '' }}</div>
  19. <div class="showImg">
  20. <img :src="detail.postBizData.viewBgImagePath" />
  21. </div>
  22. </div>
  23. </div>
  24. <img src="../../static/img/img-card-bg.png" />
  25. </div>
  26. <div class="twInfo">
  27. <div class="title">
  28. <span>{{ detail.postBizData.linkTitle || '' }}</span>
  29. </div>
  30. <div class="invitation">
  31. <template v-if="device == 'no-chrome'">
  32. <install-chrome :imgUrl=" require('../../static/img/img-chrome.svg') "></install-chrome>
  33. </template>
  34. <template v-if="device == 'chrome'">
  35. <install-extension :imgUrl=" require('../../static/img/img-no-chrome.svg') " :extensionsInstallUrl="config.extensionsInstallUrl" @installClick="installClick"></install-extension>
  36. </template>
  37. <img class="hand" src="../../static/img/img-hand.png" />
  38. </div>
  39. <div class="detail" @click="goOriginLink" v-if="detail.postBizData.certNftProjectId">Visit the original page</div>
  40. </div>
  41. <div></div><div></div><div></div>
  42. </div>
  43. </template>
  44. <div class="mask" v-if="showLoading">
  45. <van-loading color="#ffffff" size="40"></van-loading>
  46. <div class="text">Jumping to the original page, please wait a few seconds</div>
  47. </div>
  48. <!-- 移动端 -->
  49. <div v-if="device == 'ios' || device == '安卓'" class="mobile">
  50. <div class="mobile-content">
  51. <img :src="detail.postBizData.linkImagePath" alt="" />
  52. <div class="title">Open link on PC to use Subway Surfers</div>
  53. </div>
  54. <div class="area-button">
  55. <div class="btn1" @click="clickExtension">Install Chrome Extension</div>
  56. <div class="btn2" @click="clickCopy" :data-clipboard-text="copy_link">Copy Link</div>
  57. </div>
  58. </div>
  59. </div>
  60. </template>
  61. <script>
  62. import VLogo from '@/components/logo.vue';
  63. import InstallChrome from '@/components/InstallChrome.vue';
  64. import InstallExtension from '@/components/InstallExtension.vue';
  65. import { getBrowserType, baseURL, appVersionCode, jumpUrl, appType } from '@/utils/help.js';
  66. import axios from 'axios';
  67. import Cookies from 'js-cookie';
  68. import { Toast } from 'vant';
  69. import Report from '@/log-center/log';
  70. var ClipboardJS = require('clipboard');
  71. export default {
  72. name: 'tool_box',
  73. data() {
  74. return {
  75. config: {},
  76. copy_link: '',
  77. title: 'Install DeNet Plugin to Participate',
  78. metaTitle: 'Install DeNet Plugin to Participate',
  79. device: '',
  80. detail: {},
  81. mid: '',
  82. pageSource: '',
  83. img_url: '',
  84. scale: 1,
  85. userInfo: {},
  86. showLoading: false,
  87. };
  88. },
  89. head() {
  90. return {
  91. type: '',
  92. title: this.title,
  93. appVersionCode: appVersionCode,
  94. meta: [
  95. // facebook
  96. {
  97. name: 'og:url',
  98. content: jumpUrl + 'toolbox/' + this.$route.params.id,
  99. },
  100. {
  101. name: 'og:title',
  102. content: this.metaTitle,
  103. },
  104. {
  105. name: 'og:image',
  106. content: this.detail.postBizData.linkImagePath || '',
  107. },
  108. // twitter
  109. {
  110. name: 'twitter:card',
  111. content: 'summary_large_image',
  112. },
  113. {
  114. name: 'twitter:url',
  115. content: jumpUrl + 'toolbox/' + this.$route.params.id,
  116. },
  117. {
  118. name: 'twitter:title',
  119. content: this.detail.postBizData.linkTitle || this.metaTitle,
  120. },
  121. {
  122. name: 'twitter:image',
  123. content: this.detail.postBizData.linkImagePath || '',
  124. },
  125. ],
  126. };
  127. },
  128. components: {
  129. VLogo,
  130. InstallChrome,
  131. InstallExtension,
  132. },
  133. async asyncData(params) {
  134. let { route } = params;
  135. let { data } = await axios.post(`${baseURL}/denet/post/getDetail`, {
  136. baseInfo: {
  137. appVersionCode: appVersionCode,
  138. mid: '00000000-0000-0000-0000-000000000000',
  139. },
  140. params: {
  141. postId: route.params.id || '',
  142. },
  143. });
  144. if (data.code == 0) {
  145. if (data.data && data.data.postBizData && typeof data.data.postBizData == 'string') {
  146. data.data.postBizData = JSON.parse(data.data.postBizData);
  147. }
  148. if (data.data.postBizData === null) {
  149. data.data.postBizData = {
  150. postUserInfo: {},
  151. };
  152. }
  153. console.log('detail', data.data);
  154. return {
  155. detail: data.data,
  156. };
  157. }
  158. },
  159. created() {
  160. this.$nextTick(() => {
  161. this.mobileLink();
  162. })
  163. },
  164. mounted() {
  165. if (this.detail.postBizData.linkImagePath.indexOf('default') > 0) {
  166. this.img_url = '/img/img-default.png';
  167. } else {
  168. this.img_url = this.detail.postBizData.linkImagePath;
  169. }
  170. let that = this;
  171. this.pageSource = Report.pageSource.newUserLandingPage;
  172. this.setCookieMid();
  173. this.device = getBrowserType();
  174. if (this.device == 'ios' || this.device == '安卓') {
  175. Report.reportLog({
  176. baseInfo: {
  177. appVersionCode: appVersionCode,
  178. mid: this.mid,
  179. pageSource: Report.pageSource.mobileLandingPage,
  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. redPacketType: 5,
  189. nftProjectId: this.detail.postBizData.certNftProjectId,
  190. postEditorUrl: this.detail.postBizData.convertUrl,
  191. },
  192. },
  193. });
  194. } else {
  195. Report.reportLog({
  196. baseInfo: {
  197. appVersionCode: appVersionCode,
  198. mid: this.mid,
  199. pageSource: this.pageSource,
  200. appType,
  201. machineCode: this.mid,
  202. },
  203. params: {
  204. eventData: {
  205. businessType: Report.businessType.pageView,
  206. postId: this.detail.postId,
  207. srcContentId: this.detail.srcContentId,
  208. redPacketType: 5,
  209. postEditorUrl: this.detail.postBizData.convertUrl,
  210. },
  211. },
  212. });
  213. }
  214. this.copy_link = window.location.href;
  215. this.getConfig();
  216. this.getUserInfo();
  217. console.log('device', this.device);
  218. if (this.device == 'chrome') {
  219. this.setCookie();
  220. }
  221. // 计算缩放
  222. this.sumScale();
  223. window.onresize = function() {
  224. that.sumScale();
  225. }
  226. },
  227. methods: {
  228. installClick() {
  229. Report.reportLog({
  230. baseInfo: {
  231. appVersionCode: appVersionCode,
  232. mid: this.mid,
  233. pageSource: this.pageSource,
  234. appType,
  235. machineCode: this.mid,
  236. },
  237. params: {
  238. eventData: {
  239. businessType: Report.businessType.buttonClick,
  240. objectType: Report.objectType.installButton,
  241. postId: this.detail.postId,
  242. srcContentId: this.detail.srcContentId,
  243. redPacketType: 5,
  244. postEditorUrl: this.detail.postBizData.convertUrl,
  245. },
  246. },
  247. });
  248. },
  249. guid() {
  250. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  251. var r = (Math.random() * 16) | 0,
  252. v = c == 'x' ? r : (r & 0x3) | 0x8;
  253. return v.toString(16);
  254. });
  255. },
  256. setCookieMid() {
  257. let _cookie_mid_arr = Cookies.get('mid') || [];
  258. if (_cookie_mid_arr.length > 0) {
  259. this.mid = JSON.parse(_cookie_mid_arr)[0].mid;
  260. } else {
  261. this.mid = this.guid();
  262. Cookies.set('mid', JSON.stringify([{ mid: this.mid }]), { expires: 1000 });
  263. }
  264. },
  265. setCookie() {
  266. let pickupInfo = {
  267. srcContentId: this.detail.srcContentId || '',
  268. postNickName: this.detail.srcUserId || '',
  269. createTime: Date.now(),
  270. jump_type: 'tool_box',
  271. };
  272. Cookies.set('jump_info', JSON.stringify(pickupInfo), { expires: 1000 });
  273. },
  274. async getConfig() {
  275. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  276. baseInfo: {
  277. appVersionCode: this.appVersionCode,
  278. mid: this.mid,
  279. },
  280. params: {},
  281. });
  282. if (data.code == 0) {
  283. this.config = data.data;
  284. }
  285. },
  286. async getUserInfo() {
  287. let { data } = await axios.post(`${baseURL}/denet/user/getUserInfo`, {
  288. baseInfo: {
  289. appVersionCode: this.appVersionCode,
  290. mid: this.mid,
  291. },
  292. params: {
  293. uid: this.detail.uid
  294. },
  295. });
  296. if (data.code == 0) {
  297. this.userInfo = data.data;
  298. }
  299. },
  300. clickCopy() {
  301. // 复制链接
  302. var clipboard = new ClipboardJS('.btn2');
  303. clipboard.on('success', function (e) {
  304. Toast('copy success');
  305. e.clearSelection();
  306. });
  307. clipboard.on('error', function () {
  308. Toast('copy error');
  309. });
  310. Report.reportLog({
  311. baseInfo: {
  312. appVersionCode: appVersionCode,
  313. mid: this.mid,
  314. pageSource: Report.pageSource.mobileLandingPage,
  315. appType,
  316. machineCode: this.mid,
  317. },
  318. params: {
  319. eventData: {
  320. businessType: Report.businessType.buttonClick,
  321. objectType: Report.objectType.copyLinkButton,
  322. postId: this.detail.postId,
  323. srcContentId: this.detail.srcContentId,
  324. redPacketType: 5,
  325. nftProjectId: this.detail.postBizData.certNftProjectId,
  326. postEditorUrl: this.detail.postBizData.convertUrl,
  327. },
  328. },
  329. });
  330. },
  331. clickExtension() {
  332. window.open(this.config.extensionsInstallUrl);
  333. },
  334. sumScale() {
  335. if (this.device == 'chrome' || this.device == 'no-chrome') {
  336. this.$nextTick(() => {
  337. let obj = this.$refs.twCard;
  338. if (obj && obj.offsetWidth) {
  339. this.scale = obj.offsetWidth / 680;
  340. } else {
  341. setTimeout(() => {
  342. this.sumScale()
  343. }, 200)
  344. }
  345. })
  346. }
  347. },
  348. goOriginLink() {
  349. if (this.detail.postBizData.originUrl) {
  350. window.open(this.detail.postBizData.originUrl)
  351. }
  352. },
  353. mobileLink() {
  354. if (this.device == 'ios' || this.device == '安卓') {
  355. this.showLoading = true;
  356. if (!('certNftProjectId' in this.detail.postBizData)) {
  357. if (this.detail.postBizData.originUrl) {
  358. window.location.href = this.detail.postBizData.originUrl
  359. } else {
  360. setTimeout(() => {
  361. this.mobileLink()
  362. }, 200)
  363. }
  364. } else {
  365. this.showLoading = false;
  366. }
  367. }
  368. },
  369. },
  370. };
  371. </script>
  372. <style lang="scss">
  373. html,
  374. body,
  375. #__nuxt,
  376. #__layout {
  377. margin: 0;
  378. padding: 0;
  379. width: 100%;
  380. height: 100%;
  381. background: #F5FAFF;
  382. }
  383. .main {
  384. width: 100%;
  385. height: 100%;
  386. .content {
  387. display: flex;
  388. justify-content: space-evenly;
  389. height: 100%;
  390. .twCard {
  391. position: relative;
  392. height: 100%;
  393. .twLine {
  394. position: absolute;
  395. top: 0;
  396. left: 0;
  397. width: 680px;
  398. .twTitle {
  399. position: absolute;
  400. top: 24px;
  401. left: 22px;
  402. .twHead {
  403. width: 52px;
  404. height: 52px;
  405. border-radius: 50%;
  406. img {
  407. width: 100%;
  408. height: 100%;
  409. border-radius: 50%;
  410. }
  411. }
  412. .twName {
  413. position: absolute;
  414. top: 0;
  415. left: 60px;
  416. width: 550px;
  417. color: #566370;
  418. }
  419. }
  420. .twShow {
  421. position: absolute;
  422. overflow: hidden;
  423. top: 73px;
  424. left: 84px;
  425. width: 554px;
  426. border-radius: 14px;
  427. box-shadow: 0px 0 10px rgba(0, 0, 0, 0.2);
  428. .showTit {
  429. display: flex;
  430. align-items: center;
  431. color: #ffffff;
  432. font-size: 16px;
  433. font-weight: 500;
  434. height: 44px;
  435. padding-left: 16px;
  436. background: #373737;
  437. }
  438. .showImg {
  439. width: 554px;
  440. height: 554px;
  441. }
  442. }
  443. }
  444. img {
  445. height: 100%;
  446. }
  447. }
  448. .twInfo {
  449. display: flex;
  450. flex-direction: column;
  451. justify-content: center;
  452. width: 300px;
  453. .title {
  454. color: #000000;
  455. font-size: 15px;
  456. font-weight: 700;
  457. text-align: center;
  458. }
  459. .invitation {
  460. position: relative;
  461. height: 70px;
  462. margin: 16px 0 0 0;
  463. cursor: pointer;
  464. img {
  465. width: 100%;
  466. height: 100%;
  467. }
  468. .hand {
  469. position: absolute;
  470. right: -40px;
  471. top: 13px;
  472. width: 45px;
  473. height: unset;
  474. animation: leftRight .5s infinite ease-in-out;
  475. }
  476. }
  477. .detail {
  478. padding: 20px 0;
  479. cursor: pointer;
  480. color: #1D9BF0;
  481. font-size: 14px;
  482. font-weight: 500;
  483. line-height: 16px;
  484. text-align: center;
  485. }
  486. }
  487. }
  488. .mobile {
  489. .mobile-content {
  490. padding: 36px 16px 0 16px;
  491. img {
  492. width: 100%;
  493. margin-bottom: 25px;
  494. border-radius: 5px;
  495. }
  496. .title {
  497. font-weight: 700;
  498. font-size: 22px;
  499. line-height: 26px;
  500. text-align: center;
  501. letter-spacing: 0.3px;
  502. color: #000000;
  503. width: 240px;
  504. margin: 0 auto;
  505. }
  506. }
  507. .area-button {
  508. position: fixed;
  509. width: 100%;
  510. padding: 27px 16px 25px 16px;
  511. bottom: 0;
  512. height: 170px;
  513. .btn1 {
  514. height: 50px;
  515. line-height: 50px;
  516. background: #1d9bf0;
  517. border-radius: 100px;
  518. width: 100%;
  519. font-weight: 600;
  520. font-size: 18px;
  521. text-align: center;
  522. letter-spacing: 0.3px;
  523. color: #ffffff;
  524. margin-bottom: 16px;
  525. }
  526. .btn2 {
  527. height: 50px;
  528. line-height: 50px;
  529. background: rgba(29, 155, 240, 0.01);
  530. border: 1px solid #1d9bf0;
  531. border-radius: 100px;
  532. width: 100%;
  533. font-weight: 600;
  534. font-size: 18px;
  535. text-align: center;
  536. letter-spacing: 0.3px;
  537. color: #1d9bf0;
  538. }
  539. }
  540. }
  541. }
  542. .mask {
  543. position: absolute;
  544. z-index: 99;
  545. display: flex;
  546. flex-direction: column;
  547. align-items: center;
  548. justify-content: center;
  549. top: 0;
  550. left: 0;
  551. width: 100%;
  552. height: 100%;
  553. background-color: rgba($color: #000000, $alpha: .8);
  554. .text {
  555. color: #ffffff;
  556. text-align: center;
  557. font-size: 14px;
  558. font-weight: 500;
  559. margin: 40px 20px 0 20px;
  560. }
  561. }
  562. @keyframes leftRight {
  563. 0% {
  564. transform: translateX(0);
  565. }
  566. 100% {
  567. transform: translateX(20px);
  568. }
  569. }
  570. </style>