index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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">
  28. Install Chrome Extension
  29. </div>
  30. <div class="btn2" @click="clickCopy" :data-clipboard-text="copy_link">
  31. Copy Link
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. import VLogo from '@/components/logo.vue'
  39. import InstallChrome from '@/components/InstallChrome.vue'
  40. import InstallExtension from '@/components/InstallExtension.vue'
  41. import { getBrowserType, baseURL, appVersionCode, jumpUrl } from '@/utils/help.js'
  42. import axios from 'axios'
  43. import Cookies from 'js-cookie'
  44. import { Toast } from 'vant';
  45. var ClipboardJS = require('clipboard')
  46. export default {
  47. name: 'tool_box',
  48. data() {
  49. return {
  50. config: {},
  51. copy_link: '',
  52. title: 'Install DeNet Plugin to Participate',
  53. metaTitle: 'Install DeNet Plugin to Participate',
  54. device: '',
  55. detail: {}
  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.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. this.copy_link = window.location.href
  130. this.device = getBrowserType()
  131. this.getConfig()
  132. console.log('device',this.device)
  133. if(this.device == 'chrome'){
  134. this.setCookie()
  135. }
  136. },
  137. methods: {
  138. setCookie(){
  139. let pickupInfo = {
  140. srcContentId: this.detail.srcContentId || '',
  141. postNickName: this.detail.srcUserId || '',
  142. createTime: Date.now(),
  143. jump_type: 'jump_info',
  144. };
  145. Cookies.set('jump_info', JSON.stringify(pickupInfo), { expires: 1000 });
  146. },
  147. async getConfig() {
  148. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  149. baseInfo: {
  150. appVersionCode: this.appVersionCode,
  151. mid: this.mid
  152. },
  153. params: {
  154. }
  155. })
  156. if (data.code == 0) {
  157. this.config = data.data;
  158. }
  159. },
  160. clickCopy() {
  161. // 复制链接
  162. var clipboard = new ClipboardJS('.btn2');
  163. clipboard.on('success', function (e) {
  164. Toast('copy success');
  165. e.clearSelection();
  166. });
  167. clipboard.on('error', function (e) {
  168. Toast('copy error');
  169. });
  170. },
  171. clickExtension() {
  172. window.open(this.config.extensionsInstallUrl)
  173. }
  174. }
  175. }
  176. </script>
  177. <style lang="scss" >
  178. html,
  179. body,
  180. #__nuxt,
  181. #__layout {
  182. margin: 0;
  183. padding: 0;
  184. width: 100%;
  185. height: 100%;
  186. background: #F5FAFF;
  187. }
  188. .main {
  189. width: 100%;
  190. height: 100%;
  191. .tool-cover {
  192. min-width: 400px;
  193. margin-right: 90px;
  194. img {
  195. max-height: 270px;
  196. }
  197. }
  198. .content {
  199. width: 100%;
  200. height: 100%;
  201. display: flex;
  202. justify-content: center;
  203. align-items: center;
  204. padding-bottom: 70px;
  205. .txt {
  206. width: 400px;
  207. font-weight: 700;
  208. font-size: 36px;
  209. line-height: 44px;
  210. /* or 122% */
  211. letter-spacing: 0.3px;
  212. color: #323232;
  213. margin-bottom: 40px;
  214. }
  215. }
  216. .mobile {
  217. .mobile-content {
  218. padding: 36px 16px 0 16px;
  219. img {
  220. width: 100%;
  221. margin-bottom: 25px;
  222. border-radius: 5px;
  223. }
  224. .title {
  225. font-weight: 700;
  226. font-size: 22px;
  227. line-height: 26px;
  228. text-align: center;
  229. letter-spacing: 0.3px;
  230. color: #000000;
  231. width: 240px;
  232. margin: 0 auto;
  233. }
  234. }
  235. .area-button {
  236. position: fixed;
  237. width: 100%;
  238. padding: 27px 16px 25px 16px;
  239. bottom: 0;
  240. height: 170px;
  241. .btn1 {
  242. height: 50px;
  243. line-height: 50px;
  244. background: #1D9BF0;
  245. border-radius: 100px;
  246. width: 100%;
  247. font-weight: 600;
  248. font-size: 18px;
  249. text-align: center;
  250. letter-spacing: 0.3px;
  251. color: #FFFFFF;
  252. margin-bottom: 16px;
  253. }
  254. .btn2 {
  255. height: 50px;
  256. line-height: 50px;
  257. background: rgba(29, 155, 240, 0.01);
  258. border: 1px solid #1D9BF0;
  259. border-radius: 100px;
  260. width: 100%;
  261. font-weight: 600;
  262. font-size: 18px;
  263. text-align: center;
  264. letter-spacing: 0.3px;
  265. color: #1D9BF0;
  266. }
  267. }
  268. }
  269. }
  270. </style>