home.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div class="dialog" :style="{'height': dialogStyle.height + 'px'}">
  3. <!-- home -->
  4. <div class="area-title">
  5. <img :src="require('@/assets/svg/icon-close.svg')" @click="clickClose" />
  6. <div class="title">NFT Mystery box</div>
  7. </div>
  8. <!-- 内容 -->
  9. <div class="area-content">
  10. <img :src="state.data.mysteryBoxImagePath" class="box" v-show="state.data.mysteryBoxImagePath" />
  11. <img :src="require('@/assets/svg/icon-default.svg')" class="box" v-show="!state.data.mysteryBoxImagePath" />
  12. </div>
  13. <!-- 底部 -->
  14. <div class="footer" v-show="state.data.mysteryBoxImagePath">
  15. <!-- 首页 -->
  16. <div class="mark">
  17. <div class="sold">SOLD: {{ state.data.itemSoldCount || 0 }}/{{ state.data.itemTotalCount || 0 }} </div>
  18. <div class="limit" v-if="showDesc">Buy Limit: {{ state.data.userBuyCount || 0 }}/{{ state.data.perUserBuyLimit || 0 }}</div>
  19. </div>
  20. <div class="btn-area">
  21. <template v-for="item in state.data.salePlans.splice(0, 2).reverse()">
  22. <div class="buy1" @click="clickJump(item)" v-if="item.itemCount == 1 && (state.data.perUserBuyLimit - state.data.userBuyCount) >= 1
  23. && (state.data.itemTotalCount - state.data.itemSoldCount) >= 1">
  24. <template v-if="(item.price.length + item.currencyInfo.tokenSymbol.length) > 30">
  25. <div class="left">Buy 1</div>
  26. <div class="right">
  27. <p>{{ item.price }}</p>
  28. <p>{{ item.currencyInfo.tokenSymbol }}</p>
  29. </div>
  30. </template>
  31. <template v-else>
  32. <div class="left">Buy 1</div>
  33. <div class="right">
  34. {{ item.price }}
  35. {{ item.currencyInfo.tokenSymbol }}
  36. </div>
  37. </template>
  38. </div>
  39. <div class="buy1 grey" v-if="item.itemCount == 1 && ((state.data.perUserBuyLimit - state.data.userBuyCount) <= 0
  40. || (state.data.itemTotalCount - state.data.itemSoldCount) <= 0)">
  41. <template v-if="(item.price.length + item.currencyInfo.tokenSymbol.length) > 30">
  42. <div class="left">Buy 1</div>
  43. <div class="right">
  44. <p>{{ item.price }}</p>
  45. <p>{{ item.currencyInfo.tokenSymbol }}</p>
  46. </div>
  47. </template>
  48. <template v-else>
  49. <div class="left">Buy 1</div>
  50. <div class="right">
  51. {{ item.price }}
  52. {{ item.currencyInfo.tokenSymbol }}
  53. </div>
  54. </template>
  55. </div>
  56. <div class="buy5" v-if="item.itemCount == 5 && (state.data.perUserBuyLimit - state.data.userBuyCount) >= 5 &&
  57. (state.data.itemTotalCount - state.data.itemSoldCount) >= 5" @click="clickJump(item)">
  58. <div class="left">Buy {{ item.itemCount }}</div>
  59. <div class="right" v-if="(item.price.length + item.currencyInfo.tokenSymbol.length) > 30">
  60. <div class="usdt">
  61. <p>{{ item.price }}</p>
  62. <p>{{ item.currencyInfo.tokenSymbol }}</p>
  63. </div>
  64. <div class="off">
  65. <p>{{ item.discount }}</p>
  66. </div>
  67. </div>
  68. <div class="right" v-else>
  69. <div class="usdt">{{ item.price }} {{ item.currencyInfo.tokenSymbol }}</div>
  70. <div class="off">{{ item.discount }}</div>
  71. </div>
  72. </div>
  73. </template>
  74. </div>
  75. </div>
  76. </div>
  77. </template>
  78. <script setup>
  79. import { useRouter } from 'vue-router'
  80. import { onMounted, reactive, inject, ref } from "vue";
  81. import { getNftMysteryBoxSaleInfo } from "@/http/nft";
  82. import BtnLoading from '../components/btn-loading.vue'
  83. import { getQueryString } from "@/uilts/help";
  84. let pay_info = inject('pay_info');
  85. let router = useRouter()
  86. let showDesc = ref(true)
  87. let dialogStyle = reactive({
  88. height: '800'
  89. })
  90. let state = reactive({
  91. data: {
  92. salePlans: [
  93. {
  94. currencyCode: 'BSC_TESTNET_BF_6X',
  95. discount: '20$',
  96. itemCount: 5,
  97. price: 23,
  98. salePlanId: '2'
  99. },
  100. {
  101. currencyCode: 'BSC_TESTNET_BF_6X',
  102. discount: '20$',
  103. itemCount: 1,
  104. price: 123,
  105. salePlanId: '123'
  106. }
  107. ]
  108. }
  109. })
  110. const clickClose = () => {
  111. chrome.tabs.getCurrent((tab) => {
  112. chrome.tabs.sendMessage(tab.id, {
  113. actionType: "IFRAME_TWITTER_HIDE_BUY_NFT",
  114. }, (res) => { });
  115. })
  116. }
  117. const clickJump = (item) => {
  118. pay_info.home.sale_plan = item
  119. router.push({ path: '/pay' });
  120. }
  121. const setDialogStyle = () => {
  122. let clientHeight = window.innerHeight;
  123. if(clientHeight >= 840) {
  124. dialogStyle.height = 800;
  125. } else {
  126. dialogStyle.height = clientHeight - 40;
  127. }
  128. }
  129. onMounted(() => {
  130. setDialogStyle();
  131. let nft_project_Id = router.currentRoute.value.query.nftProjectId
  132. let nft_group_Id = router.currentRoute.value.query.nft_group_Id
  133. if(nft_group_Id){
  134. pay_info.nft_group_Id = nft_group_Id
  135. }
  136. if (!nft_project_Id) {
  137. return
  138. }
  139. getNftMysteryBoxSaleInfo({
  140. params: {
  141. nftProjectId: nft_project_Id
  142. }
  143. }).then((res) => {
  144. if (res.code == 0) {
  145. state.data = res.data
  146. pay_info.home = res.data
  147. let { perUserBuyLimit, itemTotalCount } = res.data;
  148. if (perUserBuyLimit && itemTotalCount && perUserBuyLimit >= itemTotalCount) {
  149. showDesc.value = false;
  150. }
  151. } else {
  152. }
  153. }).catch(() => {
  154. })
  155. })
  156. </script>
  157. <style lang="scss" scoped>
  158. .dialog {
  159. background: #fff;
  160. border-radius: 25px;
  161. max-width: 1000px;
  162. min-width: 1000px;
  163. max-height: 90%;
  164. z-index: 23;
  165. display: flex;
  166. flex-direction: column;
  167. .area-title {
  168. width: 100%;
  169. min-height: 48px;
  170. display: flex;
  171. align-items: center;
  172. border-bottom: 1px solid #D9D9D9;
  173. font-weight: 500;
  174. font-size: 16px;
  175. letter-spacing: 0.3px;
  176. color: #000000;
  177. img {
  178. width: 24p;
  179. height: 24px;
  180. margin-left: 14px;
  181. margin-right: 12px;
  182. cursor: pointer;
  183. }
  184. }
  185. .area-content {
  186. flex: 1;
  187. overflow-y: auto;
  188. img {
  189. width: 100%;
  190. object-fit: contain;
  191. }
  192. }
  193. .footer {
  194. border-top: 1px solid #D9D9D9;
  195. width: 100%;
  196. display: flex;
  197. align-items: center;
  198. justify-content: space-between;
  199. .loading {
  200. width: 24px;
  201. }
  202. .mark {
  203. margin-left: 20px;
  204. .sold {
  205. margin-bottom: 7px;
  206. }
  207. .limit {
  208. color: #AF934E;
  209. margin-right: 25px;
  210. }
  211. }
  212. .btn-area {
  213. height: 100%;
  214. display: flex;
  215. padding: 15px 0;
  216. min-height: 50px;
  217. box-sizing: border-box;
  218. .buy5 {
  219. border: 1px solid #1D9BF0;
  220. background: rgba(29, 155, 240, 0.01);
  221. border-radius: 100px;
  222. color: #1D9BF0;
  223. min-width: 217px;
  224. display: flex;
  225. justify-content: space-between;
  226. align-items: center;
  227. padding: 10px 15px 10px 20px;
  228. font-weight: 700;
  229. font-size: 14px;
  230. cursor: pointer;
  231. margin-right: 12px;
  232. box-sizing: border-box;
  233. .left {
  234. margin-right: 20px;
  235. }
  236. .right {
  237. text-align: right;
  238. line-height: 17px;
  239. p {
  240. margin: 0;
  241. padding: 0;
  242. line-height: 17px;
  243. }
  244. }
  245. .off {
  246. color: #AF934E;
  247. font-weight: 700;
  248. font-size: 12px;
  249. letter-spacing: 0.3px;
  250. }
  251. .usdt {
  252. color: #1D9BF0;
  253. font-size: 14px;
  254. font-weight: 700;
  255. }
  256. }
  257. .buy1 {
  258. cursor: pointer;
  259. background: #1D9BF0;
  260. color: #fff;
  261. border-radius: 100px;
  262. min-width: 217px;
  263. display: flex;
  264. align-items: center;
  265. font-size: 14px;
  266. font-weight: 700;
  267. justify-content: space-between;
  268. padding: 0 15px 0 20px;
  269. margin-right: 25px;
  270. box-sizing: border-box;
  271. min-height: 50px;
  272. .left {
  273. margin-right: 20px;
  274. }
  275. .right {
  276. line-height: 17px;
  277. text-align: right;
  278. p {
  279. margin: 0;
  280. padding: 0;
  281. line-height: 17px;
  282. }
  283. }
  284. }
  285. .grey {
  286. background: #CDCDCD;
  287. cursor: not-allowed;
  288. }
  289. }
  290. }
  291. }
  292. </style>