index.vue 6.0 KB

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