transfer.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <div class="info">
  3. <v-head
  4. :title="'Transfer'"
  5. :show_more="true"
  6. :transactionsRouterParams="{
  7. backUrl: 'back'
  8. }">
  9. </v-head>
  10. <template v-if="!isSuccess">
  11. <div class="content">
  12. <div class="token">
  13. <div class="title">Network</div>
  14. <div class="box">
  15. <img :src="transChainInfo?.iconPath" alt="" />
  16. <span>{{ transChainInfo?.chainName }}</span>
  17. </div>
  18. </div>
  19. <div class="token">
  20. <div class="title">Address</div>
  21. <div class="box">
  22. <input type="text" v-model="address" placeholder="Click to enter" />
  23. </div>
  24. </div>
  25. </div>
  26. <div class="footer">
  27. <div class="left">
  28. <div class="txt">Network fee</div>
  29. <span class="money"><a-tooltip :title="feeAmountValue || 0" >{{getBit(feeAmountValue || 0)}}</a-tooltip> {{ feeCurrencyInfo?.tokenSymbol }}</span>
  30. <div class="tips" v-if="showTips">Insufficient balance</div>
  31. </div>
  32. <div class="right">
  33. <div class="btn enter" @click="next" v-if="isNext">Confirm</div>
  34. <div class="btn" v-else>Confirm</div>
  35. </div>
  36. </div>
  37. </template>
  38. <template v-else>
  39. <div class="withdraw-status">
  40. <img :src="require('@/assets/svg/icon-withdraw-status.svg')" alt="" />
  41. <div>
  42. <div class="title">Submitted successfully</div>
  43. <div class="desc">
  44. Please check the status at the message tab
  45. </div>
  46. </div>
  47. </div>
  48. <div class="confirm-btn" @click="doneHandle">Done</div>
  49. </template>
  50. </div>
  51. </template>
  52. <script setup>
  53. import Report from "@/log-center/log"
  54. import { ref, onMounted, watchEffect } from 'vue'
  55. import { message } from 'ant-design-vue';
  56. import { getCurrencyInfoByCode } from '@/http/publishApi'
  57. import { transferRequest } from '@/http/nft'
  58. import router from "@/router/popup.js";
  59. import VHead from '@/view/popup/components/head.vue'
  60. import Zoom from '@/view/components/component-zoom.vue'
  61. import { getBit } from "@/uilts/help";
  62. const isNext = ref(false)
  63. const isSuccess = ref(false)
  64. const isPayment = ref(false)
  65. const showTips = ref(false)
  66. const transChainInfo = ref({})
  67. const feeAmountValue = ref(0)
  68. const feeCurrencyInfo = ref({})
  69. const address = ref('')
  70. const nftId = ref('')
  71. const getCurrentyInfo = (data) => {
  72. getCurrencyInfoByCode({
  73. params: {
  74. currencyCode: data?.currencyCode
  75. }
  76. }).then(res => {
  77. let { code, data } = res;
  78. if (code === 0) {
  79. isPayment.value = Number(data?.balance) >= Number(feeAmountValue.value)
  80. showTips.value = Number(data?.balance) < Number(feeAmountValue.value)
  81. }
  82. })
  83. }
  84. const next = () => {
  85. transferRequest({
  86. params: {
  87. nftItemId: nftId.value,
  88. receiveAddress: address.value
  89. }
  90. }).then(res => {
  91. let { code } = res;
  92. let transfer;
  93. if (code === 0) {
  94. isSuccess.value = true;
  95. transfer = 'success'
  96. } else if (code === 5302) {
  97. transfer = 'fail'
  98. message.error(`NFT transfer is under system maintenance, try again in two or three hours.`);
  99. } else {
  100. transfer = 'fail'
  101. message.error(`Transfer failed, please try again`);
  102. }
  103. // report
  104. Report.reportLog({
  105. pageSource: Report.pageSource.denetNftTransferPage,
  106. businessType: Report.businessType.buttonClick,
  107. objectType: Report.objectType.confirm_transfer_button,
  108. }, {
  109. transfer: transfer
  110. });
  111. })
  112. }
  113. const doneHandle = () => {
  114. router.push({ name: 'NFT' })
  115. }
  116. watchEffect(() => {
  117. isNext.value = address.value !== '' && isPayment.value
  118. })
  119. onMounted(() => {
  120. let { params = '{}' } = router.currentRoute.value.query;
  121. let { chainInfo, nftItemId, transferFeeAmountValue, transferFeeCurrencyInfo } = JSON.parse(params);
  122. // set
  123. nftId.value = nftItemId;
  124. transChainInfo.value = chainInfo
  125. feeAmountValue.value = transferFeeAmountValue
  126. feeCurrencyInfo.value = transferFeeCurrencyInfo
  127. getCurrentyInfo(feeCurrencyInfo.value)
  128. // report
  129. Report.reportLog({
  130. pageSource: Report.pageSource.denetNftTransferPage,
  131. businessType: Report.businessType.pageView,
  132. });
  133. })
  134. </script>
  135. <style lang="scss" scoped>
  136. .info {
  137. position: relative;
  138. height: 100%;
  139. .content {
  140. height: calc(100% - 48px - 80px);
  141. overflow: auto;
  142. padding: 13px 16px 0 13px;
  143. .token {
  144. margin-bottom: 20px;
  145. .title {
  146. font-weight: 500;
  147. font-size: 12px;
  148. margin-bottom: 6px;
  149. color: #8B8B8B;
  150. }
  151. .box {
  152. border: 1px solid #DBDBDB;
  153. border-radius: 8px;
  154. height: 44px;
  155. display: flex;
  156. align-items: center;
  157. padding: 0 15px 0 10px;
  158. display: flex;
  159. flex-wrap: nowrap;
  160. justify-content: space-between;
  161. img {
  162. width: 20px;
  163. height: 20px;
  164. }
  165. .up {
  166. width: 13px;
  167. height: 12px;
  168. cursor: pointer;
  169. }
  170. input {
  171. outline: none;
  172. border: 0;
  173. flex: 1;
  174. height: 18px;
  175. padding: 0 6px;
  176. font-weight: 500;
  177. font-size: 15px;
  178. &::placeholder {
  179. color: #B8B8B8;
  180. }
  181. }
  182. input::-webkit-outer-spin-button,
  183. input::-webkit-inner-spin-button {
  184. -webkit-appearance: none;
  185. }
  186. input[type='number'] {
  187. -moz-appearance: textfield;
  188. }
  189. span {
  190. flex: 1;
  191. margin-left: 6px;
  192. font-size: 14px;
  193. font-weight: 500;
  194. }
  195. }
  196. }
  197. }
  198. .footer {
  199. z-index: 11;
  200. background: #fff;
  201. border-top: 1px solid #DBDBDB;
  202. bottom: 0;
  203. height: 80px;
  204. display: flex;
  205. position: absolute;
  206. justify-content: space-between;
  207. width: 100%;
  208. bottom: 0;
  209. align-items: center;
  210. .left {
  211. margin-left: 16px;
  212. .txt {
  213. color: #9D9D9D;
  214. font-weight: 400;
  215. font-size: 12px;
  216. }
  217. .money {
  218. color: #000000;
  219. margin-right: auto;
  220. font-size: 15px;
  221. font-weight: bold;
  222. }
  223. .tips {
  224. color: #FF0000;
  225. font-weight: 500;
  226. font-size: 12px;
  227. }
  228. }
  229. .right {
  230. margin-right: 16px;
  231. .btn {
  232. cursor: pointer;
  233. width: 140px;
  234. height: 46px;
  235. line-height: 46px;
  236. text-align: center;
  237. font-weight: 600;
  238. font-size: 18px;
  239. color: #FFFFFF;
  240. background: #D2D2D2;
  241. border-radius: 100px;
  242. }
  243. .enter {
  244. background: #1D9BF0;
  245. }
  246. }
  247. }
  248. }
  249. .withdraw-status {
  250. text-align: center;
  251. img {
  252. margin-top: 40px;
  253. margin-bottom: 34px;
  254. }
  255. .title {
  256. font-weight: 500;
  257. font-size: 20px;
  258. margin-bottom: 10px;
  259. }
  260. .desc {
  261. font-size: 15px;
  262. color: rgba($color: #000000, $alpha: 0.5);
  263. }
  264. }
  265. .confirm-btn {
  266. width: 335px;
  267. height: 60px;
  268. text-align: center;
  269. line-height: 60px;
  270. border-radius: 100px;
  271. background: #1D9BF0;
  272. font-weight: 600;
  273. font-size: 18px;
  274. color: #fff;
  275. position: absolute;
  276. left: 50%;
  277. bottom: 35px;
  278. transform: translateX(-50%);
  279. display: flex;
  280. align-items: center;
  281. justify-content: center;
  282. cursor: pointer;
  283. }
  284. </style>