index.vue 5.9 KB

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