invite.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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. <MobileLandPage :playType="PlayType.Treasure" :useFul="true" :userInfo="detail.inviteUserInfo" :usValue="detail.upGainAmountValue" :postId="detail.postId" :srcContentId="detail.srcContentId"></MobileLandPage>
  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 } from '../../utils/help.js';
  45. import Report from '@/log-center/log';
  46. import MobileLandPage from '@/components/MobileLandPage.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. },
  75. config: {},
  76. title: 'Treasure Hunt',
  77. isMobile: false,
  78. isChrome: false,
  79. linkHref: '',
  80. metaTitle: 'DeNet: An Easy Web3 Tool For GIVEAWAY / AIRDROP',
  81. };
  82. },
  83. components: {
  84. MobileLandPage,
  85. },
  86. head() {
  87. return {
  88. type: '',
  89. title: this.title,
  90. appVersionCode: appVersionCode,
  91. meta: [
  92. // facebook
  93. {
  94. name: 'og:title',
  95. content: this.metaTitle,
  96. },
  97. {
  98. name: 'og:image',
  99. content: this.detail.imagePath || '',
  100. },
  101. // twitter
  102. {
  103. name: 'twitter:card',
  104. content: 'summary_large_image',
  105. },
  106. {
  107. name: 'twitter:title',
  108. content: this.metaTitle,
  109. },
  110. {
  111. name: 'twitter:image',
  112. content: this.detail.imagePath || '',
  113. },
  114. ],
  115. };
  116. },
  117. async asyncData(params) {
  118. let { route } = params;
  119. let { data } = await axios.post(`${baseURL}/denet/post/treasure/invite/detail`, {
  120. baseInfo: {
  121. appVersionCode: appVersionCode,
  122. mid: (function () {
  123. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  124. var r = (Math.random() * 16) | 0,
  125. v = c == 'x' ? r : (r & 0x3) | 0x8;
  126. return v.toString(16);
  127. });
  128. })(),
  129. },
  130. params: {
  131. inviteCode: route.params.id || '',
  132. },
  133. });
  134. if (data.code == 0) {
  135. return {
  136. detail: data.data,
  137. };
  138. }
  139. },
  140. created() {
  141. this.setCookieMid();
  142. this.getConfig();
  143. },
  144. mounted() {
  145. Cookies.set(this.detail.postId, JSON.stringify({ inviteCode: this.$route.params.id }), { expires: 100 });
  146. setTimeout(() => {
  147. this.checkInstall()
  148. .then(() => {
  149. console.log(this.detail, 'detail');
  150. if (this.detail.srcContentId && this.detail.postUserInfo && this.detail.postUserInfo.nickName) {
  151. let url = `https://twitter.com/${this.detail.postUserInfo.nickName}/status/${this.detail.srcContentId}`;
  152. window.open(url);
  153. }
  154. })
  155. .catch(() => {
  156. this.setTreasureInfo();
  157. });
  158. }, 600);
  159. this.checkBrowser();
  160. this.isLoading = false;
  161. var clipboard = new ClipboardJS('.btn');
  162. let that = this;
  163. clipboard.on('success', function (e) {
  164. Toast('copy success');
  165. // 埋点
  166. that.trackingClick();
  167. e.clearSelection();
  168. });
  169. this.pageSource = Report.pageSource.newUserLandingPage;
  170. // 埋点
  171. if (this.isMobile) {
  172. this.pageSource = Report.pageSource.mobileLandingPage;
  173. }
  174. // Report.reportLog({
  175. // baseInfo: {
  176. // appVersionCode: appVersionCode,
  177. // mid: this.mid,
  178. // pageSource: this.pageSource,
  179. // appType,
  180. // machineCode: this.mid
  181. // },
  182. // params: {
  183. // eventData: {
  184. // businessType: Report.businessType.pageView,
  185. // postId: this.detail.postId,
  186. // srcContentId: this.detail.srcContentId,
  187. // senderId: this.detail.srcUserId,
  188. // redPacketType: 2,
  189. // }
  190. // }
  191. // })
  192. },
  193. methods: {
  194. clickBtn() {
  195. if (this.isChrome) {
  196. let { extensionsInstallUrl } = this.config;
  197. window.open(extensionsInstallUrl);
  198. } else {
  199. this.installChrome();
  200. }
  201. },
  202. checkInstall() {
  203. return new Promise((resolve, reject) => {
  204. let dom = document.querySelector('#denet_message');
  205. console.log('denet_message', dom);
  206. if (dom) {
  207. resolve(true);
  208. } else {
  209. reject(false);
  210. }
  211. });
  212. },
  213. trackingClick() {
  214. // Report.reportLog({
  215. // baseInfo: {
  216. // appVersionCode: appVersionCode,
  217. // mid: this.mid,
  218. // pageSource: this.pageSource,
  219. // appType,
  220. // machineCode: this.mid
  221. // },
  222. // params: {
  223. // eventData: {
  224. // businessType: Report.businessType.buttonClick,
  225. // objectType: Report.objectType.installButton,
  226. // postId: this.detail.postId,
  227. // srcContentId: this.detail.srcContentId,
  228. // senderId: this.detail.srcUserId,
  229. // redPacketType: 2,
  230. // }
  231. // }
  232. // })
  233. },
  234. guid() {
  235. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  236. var r = (Math.random() * 16) | 0,
  237. v = c == 'x' ? r : (r & 0x3) | 0x8;
  238. return v.toString(16);
  239. });
  240. },
  241. setCookieMid() {
  242. let _cookie_mid_arr = Cookies.get('mid') || [];
  243. if (_cookie_mid_arr.length > 0) {
  244. this.mid = JSON.parse(_cookie_mid_arr)[0].mid;
  245. } else {
  246. this.mid = this.guid();
  247. Cookies.set('mid', JSON.stringify([{ mid: this.mid }]), { expires: 1000 });
  248. }
  249. },
  250. installExtension() {
  251. // 埋点
  252. this.trackingClick();
  253. let { extensionsInstallUrl } = this.config;
  254. window.open(extensionsInstallUrl);
  255. },
  256. installChrome() {
  257. window.open('https://www.google.com/chrome');
  258. },
  259. async getConfig() {
  260. let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
  261. baseInfo: {
  262. appVersionCode: appVersionCode,
  263. mid: this.mid,
  264. },
  265. params: {},
  266. });
  267. if (data.code == 0) {
  268. this.config = data.data;
  269. }
  270. },
  271. checkBrowser() {
  272. this.linkHref = window.location.href;
  273. this.isChrome = isBrowser() == 'chrome';
  274. 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);
  275. },
  276. setTreasureInfo() {
  277. let treasureInfo = {
  278. createTime: Date.now(),
  279. jump_type: 'treasure_info',
  280. srcContentId: this.detail.srcContentId || '',
  281. postNickName: this.detail.postUserInfo.nickName,
  282. };
  283. Cookies.set('jump_info', JSON.stringify(treasureInfo), { expires: 100 });
  284. },
  285. },
  286. };
  287. </script>
  288. <style lang="scss">
  289. html,
  290. body,
  291. #__nuxt,
  292. #__layout {
  293. width: 100%;
  294. height: 100%;
  295. padding: 0;
  296. margin: 0;
  297. }
  298. .nft-content {
  299. overflow: hidden;
  300. width: 100%;
  301. height: 100%;
  302. background: linear-gradient(180deg, #d8efff 0%, #ffffff 44.3%);
  303. .loading {
  304. position: absolute;
  305. transform: translate(-50%, -50%);
  306. top: 50%;
  307. left: 50%;
  308. margin: auto;
  309. width: 40px;
  310. border-radius: 50%;
  311. }
  312. .logo {
  313. display: flex;
  314. align-items: center;
  315. height: 70px;
  316. margin-left: 25px;
  317. img {
  318. width: 99px;
  319. height: 32px;
  320. }
  321. }
  322. .show {
  323. display: flex;
  324. align-items: center;
  325. height: calc(100% - 70px);
  326. .center {
  327. margin: -50px auto 0;
  328. width: 480px;
  329. height: 260px;
  330. box-shadow: 0px 2px 18px rgba(0, 0, 0, 0.1);
  331. border-radius: 12px;
  332. display: flex;
  333. justify-content: space-between;
  334. flex-direction: column;
  335. padding: 26px;
  336. box-sizing: border-box;
  337. .content-wrapper {
  338. display: flex;
  339. justify-content: center;
  340. align-items: center;
  341. margin-top: 14px;
  342. .img {
  343. width: 70px;
  344. height: 70px;
  345. }
  346. .img-left {
  347. border-radius: 50%;
  348. }
  349. .middle {
  350. padding: 0 20px;
  351. box-sizing: border-box;
  352. .invite-txt {
  353. color: #727272;
  354. font-weight: 400;
  355. font-size: 13px;
  356. }
  357. .title {
  358. font-weight: 800;
  359. font-size: 20px;
  360. margin: 6px 3px 0;
  361. }
  362. .up-gain-txt {
  363. color: #f8bc2b;
  364. font-weight: 600;
  365. font-size: 13px;
  366. display: flex;
  367. align-items: center;
  368. .amount {
  369. font-weight: 700;
  370. font-size: 22px;
  371. }
  372. }
  373. }
  374. }
  375. .btn-wrapper {
  376. margin-top: 54px;
  377. padding: 16px;
  378. box-sizing: border-box;
  379. background: #1d9bf0;
  380. border-radius: 100px;
  381. color: #ffffff;
  382. font-weight: 700;
  383. font-size: 17px;
  384. display: flex;
  385. align-items: center;
  386. justify-content: center;
  387. cursor: pointer;
  388. .img {
  389. width: 28px;
  390. height: 28px;
  391. margin-right: 8px;
  392. }
  393. }
  394. }
  395. }
  396. }
  397. </style>