index.vue 11 KB

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