home.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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">Buy Limit: {{ state.data.userBuyCount || 0 }}/{{ state.data.perUserBuyLimit || 0 }}
  19. </div>
  20. </div>
  21. <div class="btn-area">
  22. <template v-for="item in state.data.salePlans.splice(0, 2).reverse()">
  23. <div class="buy1" @click="clickJump(item)" v-if="item.itemCount == 1 && (state.data.perUserBuyLimit - state.data.userBuyCount) >= 1
  24. && (state.data.itemTotalCount - state.data.itemSoldCount) >= 1">
  25. <template v-if="(item.price.length + item.currencyInfo.tokenSymbol.length) > 30">
  26. <div class="left">Buy 1</div>
  27. <div class="right">
  28. <p>{{ item.price }}</p>
  29. <p>{{ item.currencyInfo.tokenSymbol }}</p>
  30. </div>
  31. </template>
  32. <template v-else>
  33. <div class="left">Buy 1</div>
  34. <div class="right">
  35. {{ item.price }}
  36. {{ item.currencyInfo.tokenSymbol }}
  37. </div>
  38. </template>
  39. </div>
  40. <div class="buy1 grey" v-if="item.itemCount == 1 && ((state.data.perUserBuyLimit - state.data.userBuyCount) <= 0
  41. || (state.data.itemTotalCount - state.data.itemSoldCount) <= 0)">
  42. <template v-if="(item.price.length + item.currencyInfo.tokenSymbol.length) > 30">
  43. <div class="left">Buy 1</div>
  44. <div class="right">
  45. <p>{{ item.price }}</p>
  46. <p>{{ item.currencyInfo.tokenSymbol }}</p>
  47. </div>
  48. </template>
  49. <template v-else>
  50. <div class="left">Buy 1</div>
  51. <div class="right">
  52. {{ item.price }}
  53. {{ item.currencyInfo.tokenSymbol }}
  54. </div>
  55. </template>
  56. </div>
  57. <div class="buy5" v-if="item.itemCount == 5 && (state.data.perUserBuyLimit - state.data.userBuyCount) >= 5 &&
  58. (state.data.itemTotalCount - state.data.itemSoldCount) >= 5" @click="clickJump(item)">
  59. <div class="left">Buy {{ item.itemCount }}</div>
  60. <div class="right" v-if="(item.price.length + item.currencyInfo.tokenSymbol.length) > 30">
  61. <div class="usdt">
  62. <p>{{ item.price }}</p>
  63. <p>{{ item.currencyInfo.tokenSymbol }}</p>
  64. </div>
  65. <div class="off">
  66. <p>{{ item.discount }}</p>
  67. </div>
  68. </div>
  69. <div class="right" v-else>
  70. <div class="usdt">{{ item.price }} {{ item.currencyInfo.tokenSymbol }}</div>
  71. <div class="off">{{ item.discount }}</div>
  72. </div>
  73. </div>
  74. </template>
  75. </div>
  76. </div>
  77. </div>
  78. </template>
  79. <script setup>
  80. import { useRouter } from 'vue-router'
  81. import { onMounted, reactive, inject, } from "vue";
  82. import { getNftMysteryBoxSaleInfo } from "@/http/nft";
  83. import BtnLoading from '../components/btn-loading.vue'
  84. import { getQueryString } from "@/uilts/help";
  85. let pay_info = inject('pay_info');
  86. const router = useRouter()
  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. } else {
  148. }
  149. }).catch(() => {
  150. })
  151. })
  152. </script>
  153. <style lang="scss" scoped>
  154. .dialog {
  155. background: #fff;
  156. border-radius: 25px;
  157. max-width: 1000px;
  158. min-width: 1000px;
  159. max-height: 90%;
  160. z-index: 23;
  161. display: flex;
  162. flex-direction: column;
  163. .area-title {
  164. width: 100%;
  165. min-height: 48px;
  166. display: flex;
  167. align-items: center;
  168. border-bottom: 1px solid #D9D9D9;
  169. font-weight: 500;
  170. font-size: 16px;
  171. letter-spacing: 0.3px;
  172. color: #000000;
  173. img {
  174. width: 24p;
  175. height: 24px;
  176. margin-left: 14px;
  177. margin-right: 12px;
  178. cursor: pointer;
  179. }
  180. }
  181. .area-content {
  182. flex: 1;
  183. overflow-y: auto;
  184. img {
  185. width: 100%;
  186. object-fit: contain;
  187. }
  188. }
  189. .footer {
  190. border-top: 1px solid #D9D9D9;
  191. width: 100%;
  192. display: flex;
  193. align-items: center;
  194. justify-content: space-between;
  195. .loading {
  196. width: 24px;
  197. }
  198. .mark {
  199. margin-left: 20px;
  200. .sold {
  201. margin-bottom: 7px;
  202. }
  203. .limit {
  204. color: #AF934E;
  205. margin-right: 25px;
  206. }
  207. }
  208. .btn-area {
  209. height: 100%;
  210. display: flex;
  211. padding: 15px 0;
  212. min-height: 50px;
  213. box-sizing: border-box;
  214. .buy5 {
  215. border: 1px solid #1D9BF0;
  216. background: rgba(29, 155, 240, 0.01);
  217. border-radius: 100px;
  218. color: #1D9BF0;
  219. min-width: 217px;
  220. display: flex;
  221. justify-content: space-between;
  222. align-items: center;
  223. padding: 10px 15px 10px 20px;
  224. font-weight: 700;
  225. font-size: 14px;
  226. cursor: pointer;
  227. margin-right: 12px;
  228. box-sizing: border-box;
  229. .left {
  230. margin-right: 20px;
  231. }
  232. .right {
  233. text-align: right;
  234. line-height: 17px;
  235. p {
  236. margin: 0;
  237. padding: 0;
  238. line-height: 17px;
  239. }
  240. }
  241. .off {
  242. color: #AF934E;
  243. font-weight: 700;
  244. font-size: 12px;
  245. letter-spacing: 0.3px;
  246. }
  247. .usdt {
  248. color: #1D9BF0;
  249. font-size: 14px;
  250. font-weight: 700;
  251. }
  252. }
  253. .buy1 {
  254. cursor: pointer;
  255. background: #1D9BF0;
  256. color: #fff;
  257. border-radius: 100px;
  258. min-width: 217px;
  259. display: flex;
  260. align-items: center;
  261. font-size: 14px;
  262. font-weight: 700;
  263. justify-content: space-between;
  264. padding: 0 15px 0 20px;
  265. margin-right: 25px;
  266. box-sizing: border-box;
  267. .left {
  268. margin-right: 20px;
  269. }
  270. .right {
  271. line-height: 17px;
  272. text-align: right;
  273. p {
  274. margin: 0;
  275. padding: 0;
  276. line-height: 17px;
  277. }
  278. }
  279. }
  280. .grey {
  281. background: #CDCDCD;
  282. cursor: not-allowed;
  283. }
  284. }
  285. }
  286. }
  287. </style>