index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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" @installClick="installClick"> </install-extension>
  18. </div>
  19. </div>
  20. <!-- 移动端 -->
  21. <div v-if="device == 'ios' || device == '安卓'" class="mobile">
  22. <div class="mobile-content">
  23. <img :class="{ blur: detail.postBizData.certNftProjectId }" :src="detail.postBizData.viewBgImagePath || detail.postBizData.linkImagePath" alt="" />
  24. <div class="title">
  25. Open link on PC to use <span v-if="detail.postBizData && detail.postBizData.linkTitle">{{ detail.postBizData.linkTitle }}</span>
  26. </div>
  27. </div>
  28. <div class="area-button">
  29. <div class="btn1" @click="clickExtension">Install Chrome Extension</div>
  30. <div class="btn2" @click="clickCopy" :data-clipboard-text="copy_link">Copy Link</div>
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import VLogo from '@/components/logo.vue';
  37. import InstallChrome from '@/components/InstallChrome.vue';
  38. import InstallExtension from '@/components/InstallExtension.vue';
  39. import { getBrowserType, baseURL, appVersionCode, jumpUrl, appType, GetDetailSSR } from '@/utils/help.js';
  40. import axios from 'axios';
  41. import Cookies from 'js-cookie';
  42. import { Toast } from 'vant';
  43. import Report from '@/log-center/log';
  44. var ClipboardJS = require('clipboard');
  45. export default {
  46. name: 'tool_box',
  47. data() {
  48. return {
  49. config: {},
  50. copy_link: '',
  51. title: 'Install DeNet Plugin to Participate',
  52. metaTitle: 'Install DeNet Plugin to Participate',
  53. device: '',
  54. detail: {},
  55. mid: '',
  56. pageSource: '',
  57. img_url: '',
  58. };
  59. },
  60. head() {
  61. return {
  62. type: '',
  63. title: this.title,
  64. appVersionCode: appVersionCode,
  65. meta: [
  66. // facebook
  67. {
  68. name: 'og:url',
  69. content: jumpUrl + 'toolbox/' + this.$route.params.id,
  70. },
  71. {
  72. name: 'og:title',
  73. content: this.metaTitle,
  74. },
  75. {
  76. name: 'og:image',
  77. content: this.detail.postBizData.linkImagePath || '',
  78. },
  79. // twitter
  80. {
  81. name: 'twitter:card',
  82. content: 'summary_large_image',
  83. },
  84. {
  85. name: 'twitter:url',
  86. content: jumpUrl + 'toolbox/' + this.$route.params.id,
  87. },
  88. {
  89. name: 'twitter:title',
  90. content: this.detail.postBizData.linkTitle || this.metaTitle,
  91. },
  92. {
  93. name: 'twitter:image',
  94. content: this.detail.postBizData.linkImagePath || '',
  95. },
  96. ],
  97. };
  98. },
  99. components: {
  100. VLogo,
  101. InstallChrome,
  102. InstallExtension,
  103. },
  104. async asyncData(context) {
  105. let { route } = context;
  106. let result = await GetDetailSSR({
  107. context,
  108. params: {
  109. postId: route.params.id || '',
  110. },
  111. url: `${baseURL}/denet/post/getDetail`,
  112. });
  113. if (result.code == 0) {
  114. if (result.data && result.data.postBizData && typeof result.data.postBizData == 'string') {
  115. result.data.postBizData = JSON.parse(result.data.postBizData);
  116. }
  117. if (result.data.postBizData === null) {
  118. result.data.postBizData = {
  119. postUserInfo: {},
  120. };
  121. }
  122. return {
  123. detail: result.data,
  124. };
  125. }
  126. },
  127. mounted() {
  128. if (this.detail.postBizData.linkImagePath.indexOf('default') > 0) {
  129. this.img_url = '/img/img-default.png';
  130. } else {
  131. this.img_url = this.detail.postBizData.linkImagePath;
  132. }
  133. this.pageSource = Report.pageSource.newUserLandingPage;
  134. this.setCookieMid();
  135. Report.reportLog({
  136. baseInfo: {
  137. appVersionCode: appVersionCode,
  138. mid: this.mid,
  139. pageSource: this.pageSource,
  140. appType,
  141. machineCode: this.mid,
  142. },
  143. params: {
  144. eventData: {
  145. businessType: Report.businessType.pageView,
  146. postId: this.detail.postId,
  147. srcContentId: this.detail.srcContentId,
  148. redPacketType: 5,
  149. postEditorUrl: this.detail.postBizData.convertUrl,
  150. },
  151. },
  152. });
  153. this.copy_link = window.location.href;
  154. this.device = getBrowserType();
  155. this.getConfig();
  156. console.log('device', this.device);
  157. if (this.device == 'chrome') {
  158. this.setCookie();
  159. }
  160. },
  161. methods: {
  162. installClick() {
  163. Report.reportLog({
  164. baseInfo: {
  165. appVersionCode: appVersionCode,
  166. mid: this.mid,
  167. pageSource: this.pageSource,
  168. appType,
  169. machineCode: this.mid,
  170. },
  171. params: {
  172. eventData: {
  173. businessType: Report.businessType.buttonClick,
  174. objectType: Report.objectType.installButton,
  175. postId: this.detail.postId,
  176. srcContentId: this.detail.srcContentId,
  177. redPacketType: 5,
  178. postEditorUrl: this.detail.postBizData.convertUrl,
  179. },
  180. },
  181. });
  182. },
  183. guid() {
  184. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  185. var r = (Math.random() * 16) | 0,
  186. v = c == 'x' ? r : (r & 0x3) | 0x8;
  187. return v.toString(16);
  188. });
  189. },
  190. setCookieMid() {
  191. let _cookie_mid_arr = Cookies.get('mid') || [];
  192. if (_cookie_mid_arr.length > 0) {
  193. this.mid = JSON.parse(_cookie_mid_arr)[0].mid;
  194. } else {
  195. this.mid = this.guid();
  196. Cookies.set('mid', JSON.stringify([{ mid: this.mid }]), { expires: 1000 });
  197. }
  198. },
  199. setCookie() {
  200. let pickupInfo = {
  201. srcContentId: this.detail.srcContentId || '',
  202. postNickName: this.detail.srcUserId || '',
  203. createTime: Date.now(),
  204. jump_type: 'tool_box',
  205. postId: this.detail.postId || '',
  206. };
  207. Cookies.set('jump_info', JSON.stringify(pickupInfo), { expires: 1000 });
  208. },
  209. async getConfig() {
  210. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  211. baseInfo: {
  212. appVersionCode: this.appVersionCode,
  213. mid: this.mid,
  214. },
  215. params: {},
  216. });
  217. if (data.code == 0) {
  218. this.config = data.data;
  219. }
  220. },
  221. clickCopy() {
  222. // 复制链接
  223. var clipboard = new ClipboardJS('.btn2');
  224. clipboard.on('success', function (e) {
  225. Toast('copy success');
  226. e.clearSelection();
  227. });
  228. clipboard.on('error', function () {
  229. Toast('copy error');
  230. });
  231. },
  232. clickExtension() {
  233. window.open(this.config.extensionsInstallUrl);
  234. },
  235. },
  236. };
  237. </script>
  238. <style lang="scss">
  239. html,
  240. body,
  241. #__nuxt,
  242. #__layout {
  243. margin: 0;
  244. padding: 0;
  245. width: 100%;
  246. height: 100%;
  247. background: #f5faff;
  248. }
  249. .main {
  250. width: 100%;
  251. height: 100%;
  252. .tool-cover {
  253. min-width: 400px;
  254. margin-right: 90px;
  255. img {
  256. max-height: 270px;
  257. }
  258. }
  259. .content {
  260. width: 100%;
  261. height: 100%;
  262. display: flex;
  263. justify-content: center;
  264. align-items: center;
  265. padding-bottom: 70px;
  266. .txt {
  267. width: 400px;
  268. font-weight: 700;
  269. font-size: 36px;
  270. line-height: 44px;
  271. /* or 122% */
  272. letter-spacing: 0.3px;
  273. color: #323232;
  274. margin-bottom: 40px;
  275. }
  276. }
  277. .mobile {
  278. .mobile-content {
  279. text-align: center;
  280. padding: 36px 16px 0 16px;
  281. img {
  282. width: 100%;
  283. margin-bottom: 25px;
  284. border-radius: 5px;
  285. &.blur {
  286. width: 95%;
  287. filter: saturate(0.5) blur(6px);
  288. }
  289. }
  290. .title {
  291. font-weight: 700;
  292. font-size: 22px;
  293. line-height: 26px;
  294. text-align: center;
  295. letter-spacing: 0.3px;
  296. color: #000000;
  297. width: 240px;
  298. margin: 0 auto;
  299. }
  300. }
  301. .area-button {
  302. position: fixed;
  303. width: 100%;
  304. padding: 27px 16px 25px 16px;
  305. bottom: 0;
  306. height: 170px;
  307. .btn1 {
  308. height: 50px;
  309. line-height: 50px;
  310. background: #1d9bf0;
  311. border-radius: 100px;
  312. width: 100%;
  313. font-weight: 600;
  314. font-size: 18px;
  315. text-align: center;
  316. letter-spacing: 0.3px;
  317. color: #ffffff;
  318. margin-bottom: 16px;
  319. }
  320. .btn2 {
  321. height: 50px;
  322. line-height: 50px;
  323. background: rgba(29, 155, 240, 0.01);
  324. border: 1px solid #1d9bf0;
  325. border-radius: 100px;
  326. width: 100%;
  327. font-weight: 600;
  328. font-size: 18px;
  329. text-align: center;
  330. letter-spacing: 0.3px;
  331. color: #1d9bf0;
  332. }
  333. }
  334. }
  335. }
  336. </style>