index.vue 8.5 KB

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