index.vue 7.3 KB

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