index.vue 8.2 KB

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