index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <div class="main">
  3. <!-- pc -->
  4. <div v-if="device == 'chrome' || device == 'no-chrome'" class="content">
  5. <v-logo></v-logo>
  6. <div class="tool-cover">
  7. <img :src="img_url" alt="" />
  8. </div>
  9. <!-- 非chrome -->
  10. <div v-if="device == 'no-chrome'">
  11. <div class="txt">Use chrome browser to access {{ detail.postBizData.linkTitle || '' }}</div>
  12. <install-chrome></install-chrome>
  13. </div>
  14. <!-- chrome -->
  15. <div v-if="device == 'chrome'">
  16. <div class="txt">Use chrome browser to access {{ detail.postBizData.linkTitle || '' }}</div>
  17. <install-extension :extensionsInstallUrl="config.extensionsInstallUrl" @installClick="installClick"></install-extension>
  18. </div>
  19. </div>
  20. <!-- 移动端 -->
  21. <div v-if="device == 'ios' || device == '安卓'" class="mobile">
  22. <div class="mobile-content">
  23. <img :src="detail.postBizData.linkImagePath" alt="" />
  24. <div class="title">Open link on PC to use Subway Surfers</div>
  25. </div>
  26. <div class="area-button">
  27. <div class="btn1" @click="clickExtension">Install Chrome Extension</div>
  28. <div class="btn2" @click="clickCopy" :data-clipboard-text="copy_link">Copy Link</div>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import VLogo from '@/components/logo.vue';
  35. import InstallChrome from '@/components/InstallChrome.vue';
  36. import InstallExtension from '@/components/InstallExtension.vue';
  37. import { getBrowserType, baseURL, appVersionCode, jumpUrl, appType } from '@/utils/help.js';
  38. import axios from 'axios';
  39. import Cookies from 'js-cookie';
  40. import { Toast } from 'vant';
  41. import Report from '@/log-center/log';
  42. var ClipboardJS = require('clipboard');
  43. export default {
  44. name: 'tool_box',
  45. data() {
  46. return {
  47. config: {},
  48. copy_link: '',
  49. title: 'Install DeNet Plugin to Participate',
  50. metaTitle: 'Install DeNet Plugin to Participate',
  51. device: '',
  52. detail: {},
  53. mid: '',
  54. pageSource: '',
  55. img_url: '',
  56. };
  57. },
  58. head() {
  59. return {
  60. type: '',
  61. title: this.title,
  62. appVersionCode: appVersionCode,
  63. meta: [
  64. // facebook
  65. {
  66. name: 'og:url',
  67. content: jumpUrl + 'toolbox/' + this.$route.params.id,
  68. },
  69. {
  70. name: 'og:title',
  71. content: this.metaTitle,
  72. },
  73. {
  74. name: 'og:image',
  75. content: this.detail.postBizData.linkImagePath || '',
  76. },
  77. // twitter
  78. {
  79. name: 'twitter:card',
  80. content: 'summary_large_image',
  81. },
  82. {
  83. name: 'twitter:url',
  84. content: jumpUrl + 'toolbox/' + this.$route.params.id,
  85. },
  86. {
  87. name: 'twitter:title',
  88. content: this.detail.postBizData.linkTitle || this.metaTitle,
  89. },
  90. {
  91. name: 'twitter:image',
  92. content: this.detail.postBizData.linkImagePath || '',
  93. },
  94. ],
  95. };
  96. },
  97. components: {
  98. VLogo,
  99. InstallChrome,
  100. InstallExtension,
  101. },
  102. async asyncData(params) {
  103. let { route } = params;
  104. let { data } = await axios.post(`${baseURL}/denet/post/getDetail`, {
  105. baseInfo: {
  106. appVersionCode: appVersionCode,
  107. mid: '00000000-0000-0000-0000-000000000000',
  108. },
  109. params: {
  110. postId: route.params.id || '',
  111. },
  112. });
  113. if (data.code == 0) {
  114. if (data.data && data.data.postBizData && typeof data.data.postBizData == 'string') {
  115. data.data.postBizData = JSON.parse(data.data.postBizData);
  116. }
  117. if (data.data.postBizData === null) {
  118. data.data.postBizData = {
  119. postUserInfo: {},
  120. };
  121. }
  122. console.log('detail', data.data);
  123. return {
  124. detail: data.data,
  125. };
  126. }
  127. },
  128. mounted() {
  129. if (this.detail.postBizData.linkImagePath.indexOf('default') > 0) {
  130. this.img_url = '/img/img-default.png';
  131. } else {
  132. this.img_url = this.detail.postBizData.linkImagePath;
  133. }
  134. this.pageSource = Report.pageSource.newUserLandingPage;
  135. this.setCookieMid();
  136. Report.reportLog({
  137. baseInfo: {
  138. appVersionCode: appVersionCode,
  139. mid: this.mid,
  140. pageSource: this.pageSource,
  141. appType,
  142. machineCode: this.mid,
  143. },
  144. params: {
  145. eventData: {
  146. businessType: Report.businessType.pageView,
  147. postId: this.detail.postId,
  148. srcContentId: this.detail.srcContentId,
  149. redPacketType: 5,
  150. postEditorUrl: this.detail.postBizData.convertUrl,
  151. },
  152. },
  153. });
  154. this.copy_link = window.location.href;
  155. this.device = getBrowserType();
  156. this.getConfig();
  157. console.log('device', this.device);
  158. if (this.device == 'chrome') {
  159. this.setCookie();
  160. }
  161. },
  162. methods: {
  163. installClick() {
  164. Report.reportLog({
  165. baseInfo: {
  166. appVersionCode: appVersionCode,
  167. mid: this.mid,
  168. pageSource: this.pageSource,
  169. appType,
  170. machineCode: this.mid,
  171. },
  172. params: {
  173. eventData: {
  174. businessType: Report.businessType.buttonClick,
  175. objectType: Report.objectType.installButton,
  176. postId: this.detail.postId,
  177. srcContentId: this.detail.srcContentId,
  178. redPacketType: 5,
  179. postEditorUrl: this.detail.postBizData.convertUrl,
  180. },
  181. },
  182. });
  183. },
  184. guid() {
  185. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  186. var r = (Math.random() * 16) | 0,
  187. v = c == 'x' ? r : (r & 0x3) | 0x8;
  188. return v.toString(16);
  189. });
  190. },
  191. setCookieMid() {
  192. let _cookie_mid_arr = Cookies.get('mid') || [];
  193. if (_cookie_mid_arr.length > 0) {
  194. this.mid = JSON.parse(_cookie_mid_arr)[0].mid;
  195. } else {
  196. this.mid = this.guid();
  197. Cookies.set('mid', JSON.stringify([{ mid: this.mid }]), { expires: 1000 });
  198. }
  199. },
  200. setCookie() {
  201. let pickupInfo = {
  202. srcContentId: this.detail.srcContentId || '',
  203. postNickName: this.detail.srcUserId || '',
  204. createTime: Date.now(),
  205. jump_type: 'jump_info',
  206. };
  207. Cookies.set('jump_info', JSON.stringify(pickupInfo), { expires: 1000 });
  208. },
  209. async getConfig() {
  210. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  211. baseInfo: {
  212. appVersionCode: this.appVersionCode,
  213. mid: this.mid,
  214. },
  215. params: {},
  216. });
  217. if (data.code == 0) {
  218. this.config = data.data;
  219. }
  220. },
  221. clickCopy() {
  222. // 复制链接
  223. var clipboard = new ClipboardJS('.btn2');
  224. clipboard.on('success', function (e) {
  225. Toast('copy success');
  226. e.clearSelection();
  227. });
  228. clipboard.on('error', function () {
  229. Toast('copy error');
  230. });
  231. },
  232. clickExtension() {
  233. window.open(this.config.extensionsInstallUrl);
  234. },
  235. },
  236. };
  237. </script>
  238. <style lang="scss">
  239. html,
  240. body,
  241. #__nuxt,
  242. #__layout {
  243. margin: 0;
  244. padding: 0;
  245. width: 100%;
  246. height: 100%;
  247. background: #f5faff;
  248. }
  249. .main {
  250. width: 100%;
  251. height: 100%;
  252. .tool-cover {
  253. min-width: 400px;
  254. margin-right: 90px;
  255. img {
  256. max-height: 270px;
  257. }
  258. }
  259. .content {
  260. width: 100%;
  261. height: 100%;
  262. display: flex;
  263. justify-content: center;
  264. align-items: center;
  265. padding-bottom: 70px;
  266. .txt {
  267. width: 400px;
  268. font-weight: 700;
  269. font-size: 36px;
  270. line-height: 44px;
  271. /* or 122% */
  272. letter-spacing: 0.3px;
  273. color: #323232;
  274. margin-bottom: 40px;
  275. }
  276. }
  277. .mobile {
  278. .mobile-content {
  279. padding: 36px 16px 0 16px;
  280. img {
  281. width: 100%;
  282. margin-bottom: 25px;
  283. border-radius: 5px;
  284. }
  285. .title {
  286. font-weight: 700;
  287. font-size: 22px;
  288. line-height: 26px;
  289. text-align: center;
  290. letter-spacing: 0.3px;
  291. color: #000000;
  292. width: 240px;
  293. margin: 0 auto;
  294. }
  295. }
  296. .area-button {
  297. position: fixed;
  298. width: 100%;
  299. padding: 27px 16px 25px 16px;
  300. bottom: 0;
  301. height: 170px;
  302. .btn1 {
  303. height: 50px;
  304. line-height: 50px;
  305. background: #1d9bf0;
  306. border-radius: 100px;
  307. width: 100%;
  308. font-weight: 600;
  309. font-size: 18px;
  310. text-align: center;
  311. letter-spacing: 0.3px;
  312. color: #ffffff;
  313. margin-bottom: 16px;
  314. }
  315. .btn2 {
  316. height: 50px;
  317. line-height: 50px;
  318. background: rgba(29, 155, 240, 0.01);
  319. border: 1px solid #1d9bf0;
  320. border-radius: 100px;
  321. width: 100%;
  322. font-weight: 600;
  323. font-size: 18px;
  324. text-align: center;
  325. letter-spacing: 0.3px;
  326. color: #1d9bf0;
  327. }
  328. }
  329. }
  330. }
  331. </style>