info.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <!-- 公共组件 -->
  3. <div class="info">
  4. <v-head :title="'Withdraw'" :show_more="true"></v-head>
  5. <!-- 内容 -->
  6. <div class="content">
  7. <div class="area-input-1">
  8. <div class="token">
  9. <div class="title">Token</div>
  10. <div class="box">
  11. <img :src="withdraw_info.icon_token" alt="">
  12. <span>{{ withdraw_info.token_symbol }}</span>
  13. </div>
  14. </div>
  15. <div class="net">
  16. <div class="title">NetWork</div>
  17. <div class="box">
  18. <img :src="withdraw_info.icon_net" alt="">
  19. <span>{{ withdraw_info.token_chain }}</span>
  20. <!-- <img :src="require('@/assets/svg/icon-botton-up.svg')" alt="" class="up"> -->
  21. </div>
  22. </div>
  23. </div>
  24. <div class="area-input-2">
  25. <div class="title">Wallet Address</div>
  26. <div class="box">
  27. <input type="text" placeholder="Click to enter" v-model="state.input_address" @input="inputText">
  28. </div>
  29. </div>
  30. <div class="area-input-3">
  31. <div class="title">
  32. <span>Withdrawal Amount</span>
  33. <span>Balance: {{ state.balance || 0 }}</span>
  34. </div>
  35. <div class="box">
  36. <input type="number" placeholder="0" @input="inputText" v-model="state.input_amount" :max="state.balance">
  37. <span @click="clickWithdrawalAll">Withdrawal All</span>
  38. </div>
  39. <div class="error">{{ state.error_msg }}</div>
  40. </div>
  41. <div class="tips">
  42. <div class="tip-title">TIPS</div>
  43. <div class="tip-content">asdasdasdasd</div>
  44. </div>
  45. </div>
  46. <!-- 底部 -->
  47. <div class="footer">
  48. <div class="left">
  49. <div class="txt">Receive Amount</div>
  50. <div class="money">{{ state.amount || 0 }} {{ state.currency_code }}</div>
  51. <div class="txt"> Network Fee: {{ state.fee_amount }} {{ withdraw_info.token_symbol }} </div>
  52. </div>
  53. <div class="right">
  54. <div class="btn" @click="clickBtn" :class="{ enter: state.is_enter_state }">Confirm</div>
  55. </div>
  56. </div>
  57. </div>
  58. </template>
  59. <script setup>
  60. import VHead from '@/view/popup/components/head.vue'
  61. import router from "@/router/popup.js";
  62. import { reactive, onMounted, inject } from 'vue'
  63. import { getWithdrawConfig } from "@/http/account";
  64. import { withdrawCalcFee } from "@/http/pay";
  65. let withdraw_info = inject('withdraw_info')
  66. let state = reactive({
  67. input_address: '',
  68. input_amount: '',
  69. is_enter_state: false,
  70. error_msg: 'Wallet Address不能为空'
  71. })
  72. const inputWithdrawCalcFee = () => {
  73. withdrawCalcFee({
  74. params: {
  75. "amountValue": state.input_amount,
  76. "currencyCode": withdraw_info.currency_code,
  77. "withdrawNetwork": withdraw_info.token_chain
  78. }
  79. }).then((res) => {
  80. if (res.code == 0) {
  81. if (res.data) {
  82. state.currency_code = res.data.currencyCode || ''
  83. state.fee_amount = res.data.feeAmountValue || 0
  84. state.amount = res.data.finalAmountValue || 111
  85. state.is_enter_state = true
  86. }
  87. }
  88. })
  89. }
  90. const inputText = () => {
  91. if (!state.withdraw_switch) {
  92. return
  93. }
  94. if (!state.input_amount == undefined || state.input_amount < 0) {
  95. state.input_amount = 0
  96. }
  97. if (state.input_address.trim().length == 0) {
  98. state.error_msg = 'Wallet Address不能为空'
  99. state.is_enter_state = false
  100. return
  101. }
  102. if (Number(state.input_amount) > Number(state.balance)) {
  103. state.error_msg = `输入金额超过钱包余额`
  104. state.is_enter_state = false
  105. state.amount = 0
  106. return
  107. }
  108. if (Number(state.input_amount) < Number(state.min_amount)) {
  109. state.error_msg = `输入金额需要高于最小提现额 ${state.min_amount}`
  110. state.is_enter_state = false
  111. state.amount = 0
  112. return
  113. } else {
  114. state.error_msg = ''
  115. inputWithdrawCalcFee()
  116. }
  117. }
  118. const clickBtn = () => {
  119. if (state.is_enter_state) {
  120. withdraw_info.data = state
  121. router.push('/withdraw/confirm')
  122. }
  123. }
  124. const initConfig = () => {
  125. state.balance = withdraw_info.balance
  126. if (withdraw_info.source == 'confirm') {
  127. state.withdraw_switch = withdraw_info.data.withdraw_switch
  128. state.input_address = withdraw_info.data.input_address
  129. state.input_amount = withdraw_info.data.input_amount
  130. state.amount = withdraw_info.data.amount
  131. state.withdraw_fee_desc = withdraw_info.data.withdraw_fee_desc
  132. inputText()
  133. } else {
  134. getWithdrawConfig({
  135. params: {
  136. "currencyCode": withdraw_info.currency_code,
  137. "withdrawNetwork": withdraw_info.token_chain
  138. }
  139. }).then((res) => {
  140. switch (res.code.toString()) {
  141. case '0':
  142. state.withdraw_switch = res.data.withdrawSwitch
  143. // 关闭提现功能
  144. if (!res.data.withdrawSwitch) {
  145. state.error_msg = '关闭提现功能'
  146. return
  147. }
  148. state.fee_amount = res.data.withdrawFee
  149. // 单次提现最小金额
  150. state.min_amount = res.data.withdrawPerMinAmount
  151. state.withdraw_fee_desc = res.data.withdrawFeeDesc
  152. break;
  153. default:
  154. break;
  155. }
  156. })
  157. }
  158. }
  159. onMounted(() => {
  160. initConfig()
  161. })
  162. const clickWithdrawalAll = () => {
  163. state.input_amount = state.balance
  164. inputText()
  165. }
  166. </script>
  167. <style lang='scss' scoped>
  168. .info {
  169. position: relative;
  170. height: 100%;
  171. .content {
  172. padding: 16px 16px 0 16px;
  173. .area-input-1 {
  174. display: flex;
  175. flex-wrap: nowrap;
  176. justify-content: space-between;
  177. .token {
  178. padding-right: 7px;
  179. }
  180. .net {
  181. padding-left: 7px;
  182. }
  183. .token,
  184. .net {
  185. width: 50%;
  186. .title {
  187. font-weight: 500;
  188. font-size: 12px;
  189. margin-bottom: 6px;
  190. color: #8B8B8B;
  191. }
  192. .box {
  193. border: 1px solid #DBDBDB;
  194. border-radius: 8px;
  195. height: 44px;
  196. display: flex;
  197. align-items: center;
  198. padding: 0 15px 0 10px;
  199. display: flex;
  200. flex-wrap: nowrap;
  201. justify-content: space-between;
  202. img {
  203. width: 20px;
  204. height: 20px;
  205. }
  206. .up {
  207. width: 13px;
  208. height: 12px;
  209. cursor: pointer;
  210. }
  211. span {
  212. flex: 1;
  213. margin-left: 6px;
  214. font-size: 14px;
  215. font-weight: 500;
  216. }
  217. }
  218. }
  219. }
  220. .area-input-2,
  221. .area-input-3 {
  222. margin-top: 25px;
  223. .title {
  224. font-weight: 500;
  225. font-size: 12px;
  226. color: #8B8B8B;
  227. margin-bottom: 6px;
  228. display: flex;
  229. justify-content: space-between;
  230. }
  231. .box {
  232. border: 1px solid #DBDBDB;
  233. border-radius: 8px;
  234. height: 44px;
  235. display: flex;
  236. align-items: center;
  237. input {
  238. outline: none;
  239. border: 0;
  240. flex: 1;
  241. height: 18px;
  242. padding: 0 16px;
  243. font-weight: 500;
  244. font-size: 15px;
  245. }
  246. input::-webkit-outer-spin-button,
  247. input::-webkit-inner-spin-button {
  248. -webkit-appearance: none;
  249. }
  250. input[type="number"] {
  251. -moz-appearance: textfield;
  252. }
  253. span {
  254. display: block;
  255. color: #1D9BF0;
  256. font-size: 13px;
  257. cursor: pointer;
  258. margin-right: 16px;
  259. }
  260. }
  261. .error {
  262. margin-top: 10px;
  263. color: #FFA621;
  264. font-weight: 400;
  265. font-size: 12px;
  266. }
  267. }
  268. .tips {
  269. margin-top: 30px;
  270. font-size: 13px;
  271. .tip-title {
  272. color: #000000;
  273. }
  274. .tip-content {
  275. color: #000000;
  276. }
  277. }
  278. }
  279. .footer {
  280. border-top: 1px solid #DBDBDB;
  281. bottom: 0;
  282. height: 80px;
  283. display: flex;
  284. position: absolute;
  285. justify-content: space-between;
  286. width: 100%;
  287. bottom: 0;
  288. align-items: center;
  289. .left {
  290. margin-left: 16px;
  291. .txt {
  292. color: #9D9D9D;
  293. font-weight: 400;
  294. font-size: 12px;
  295. }
  296. .money {
  297. color: #000000;
  298. font-weight: 500;
  299. font-size: 15px;
  300. }
  301. }
  302. .right {
  303. margin-right: 16px;
  304. .btn {
  305. cursor: pointer;
  306. width: 140px;
  307. height: 46px;
  308. line-height: 46px;
  309. text-align: center;
  310. font-weight: 600;
  311. font-size: 18px;
  312. color: #FFFFFF;
  313. background: #D2D2D2;
  314. border-radius: 100px;
  315. }
  316. .enter {
  317. background: #1D9BF0;
  318. }
  319. }
  320. }
  321. }
  322. </style>