home.vue 8.4 KB

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