Browse Source

添加汇率

max 6 months ago
parent
commit
777096aa6b
1 changed files with 19 additions and 2 deletions
  1. 19 2
      src/views/cashier.vue

+ 19 - 2
src/views/cashier.vue

@@ -17,6 +17,9 @@
               </el-select>
               </el-select>
             </template>
             </template>
           </el-input>
           </el-input>
+          <el-col style="text-align: right; margin-top: 12px" v-show="currency!== 'CNY'" :span="24" v-loading="ARS_amount_loading">
+            Exchange Rate: 1.00{{currency}} = <span style="font-size: 12px">{{ARS_amount}}ARS</span>
+          </el-col>
           <el-col style="text-align: right; margin-top: 12px">
           <el-col style="text-align: right; margin-top: 12px">
             <el-button type="primary" @click="createOrderFn">Submit</el-button>
             <el-button type="primary" @click="createOrderFn">Submit</el-button>
           </el-col>
           </el-col>
@@ -70,7 +73,7 @@
 </template>
 </template>
 
 
 <script setup>
 <script setup>
-import {ref, onMounted, computed} from 'vue'
+import {ref, onMounted, computed, watch} from 'vue'
 import {createOrder, getOrder, getConversionFactors} from '@/api'
 import {createOrder, getOrder, getConversionFactors} from '@/api'
 import {useRoute} from 'vue-router';
 import {useRoute} from 'vue-router';
 import _ from 'lodash'
 import _ from 'lodash'
@@ -87,7 +90,9 @@ const route = useRoute()
 const orderNo = route.query.t || ''
 const orderNo = route.query.t || ''
 const mchId = route.query.mchId || ''
 const mchId = route.query.mchId || ''
 const amount = ref(0)
 const amount = ref(0)
-const currency = ref('USD')
+const ARS_amount = ref(0)
+const currency = ref('');
+const  ARS_amount_loading = ref(false);
 import {ElMessage} from 'element-plus';
 import {ElMessage} from 'element-plus';
 
 
 
 
@@ -154,6 +159,17 @@ const getAmount = async () => {
   return res.amount
   return res.amount
 }
 }
 
 
+watch(currency, async () => {
+  if(currency.value === 'CNY')  return
+  ARS_amount_loading.value = true
+  const  res = await getConversionFactors({
+    currency: currency.value,
+    amount: '1.00'
+  })
+  ARS_amount.value = res.amount
+  ARS_amount_loading.value = false
+})
+
 const createOrderFn = async () => {
 const createOrderFn = async () => {
   loading.value = true
   loading.value = true
   if(_.isNumber(amount.value) && amount.value < 1) {
   if(_.isNumber(amount.value) && amount.value < 1) {
@@ -235,6 +251,7 @@ function signSort(args) {
 
 
 onMounted(() => {
 onMounted(() => {
   getOrderInfo()
   getOrderInfo()
+  currency.value = "USD"
 })
 })
 </script>
 </script>