index.vue 8.0 KB

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