zhangwei 3 éve
szülő
commit
a06a269782

+ 1 - 0
package.json

@@ -18,6 +18,7 @@
     "element-plus": "^2.1.10",
     "eslint": "^8.13.0",
     "eslint-plugin-vue": "^8.7.0",
+    "mathjs": "^10.5.0",
     "moment": "^2.29.1",
     "node-sass": "^7.0.1",
     "postcss-import": "^14.0.2",

+ 5 - 0
src/entry/popup.js

@@ -6,6 +6,11 @@ const app = createApp(App)
 // 引入路由对象实例
 import router from '@/router/popup.js'
 import { message } from "ant-design-vue";
+message.config({
+    top: `10px`,
+    duration: 3,
+    maxCount: 1,
+});
 app.use(message);
 import "ant-design-vue/dist/antd.css"; // or 'ant-design-vue/dist/antd.less'
 

+ 4 - 1
src/view/popup/popup.vue

@@ -446,6 +446,7 @@ const clickTopUp = () => {
     router.push('/top-up/home');
 }
 
+
 </script>
 
 <style lang="scss">
@@ -652,9 +653,11 @@ body {
                                 display: flex;
                                 justify-content: flex-end;
                                 align-items: center;
-                                span{
+
+                                span {
                                     margin-left: 3px;
                                 }
+
                                 img {
                                     margin-left: 4px;
                                     width: 14px;

+ 1 - 1
src/view/popup/top-up/home.vue

@@ -21,7 +21,7 @@ function selectCurrency(_params) {
     top_up_info.currency_code = _params.currencyCode
     top_up_info.icon_token = _params.iconPath || ''
     top_up_info.icon_net = require('@/assets/svg/icon-BNB.svg')
-    router.push({ path: '/top-up/info', query: { tokenChain: 123 } });
+    router.push({ path: '/top-up/info'});
 }
 </script>
 

+ 23 - 29
src/view/popup/top-up/info.vue

@@ -53,11 +53,7 @@ import { useRouter } from "vue-router";
 import { useRoute } from "vue-router";
 import { getTokenRechargeAddress } from "@/http/pay";
 import { message } from 'ant-design-vue';
-message.config({
-    top: `10px`,
-    duration: 3,
-    maxCount: 1,
-});
+
 
 let top_up_info = inject('top_up_info')
 
@@ -66,7 +62,7 @@ const route = useRoute()
 var QRCode = require('qrcode')
 var ClipboardJS = require('clipboard')
 let state = reactive({
-    token_address: '123'
+    token_address: ''
 })
 
 const clickDone = () => {
@@ -108,27 +104,24 @@ const copyToken = () => {
 }
 
 onMounted(() => {
-    state.token_address = '123'
-    createQRCode(state.token_address)
-    copyToken()
-    // getTokenRechargeAddress({
-    //     params: {
-    //         "tokenChain": route.query.tokenChain || ''
-    //     },
-    // }).then((res) => {
-    //     switch (res.code.toString()) {
-    //         case '0':
-    //             if (res.data && res.data.rechargeAddress) {
-    //                 state.token_address = res.data.rechargeAddress
-    //                 createQRCode(state.token_address)
-    //                 copyToken()
-    //             }
-    //             break;
-
-    //         default:
-    //             break;
-    //     }
-    // })
+    getTokenRechargeAddress({
+        params: {
+            "tokenChain": top_up_info.net
+        },
+    }).then((res) => {
+        switch (res.code.toString()) {
+            case '0':
+                if (res.data && res.data.rechargeAddress) {
+                    state.token_address = res.data.rechargeAddress
+                    createQRCode(state.token_address)
+                    copyToken()
+                }
+                break;
+
+            default:
+                break;
+        }
+    })
 
 })
 
@@ -211,14 +204,15 @@ onMounted(() => {
                 font-size: 15px;
                 width: 100%;
                 text-align: center;
+                word-break: break-all;
             }
 
             .copy-btn {
                 cursor: pointer;
-                margin-top: 22px;
+                margin-top: 5px;
                 width: 160px;
                 height: 40px;
-                line-height: 40px;
+                line-height: 38px;
                 text-align: center;
                 font-size: 16px;
                 color: #389AFF;

+ 30 - 18
src/view/popup/withdraw/confirm.vue

@@ -59,31 +59,42 @@ import { reactive, inject } from 'vue'
 import VHead from '@/view/popup/components/head.vue'
 import { withdrawRequest } from "@/http/account";
 import router from "@/router/popup.js";
+import { message } from "ant-design-vue";
+
 let withdraw_info = inject('withdraw_info')
+withdraw_info.source = 'confirm'
 withdraw_info.state_page = {}
 let state = reactive({
     img_enter_state: false
 })
 
 const clickBtn = () => {
-    // withdrawRequest({
-    //     params: {
-    //         "amountValue": withdraw_info.data.amount,
-    //         "currencyCode": withdraw_info.data.currency_code,
-    //         "withdrawNetwork": withdraw_info.net,
-    //         "withdrawReceiveAccount": withdraw_info.data.input_address
-    //     }
-    // }).then((res) => {
-    //     if (res.code == 0) {
-    
-    //     }
-    // })
-    if(state.img_enter_state){
-        withdraw_info.state_page.txt = ['123123']
-        router.push('/withdraw/success')
+    if (!state.img_enter_state) {
+        return
     }
+    withdrawRequest({
+        params: {
+            "amountValue": withdraw_info.data.amount,
+            "currencyCode": withdraw_info.currency_code,
+            "withdrawNetwork": withdraw_info.net,
+            "withdrawReceiveAccount": withdraw_info.data.input_address
+        }
+    }).then((res) => {
+        switch (res.code.toString()) {
+            case '0':
+                withdraw_info.state_page.txt = ['123123']
+                router.push('/withdraw/success')
+                break
+            case '4002':
+                message.error(res.msg);
+                break
+            default:
+                message.error(res.code);
+        }
+    })
+
 }
-const clickAgreement = ()=>{
+const clickAgreement = () => {
     // router.push('/')
 }
 
@@ -238,8 +249,9 @@ const clickEnter = () => {
                 font-size: 14px;
 
             }
-            .agreement{
-                text-decoration:underline;
+
+            .agreement {
+                text-decoration: underline;
                 color: #389AFF;
             }
         }

+ 2 - 0
src/view/popup/withdraw/home.vue

@@ -20,6 +20,8 @@ function selectCurrency(_params) {
         withdraw_info.currency_code = _params.currencyCode
         router.push('/withdraw/paypal')
     } else {
+        withdraw_info.source = 'home'
+        withdraw_info.balance = _params.balance
         withdraw_info.token = _params.currencyName || ''
         withdraw_info.net = _params.tokenChain || 'BNB Chain'
         withdraw_info.currency_code = _params.currencyCode

+ 43 - 36
src/view/popup/withdraw/info.vue

@@ -83,8 +83,8 @@ const inputWithdrawCalcFee = () => {
   withdrawCalcFee({
     params: {
       "amountValue": state.input_amount,
-      "currencyCode": state.currency_code,
-      "withdrawNetwork": 0
+      "currencyCode": withdraw_info.currency_code,
+      "withdrawNetwork": withdraw_info.net
     }
   }).then((res) => {
     if (res.code == 0) {
@@ -101,6 +101,9 @@ const inputWithdrawCalcFee = () => {
 }
 
 const inputText = () => {
+  if (!state.withdraw_switch) {
+    return
+  }
   if (!state.input_amount == undefined || state.input_amount < 0) {
     state.input_amount = 0
   }
@@ -109,9 +112,10 @@ const inputText = () => {
     state.is_enter_state = false
     return
   }
-  if (state.input_amount > state.max_amount || state.input_amount < state.min_amount) {
+  if (Number(state.input_amount) > Number(state.max_amount) || Number(state.input_amount) < Number(state.min_amount)) {
     state.error_msg = `最小为${state.min_amount},最大${state.max_amount}`
     state.is_enter_state = false
+    state.amount = 0
   } else {
     state.error_msg = ''
     inputWithdrawCalcFee()
@@ -126,40 +130,43 @@ const clickBtn = () => {
 }
 
 const initConfig = () => {
-  state.fee_amount = 0.1
   state.balance = withdraw_info.balance
-  // 单次提现最小金额
-  state.min_amount = 11
-  // 单次提现最小金额
-  state.max_amount = 123
-  state.currency_code = 'USD'
-
-  // getWithdrawConfig({
-  //   params: {
-  //     "currencyCode": "string",
-  //     "withdrawNetwork": 0
-  //   }
-  // }).then((res) => {
-  //   switch (res.code.toString()) {
-  //     case '0':
-  //       // 关闭提现功能
-  //       if (!res.data.withdrawSwitch) {
-  //         state.error_msg = '关闭提现功能'
-  //         return
-  //       }
-  //       state.fee_amount = res.data.withdrawFee
-  // state.min_amount = res.data.withdrawPerMinAmount
-  // 
-  // state.max_amount = res.data.withdrawPerMaxAmount
-  //       break;
-  //     case '0':
-
-  //       break;
-
-  //     default:
-  //       break;
-  //   }
-  // })
+  if (withdraw_info.source == 'confirm') {
+    state.input_address = withdraw_info.data.input_address
+    state.input_amount = withdraw_info.data.input_amount
+    state.amount = withdraw_info.data.amount
+  }
+  inputText()
+
+  getWithdrawConfig({
+    params: {
+      "currencyCode": withdraw_info.currency_code,
+      "withdrawNetwork": withdraw_info.net
+    }
+  }).then((res) => {
+    switch (res.code.toString()) {
+      case '0':
+        state.withdraw_switch = res.data.withdrawSwitch
+        // 关闭提现功能
+        if (!res.data.withdrawSwitch) {
+          state.error_msg = '关闭提现功能'
+          return
+        }
+
+        state.fee_amount = res.data.withdrawFee
+        // 单次提现最小金额
+        state.min_amount = res.data.withdrawPerMinAmount
+
+        state.max_amount = res.data.withdrawPerMaxAmount
+        break;
+      case '0':
+
+        break;
+
+      default:
+        break;
+    }
+  })
 }
 
 onMounted(() => {