invite.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <template>
  2. <div class="nft-content">
  3. <template v-if="isLoading">
  4. <img class="loading" src="../../static/svg/icon-loading.svg" />
  5. </template>
  6. <template v-else>
  7. <template v-if="isMobile">
  8. <MobileGuidePage :playType="PlayType.Treasure" :detail="detail" :postUserInfo="detail.postUserInfo"></MobileGuidePage>
  9. </template>
  10. <template v-else>
  11. <div class="logo">
  12. <img src="/img/icon-logo.png" alt />
  13. </div>
  14. <div class="show">
  15. <div class="center">
  16. <div class="content-wrapper">
  17. <img class="img img-left" :src="detail.inviteUserInfo.avatarUrl" alt="" />
  18. <div class="middle">
  19. <div class="invite-txt">@{{ detail.inviteUserInfo.nickName }} invite you to</div>
  20. <div class="title">Hunt the Treaure</div>
  21. <div class="up-gain-txt">
  22. Each can gain up to <span class="amount"> ${{ detail.upGainAmountValue }}</span>
  23. </div>
  24. </div>
  25. <img class="img" src="../../static/svg/icon-treasure.svg" alt="" />
  26. </div>
  27. <div class="btn-wrapper" @click="clickBtn()">
  28. <template v-if="isChrome"> Install Denet Chrome Extension </template>
  29. <template v-else>
  30. <img class="img" src="../../static/svg/icon-chrome-down.svg" />
  31. Open in Chrome to participate
  32. </template>
  33. </div>
  34. </div>
  35. </div>
  36. </template>
  37. </template>
  38. </div>
  39. </template>
  40. <script>
  41. import axios from 'axios';
  42. import Cookies from 'js-cookie';
  43. import { Toast } from 'vant';
  44. import { isBrowser, appVersionCode, appType } from '../../utils/help.js';
  45. import Report from '@/log-center/log';
  46. import MobileGuidePage from '@/components/MobileGuidePage.vue';
  47. import { PlayType } from '@/types';
  48. const api = {
  49. prod: 'https://api.denetme.net',
  50. pre: 'https://preapi.denetme.net',
  51. test: 'https://testapi.denetme.net',
  52. };
  53. const page = {
  54. prod: 'https://h5.denetme.net',
  55. pre: 'https://preh5.denetme.net',
  56. test: 'https://testh5.denetme.net',
  57. };
  58. const jumpUrl = page[process.env.NUXT_ENV.MODE] + '/';
  59. const baseURL = api[process.env.NUXT_ENV.MODE];
  60. const ClipboardJS = require('clipboard');
  61. export default {
  62. name: 'ntf',
  63. data() {
  64. return {
  65. PlayType,
  66. isLoading: true,
  67. appVersionCode: appVersionCode,
  68. jumpUrl: jumpUrl,
  69. detail: {
  70. inviteUserInfo: {
  71. avatarUrl: '',
  72. nickName: '',
  73. },
  74. amountValue: '',
  75. currencySymbol: '',
  76. amountUsdValue: '',
  77. totalCount: '',
  78. },
  79. config: {},
  80. title: 'Treasure Hunt',
  81. isMobile: false,
  82. isChrome: false,
  83. linkHref: '',
  84. pageLink: '',
  85. };
  86. },
  87. components: {
  88. MobileGuidePage,
  89. },
  90. head() {
  91. return {
  92. type: '',
  93. title: this.title,
  94. appVersionCode: appVersionCode,
  95. meta: [
  96. // facebook
  97. {
  98. name: 'og:title',
  99. content: `Treasure Chest: ${this.detail.amountValue} ${this.detail.currencySymbol} (worth $${this.detail.amountUsdValue}) for ${this.detail.totalCount} winners`,
  100. },
  101. {
  102. name: 'og:image',
  103. content: this.detail.imagePath || '',
  104. },
  105. {
  106. name: 'og:url',
  107. content: this.pageLink,
  108. },
  109. // twitter
  110. {
  111. name: 'twitter:card',
  112. content: 'summary_large_image',
  113. },
  114. {
  115. name: 'twitter:title',
  116. content: `Treasure Chest: ${this.detail.amountValue} ${this.detail.currencySymbol} (worth $${this.detail.amountUsdValue}) for ${this.detail.totalCount} winners`,
  117. },
  118. {
  119. name: 'twitter:image',
  120. content: this.detail.imagePath || '',
  121. },
  122. ],
  123. };
  124. },
  125. async asyncData(params) {
  126. let { route } = params;
  127. let { data } = await axios.post(`${baseURL}/denet/post/treasure/invite/detail`, {
  128. baseInfo: {
  129. appVersionCode: appVersionCode,
  130. mid: (function () {
  131. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  132. var r = (Math.random() * 16) | 0,
  133. v = c == 'x' ? r : (r & 0x3) | 0x8;
  134. return v.toString(16);
  135. });
  136. })(),
  137. },
  138. params: {
  139. inviteCode: route.params.id || '',
  140. },
  141. });
  142. if (data.code == 0) {
  143. return {
  144. detail: data.data,
  145. pageLink: `${jumpUrl}treasure/invite/${route.params.id}/${route.params.channel}`,
  146. };
  147. }
  148. },
  149. created() {
  150. this.setCookieMid();
  151. this.getConfig();
  152. },
  153. mounted() {
  154. Cookies.set(this.detail.postId, JSON.stringify({ inviteCode: this.$route.params.id }), { expires: 100 });
  155. this.setTreasureInfo();
  156. setTimeout(() => {
  157. this.checkInstall()
  158. .then(() => {
  159. console.log(this.detail);
  160. if (this.detail.repostSrcContentId && this.detail.inviteUserInfo && this.detail.inviteUserInfo.nickName) {
  161. let url = `https://twitter.com/${this.detail.inviteUserInfo.nickName}/status/${this.detail.repostSrcContentId}`;
  162. window.location.replace(url);
  163. }
  164. this.isLoading = false;
  165. })
  166. .catch(() => {
  167. this.isLoading = false;
  168. });
  169. }, 1000);
  170. this.checkBrowser();
  171. var clipboard = new ClipboardJS('.btn');
  172. let that = this;
  173. clipboard.on('success', function (e) {
  174. Toast('copy success');
  175. // 埋点
  176. that.trackingClick();
  177. e.clearSelection();
  178. });
  179. this.pageSource = Report.pageSource.newUserLandingPage;
  180. // 埋点
  181. if (this.isMobile) {
  182. this.pageSource = Report.pageSource.mobileLandingPage;
  183. Report.reportLog({
  184. baseInfo: {
  185. appVersionCode: this.appVersionCode,
  186. mid: this.mid,
  187. pageSource: this.pageSource,
  188. machineCode: this.mid,
  189. },
  190. params: {
  191. eventData: {
  192. businessType: Report.businessType.pageView,
  193. shareLinkId: this.$route.params.id,
  194. postId: this.detail.postId,
  195. redPacketType: 4,
  196. },
  197. },
  198. });
  199. } else {
  200. Report.reportLog({
  201. baseInfo: {
  202. appVersionCode: appVersionCode,
  203. mid: this.mid,
  204. pageSource: this.pageSource,
  205. appType,
  206. machineCode: this.mid,
  207. },
  208. params: {
  209. eventData: {
  210. businessType: Report.businessType.pageView,
  211. postId: this.detail.postId,
  212. srcContentId: this.detail.srcContentId,
  213. redPacketType: 4,
  214. shareLinkId: this.$route.params.id,
  215. },
  216. },
  217. });
  218. }
  219. },
  220. methods: {
  221. clickBtn() {
  222. if (this.isChrome) {
  223. Report.reportLog({
  224. baseInfo: {
  225. appVersionCode: appVersionCode,
  226. mid: this.mid,
  227. pageSource: this.pageSource,
  228. appType,
  229. machineCode: this.mid,
  230. },
  231. params: {
  232. eventData: {
  233. businessType: Report.businessType.buttonClick,
  234. postId: this.detail.postId,
  235. srcContentId: this.detail.srcContentId,
  236. redPacketType: 4,
  237. shareLinkId: this.$route.params.id,
  238. },
  239. },
  240. });
  241. let { extensionsInstallUrl } = this.config;
  242. window.open(extensionsInstallUrl);
  243. } else {
  244. this.installChrome();
  245. }
  246. },
  247. checkInstall() {
  248. return new Promise((resolve, reject) => {
  249. let dom = document.querySelector('#denet_message');
  250. console.log('denet_message', dom);
  251. if (dom) {
  252. resolve(true);
  253. } else {
  254. reject(false);
  255. }
  256. });
  257. },
  258. trackingClick() {},
  259. guid() {
  260. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  261. var r = (Math.random() * 16) | 0,
  262. v = c == 'x' ? r : (r & 0x3) | 0x8;
  263. return v.toString(16);
  264. });
  265. },
  266. setCookieMid() {
  267. let _cookie_mid_arr = Cookies.get('mid') || [];
  268. if (_cookie_mid_arr.length > 0) {
  269. this.mid = JSON.parse(_cookie_mid_arr)[0].mid;
  270. } else {
  271. this.mid = this.guid();
  272. Cookies.set('mid', JSON.stringify([{ mid: this.mid }]), { expires: 1000 });
  273. }
  274. },
  275. installExtension() {
  276. // 埋点
  277. this.trackingClick();
  278. let { extensionsInstallUrl } = this.config;
  279. window.open(extensionsInstallUrl);
  280. },
  281. installChrome() {
  282. window.open('https://www.google.com/chrome');
  283. },
  284. async getConfig() {
  285. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  286. baseInfo: {
  287. appVersionCode: appVersionCode,
  288. mid: this.mid,
  289. },
  290. params: {},
  291. });
  292. if (data.code == 0) {
  293. this.config = data.data;
  294. }
  295. },
  296. checkBrowser() {
  297. this.linkHref = window.location.href;
  298. this.isChrome = isBrowser() == 'chrome';
  299. this.isMobile = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
  300. },
  301. setTreasureInfo() {
  302. let treasureInfo = {
  303. createTime: Date.now(),
  304. jump_type: 'treasure_info',
  305. srcContentId: this.detail.repostSrcContentId || '',
  306. postNickName: this.detail.inviteUserInfo.nickName,
  307. };
  308. Cookies.set('jump_info', JSON.stringify(treasureInfo), { expires: 100 });
  309. },
  310. },
  311. };
  312. </script>
  313. <style lang="scss">
  314. html,
  315. body,
  316. #__nuxt,
  317. #__layout {
  318. width: 100%;
  319. height: 100%;
  320. padding: 0;
  321. margin: 0;
  322. }
  323. .nft-content {
  324. overflow: hidden;
  325. width: 100%;
  326. height: 100%;
  327. background: linear-gradient(180deg, #d8efff 0%, #ffffff 44.3%);
  328. .loading {
  329. position: absolute;
  330. transform: translate(-50%, -50%);
  331. top: 50%;
  332. left: 50%;
  333. margin: auto;
  334. width: 40px;
  335. border-radius: 50%;
  336. }
  337. .logo {
  338. display: flex;
  339. align-items: center;
  340. height: 70px;
  341. margin-left: 25px;
  342. img {
  343. width: 99px;
  344. height: 32px;
  345. }
  346. }
  347. .show {
  348. display: flex;
  349. align-items: center;
  350. height: calc(100% - 70px);
  351. .center {
  352. margin: -50px auto 0;
  353. width: 480px;
  354. height: 260px;
  355. box-shadow: 0px 2px 18px rgba(0, 0, 0, 0.1);
  356. border-radius: 12px;
  357. display: flex;
  358. justify-content: space-between;
  359. flex-direction: column;
  360. padding: 26px;
  361. box-sizing: border-box;
  362. .content-wrapper {
  363. display: flex;
  364. justify-content: center;
  365. align-items: center;
  366. margin-top: 14px;
  367. .img {
  368. width: 70px;
  369. height: 70px;
  370. }
  371. .img-left {
  372. border-radius: 50%;
  373. }
  374. .middle {
  375. padding: 0 20px;
  376. box-sizing: border-box;
  377. .invite-txt {
  378. color: #727272;
  379. font-weight: 400;
  380. font-size: 13px;
  381. }
  382. .title {
  383. font-weight: 800;
  384. font-size: 20px;
  385. margin: 6px 3px 0;
  386. }
  387. .up-gain-txt {
  388. color: #f8bc2b;
  389. font-weight: 600;
  390. font-size: 13px;
  391. display: flex;
  392. align-items: center;
  393. .amount {
  394. font-weight: 700;
  395. font-size: 22px;
  396. }
  397. }
  398. }
  399. }
  400. .btn-wrapper {
  401. margin-top: 54px;
  402. padding: 16px;
  403. box-sizing: border-box;
  404. background: #1d9bf0;
  405. border-radius: 100px;
  406. color: #ffffff;
  407. font-weight: 700;
  408. font-size: 17px;
  409. display: flex;
  410. align-items: center;
  411. justify-content: center;
  412. cursor: pointer;
  413. .img {
  414. width: 28px;
  415. height: 28px;
  416. margin-right: 8px;
  417. }
  418. }
  419. }
  420. }
  421. }
  422. </style>