index.vue 8.6 KB

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