index.vue 13 KB

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