index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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. 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. redPacketType: 5,
  187. postEditorUrl: this.detail.postBizData.convertUrl,
  188. },
  189. },
  190. });
  191. this.copy_link = window.location.href;
  192. this.device = getBrowserType();
  193. this.getConfig();
  194. this.getUserInfo();
  195. console.log('device', this.device);
  196. if (this.device == 'chrome') {
  197. this.setCookie();
  198. }
  199. // 计算缩放
  200. this.sumScale();
  201. window.onresize = function() {
  202. that.sumScale();
  203. }
  204. },
  205. methods: {
  206. installClick() {
  207. Report.reportLog({
  208. baseInfo: {
  209. appVersionCode: appVersionCode,
  210. mid: this.mid,
  211. pageSource: this.pageSource,
  212. appType,
  213. machineCode: this.mid,
  214. },
  215. params: {
  216. eventData: {
  217. businessType: Report.businessType.buttonClick,
  218. objectType: Report.objectType.installButton,
  219. postId: this.detail.postId,
  220. srcContentId: this.detail.srcContentId,
  221. redPacketType: 5,
  222. postEditorUrl: this.detail.postBizData.convertUrl,
  223. },
  224. },
  225. });
  226. },
  227. guid() {
  228. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  229. var r = (Math.random() * 16) | 0,
  230. v = c == 'x' ? r : (r & 0x3) | 0x8;
  231. return v.toString(16);
  232. });
  233. },
  234. setCookieMid() {
  235. let _cookie_mid_arr = Cookies.get('mid') || [];
  236. if (_cookie_mid_arr.length > 0) {
  237. this.mid = JSON.parse(_cookie_mid_arr)[0].mid;
  238. } else {
  239. this.mid = this.guid();
  240. Cookies.set('mid', JSON.stringify([{ mid: this.mid }]), { expires: 1000 });
  241. }
  242. },
  243. setCookie() {
  244. let pickupInfo = {
  245. srcContentId: this.detail.srcContentId || '',
  246. postNickName: this.detail.srcUserId || '',
  247. createTime: Date.now(),
  248. jump_type: 'tool_box',
  249. };
  250. Cookies.set('jump_info', JSON.stringify(pickupInfo), { expires: 1000 });
  251. },
  252. async getConfig() {
  253. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  254. baseInfo: {
  255. appVersionCode: this.appVersionCode,
  256. mid: this.mid,
  257. },
  258. params: {},
  259. });
  260. if (data.code == 0) {
  261. this.config = data.data;
  262. }
  263. },
  264. async getUserInfo() {
  265. let { data } = await axios.post(`${baseURL}/denet/user/getUserInfo`, {
  266. baseInfo: {
  267. appVersionCode: this.appVersionCode,
  268. mid: this.mid,
  269. },
  270. params: {
  271. uid: this.detail.uid
  272. },
  273. });
  274. if (data.code == 0) {
  275. this.userInfo = data.data;
  276. }
  277. },
  278. clickCopy() {
  279. // 复制链接
  280. var clipboard = new ClipboardJS('.btn2');
  281. clipboard.on('success', function (e) {
  282. Toast('copy success');
  283. e.clearSelection();
  284. });
  285. clipboard.on('error', function () {
  286. Toast('copy error');
  287. });
  288. },
  289. clickExtension() {
  290. window.open(this.config.extensionsInstallUrl);
  291. },
  292. sumScale() {
  293. if (this.device == 'chrome' || this.device == 'no-chrome') {
  294. this.$nextTick(() => {
  295. let obj = this.$refs.twCard;
  296. if (obj && obj.offsetWidth) {
  297. this.scale = obj.offsetWidth / 680;
  298. } else {
  299. setTimeout(() => {
  300. this.sumScale()
  301. }, 200)
  302. }
  303. })
  304. }
  305. },
  306. goOriginLink() {
  307. if (this.detail.postBizData.originUrl) {
  308. window.open(this.detail.postBizData.originUrl)
  309. }
  310. },
  311. mobileLink() {
  312. if (this.device == 'ios' || this.device == '安卓') {
  313. this.showLoading = true;
  314. if (!('certNftProjectId' in this.detail.postBizData)) {
  315. if (this.detail.postBizData.originUrl) {
  316. window.location.href = this.detail.postBizData.originUrl
  317. } else {
  318. setTimeout(() => {
  319. this.mobileLink()
  320. }, 200)
  321. }
  322. } else {
  323. this.showLoading = false;
  324. }
  325. }
  326. },
  327. },
  328. };
  329. </script>
  330. <style lang="scss">
  331. html,
  332. body,
  333. #__nuxt,
  334. #__layout {
  335. margin: 0;
  336. padding: 0;
  337. width: 100%;
  338. height: 100%;
  339. background: #F5FAFF;
  340. }
  341. .main {
  342. width: 100%;
  343. height: 100%;
  344. .content {
  345. display: flex;
  346. justify-content: space-evenly;
  347. height: 100%;
  348. .twCard {
  349. position: relative;
  350. height: 100%;
  351. .twLine {
  352. position: absolute;
  353. top: 0;
  354. left: 0;
  355. width: 680px;
  356. .twTitle {
  357. position: absolute;
  358. top: 24px;
  359. left: 22px;
  360. .twHead {
  361. width: 52px;
  362. height: 52px;
  363. border-radius: 50%;
  364. img {
  365. width: 100%;
  366. height: 100%;
  367. border-radius: 50%;
  368. }
  369. }
  370. .twName {
  371. position: absolute;
  372. top: 0;
  373. left: 60px;
  374. width: 550px;
  375. color: #566370;
  376. }
  377. }
  378. .twShow {
  379. position: absolute;
  380. overflow: hidden;
  381. top: 73px;
  382. left: 84px;
  383. width: 554px;
  384. border-radius: 14px;
  385. box-shadow: 0px 0 10px rgba(0, 0, 0, 0.2);
  386. .showTit {
  387. display: flex;
  388. align-items: center;
  389. color: #ffffff;
  390. font-size: 16px;
  391. font-weight: 500;
  392. height: 44px;
  393. padding-left: 16px;
  394. background: #373737;
  395. }
  396. .showImg {
  397. width: 554px;
  398. height: 554px;
  399. }
  400. }
  401. }
  402. img {
  403. height: 100%;
  404. }
  405. }
  406. .twInfo {
  407. display: flex;
  408. flex-direction: column;
  409. justify-content: center;
  410. width: 300px;
  411. .title {
  412. color: #000000;
  413. font-size: 15px;
  414. font-weight: 700;
  415. text-align: center;
  416. }
  417. .invitation {
  418. position: relative;
  419. height: 70px;
  420. margin: 16px 0 0 0;
  421. cursor: pointer;
  422. img {
  423. width: 100%;
  424. height: 100%;
  425. }
  426. .hand {
  427. position: absolute;
  428. right: -40px;
  429. top: 13px;
  430. width: 45px;
  431. height: unset;
  432. animation: leftRight .5s infinite ease-in-out;
  433. }
  434. }
  435. .detail {
  436. padding: 20px 0;
  437. cursor: pointer;
  438. color: #1D9BF0;
  439. font-size: 14px;
  440. font-weight: 500;
  441. line-height: 16px;
  442. text-align: center;
  443. }
  444. }
  445. }
  446. .mobile {
  447. .mobile-content {
  448. padding: 36px 16px 0 16px;
  449. img {
  450. width: 100%;
  451. margin-bottom: 25px;
  452. border-radius: 5px;
  453. }
  454. .title {
  455. font-weight: 700;
  456. font-size: 22px;
  457. line-height: 26px;
  458. text-align: center;
  459. letter-spacing: 0.3px;
  460. color: #000000;
  461. width: 240px;
  462. margin: 0 auto;
  463. }
  464. }
  465. .area-button {
  466. position: fixed;
  467. width: 100%;
  468. padding: 27px 16px 25px 16px;
  469. bottom: 0;
  470. height: 170px;
  471. .btn1 {
  472. height: 50px;
  473. line-height: 50px;
  474. background: #1d9bf0;
  475. border-radius: 100px;
  476. width: 100%;
  477. font-weight: 600;
  478. font-size: 18px;
  479. text-align: center;
  480. letter-spacing: 0.3px;
  481. color: #ffffff;
  482. margin-bottom: 16px;
  483. }
  484. .btn2 {
  485. height: 50px;
  486. line-height: 50px;
  487. background: rgba(29, 155, 240, 0.01);
  488. border: 1px solid #1d9bf0;
  489. border-radius: 100px;
  490. width: 100%;
  491. font-weight: 600;
  492. font-size: 18px;
  493. text-align: center;
  494. letter-spacing: 0.3px;
  495. color: #1d9bf0;
  496. }
  497. }
  498. }
  499. }
  500. .mask {
  501. position: absolute;
  502. z-index: 99;
  503. display: flex;
  504. flex-direction: column;
  505. align-items: center;
  506. justify-content: center;
  507. top: 0;
  508. left: 0;
  509. width: 100%;
  510. height: 100%;
  511. background-color: rgba($color: #000000, $alpha: .8);
  512. .text {
  513. color: #ffffff;
  514. text-align: center;
  515. font-size: 14px;
  516. font-weight: 500;
  517. margin: 40px 20px 0 20px;
  518. }
  519. }
  520. @keyframes leftRight {
  521. 0% {
  522. transform: translateX(0);
  523. }
  524. 100% {
  525. transform: translateX(20px);
  526. }
  527. }
  528. </style>