index.vue 13 KB

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