invite.vue 13 KB

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