index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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 } 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(params) {
  105. let { route } = params;
  106. let { data } = await axios.post(`${baseURL}/denet/post/getDetail`, {
  107. baseInfo: {
  108. appVersionCode: appVersionCode,
  109. mid: '00000000-0000-0000-0000-000000000000',
  110. },
  111. params: {
  112. postId: route.params.id || '',
  113. },
  114. });
  115. if (data.code == 0) {
  116. if (data.data && data.data.postBizData && typeof data.data.postBizData == 'string') {
  117. data.data.postBizData = JSON.parse(data.data.postBizData);
  118. }
  119. if (data.data.postBizData === null) {
  120. data.data.postBizData = {
  121. postUserInfo: {},
  122. };
  123. }
  124. console.log('detail', data.data);
  125. return {
  126. detail: data.data,
  127. };
  128. }
  129. },
  130. mounted() {
  131. if (this.detail.postBizData.linkImagePath.indexOf('default') > 0) {
  132. this.img_url = '/img/img-default.png';
  133. } else {
  134. this.img_url = this.detail.postBizData.linkImagePath;
  135. }
  136. this.pageSource = Report.pageSource.newUserLandingPage;
  137. this.setCookieMid();
  138. Report.reportLog({
  139. baseInfo: {
  140. appVersionCode: appVersionCode,
  141. mid: this.mid,
  142. pageSource: this.pageSource,
  143. appType,
  144. machineCode: this.mid,
  145. },
  146. params: {
  147. eventData: {
  148. businessType: Report.businessType.pageView,
  149. postId: this.detail.postId,
  150. srcContentId: this.detail.srcContentId,
  151. redPacketType: 5,
  152. postEditorUrl: this.detail.postBizData.convertUrl,
  153. },
  154. },
  155. });
  156. this.copy_link = window.location.href;
  157. this.device = getBrowserType();
  158. this.getConfig();
  159. console.log('device', this.device);
  160. if (this.device == 'chrome') {
  161. this.setCookie();
  162. }
  163. },
  164. methods: {
  165. installClick() {
  166. Report.reportLog({
  167. baseInfo: {
  168. appVersionCode: appVersionCode,
  169. mid: this.mid,
  170. pageSource: this.pageSource,
  171. appType,
  172. machineCode: this.mid,
  173. },
  174. params: {
  175. eventData: {
  176. businessType: Report.businessType.buttonClick,
  177. objectType: Report.objectType.installButton,
  178. postId: this.detail.postId,
  179. srcContentId: this.detail.srcContentId,
  180. redPacketType: 5,
  181. postEditorUrl: this.detail.postBizData.convertUrl,
  182. },
  183. },
  184. });
  185. },
  186. guid() {
  187. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  188. var r = (Math.random() * 16) | 0,
  189. v = c == 'x' ? r : (r & 0x3) | 0x8;
  190. return v.toString(16);
  191. });
  192. },
  193. setCookieMid() {
  194. let _cookie_mid_arr = Cookies.get('mid') || [];
  195. if (_cookie_mid_arr.length > 0) {
  196. this.mid = JSON.parse(_cookie_mid_arr)[0].mid;
  197. } else {
  198. this.mid = this.guid();
  199. Cookies.set('mid', JSON.stringify([{ mid: this.mid }]), { expires: 1000 });
  200. }
  201. },
  202. setCookie() {
  203. let pickupInfo = {
  204. srcContentId: this.detail.srcContentId || '',
  205. postNickName: this.detail.srcUserId || '',
  206. createTime: Date.now(),
  207. jump_type: 'tool_box',
  208. postId: this.detail.postId || '',
  209. };
  210. Cookies.set('jump_info', JSON.stringify(pickupInfo), { expires: 1000 });
  211. },
  212. async getConfig() {
  213. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  214. baseInfo: {
  215. appVersionCode: this.appVersionCode,
  216. mid: this.mid,
  217. },
  218. params: {},
  219. });
  220. if (data.code == 0) {
  221. this.config = data.data;
  222. }
  223. },
  224. clickCopy() {
  225. // 复制链接
  226. var clipboard = new ClipboardJS('.btn2');
  227. clipboard.on('success', function (e) {
  228. Toast('copy success');
  229. e.clearSelection();
  230. });
  231. clipboard.on('error', function () {
  232. Toast('copy error');
  233. });
  234. },
  235. clickExtension() {
  236. window.open(this.config.extensionsInstallUrl);
  237. },
  238. },
  239. };
  240. </script>
  241. <style lang="scss">
  242. html,
  243. body,
  244. #__nuxt,
  245. #__layout {
  246. margin: 0;
  247. padding: 0;
  248. width: 100%;
  249. height: 100%;
  250. background: #f5faff;
  251. }
  252. .main {
  253. width: 100%;
  254. height: 100%;
  255. .tool-cover {
  256. min-width: 400px;
  257. margin-right: 90px;
  258. img {
  259. max-height: 270px;
  260. }
  261. }
  262. .content {
  263. width: 100%;
  264. height: 100%;
  265. display: flex;
  266. justify-content: center;
  267. align-items: center;
  268. padding-bottom: 70px;
  269. .txt {
  270. width: 400px;
  271. font-weight: 700;
  272. font-size: 36px;
  273. line-height: 44px;
  274. /* or 122% */
  275. letter-spacing: 0.3px;
  276. color: #323232;
  277. margin-bottom: 40px;
  278. }
  279. }
  280. .mobile {
  281. .mobile-content {
  282. text-align: center;
  283. padding: 36px 16px 0 16px;
  284. img {
  285. width: 100%;
  286. margin-bottom: 25px;
  287. border-radius: 5px;
  288. &.blur {
  289. width: 95%;
  290. filter: saturate(0.5) blur(6px);
  291. }
  292. }
  293. .title {
  294. font-weight: 700;
  295. font-size: 22px;
  296. line-height: 26px;
  297. text-align: center;
  298. letter-spacing: 0.3px;
  299. color: #000000;
  300. width: 240px;
  301. margin: 0 auto;
  302. }
  303. }
  304. .area-button {
  305. position: fixed;
  306. width: 100%;
  307. padding: 27px 16px 25px 16px;
  308. bottom: 0;
  309. height: 170px;
  310. .btn1 {
  311. height: 50px;
  312. line-height: 50px;
  313. background: #1d9bf0;
  314. border-radius: 100px;
  315. width: 100%;
  316. font-weight: 600;
  317. font-size: 18px;
  318. text-align: center;
  319. letter-spacing: 0.3px;
  320. color: #ffffff;
  321. margin-bottom: 16px;
  322. }
  323. .btn2 {
  324. height: 50px;
  325. line-height: 50px;
  326. background: rgba(29, 155, 240, 0.01);
  327. border: 1px solid #1d9bf0;
  328. border-radius: 100px;
  329. width: 100%;
  330. font-weight: 600;
  331. font-size: 18px;
  332. text-align: center;
  333. letter-spacing: 0.3px;
  334. color: #1d9bf0;
  335. }
  336. }
  337. }
  338. }
  339. </style>