index.vue 11 KB

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