1
jhzh
2026-02-27 5dfb843c29fdcc1693961b70a36ddee3fea85a4a
src/page/user/ransferIndex.vue
@@ -6,12 +6,20 @@
      :title="$t('劃轉')"
      left-arrow
      @click-left="onClickLeft"
    />
    >
      <template #right>
        <van-icon
          @click="$router.push('/transferindex-list')"
          name="orders-o"
          size="20"
        />
      </template>
    </van-nav-bar>
    <main>
      <div>
        <div class="main-header">
          <div class="main-li" @click="show = true">
            <span class="li-left">從</span
            <span class="li-left">{{ $t("从") }}</span
            ><span class="li-center">{{ from.name }}</span>
            <div class="img-con">
              <img
@@ -36,7 +44,7 @@
            />
          </div>
          <div class="main-li" @click="toShow = true">
            <span class="li-left">到</span
            <span class="li-left">{{ $t("到") }}</span
            ><span class="li-center">{{ to.name }}</span>
            <div class="img-con">
              <img
@@ -69,7 +77,6 @@
              class="van-cell van-field white-input"
              modelmodifiers="[object Object]"
            >
              <!----><!---->
              <div class="van-cell__value van-field__value">
                <div class="van-field__body">
                  <input
@@ -80,14 +87,14 @@
                    class="van-field__control"
                    :placeholder="$t('請選擇')"
                    @input="inputValue"
                  /><!----><!---->
                  />
                  <div class="van-field__button" style="margin-right: 10px">
                    <span style="color: rgb(79, 82, 87)">MYR</span>
                    <span style="color: rgb(79, 82, 87)">{{
                      from.symbolCode
                    }}</span>
                  </div>
                </div>
                <!----><!---->
              </div>
              <!----><!---->
            </div>
          </van-col>
          <div class="huazhuan">
@@ -107,30 +114,24 @@
              {{ $t("轉換得到金額") }}
            </div>
            <div class="van-cell van-field van-field--disabled white-input">
              <!----><!---->
              <div class="van-cell__value van-field__value">
                <div class="van-field__body">
                  <input
                    type="text"
                    id="van-field-48-input"
                    class="van-field__control"
                    disabled=""
                    :placeholder="$t('請選擇')"
                    style="padding-left: 10px"
                  /><!----><!---->
                  <div class="van-field__control" style="padding-left: 10px">
                    {{ (formValue * rate).toFixed(2) }}
                  </div>
                  <div class="van-field__button" style="">
                    <span style="color: rgb(79, 82, 87)">USD</span>
                    <span style="color: rgb(79, 82, 87)">{{
                      to.symbolCode
                    }}</span>
                  </div>
                </div>
                <!----><!---->
              </div>
              <!----><!---->
            </div>
          </van-col>
        </van-row>
        <div
          @click="formValue = from.availableBalanceUSD"
          @click="formValue = from.availableBalance"
          style="
            color: rgb(5, 106, 239);
            text-align: right;
@@ -143,11 +144,10 @@
        <div class="balance">
          <div>{{ $t("可用餘額") }}</div>
          <div class="balance-text">
            {{ from.availableBalanceUSD || "0.0000" }} USD
            {{ from.availableBalance || "0.0000" }} {{ from.symbolCode }}
          </div>
        </div>
      </div>
      <!-- transfer -->
      <van-button type="primary" @click="transferIndex" class="but">{{
        $t("確認劃轉")
      }}</van-button>
@@ -158,21 +158,30 @@
<script>
import * as api from "@/axios/api";
import { Notify } from "vant";
import { login, transfer } from "../../axios/api";
import { transfer } from "../../axios/api";
export default {
  created() {
    this.getMoneyData();
  },
  components: {},
  data() {
    return {
      // 马股和美元的汇率
      exchangeRate: 4.59,
      // 划转的金额
      formValue: "",
      from: {},
      to: {},
      show: false,
      actions: [],
      toShow: false,
      // 后端返回的数据列表比较多。在这里前端配置需要展示的
      filterActions: ["US", "MAS", "HK"],
      // 选择的列表
      actions: [],
      // 汇率
      rate: "",
    };
  },
  methods: {
@@ -188,7 +197,7 @@
      if (res.status === 0) {
        Notify({ type: "success", message: this.$t("划转成功") });
        setTimeout(() => {
          this.$router.push("/user");
          this.$router.push("/transferindex-list");
        }, 500);
      } else {
        Notify({ type: "warning", message: res.msg });
@@ -199,6 +208,7 @@
      this.from = { ...this.to };
      this.to = { ...obj };
      this.formValue = "";
      this.geCurrencyRate();
    },
    fromSelect(e) {
      if (e.accectType === this.to.accectType) {
@@ -206,22 +216,40 @@
      }
      this.from = e;
      this.formValue = "";
      this.geCurrencyRate();
    },
    toSelect(e) {
      if (e.accectType === this.from.accectType) {
        return Notify({ type: "warning", message: this.$t("不能选择一样的") });
      }
      this.to = e;
      this.formValue = "";
      this.geCurrencyRate();
    },
    // 获取账号余额
    async getMoneyData() {
      let res = await api.getMoney();
      if (res.status === 0) {
        let array = res.data.filter((item) => item.accectType !== "ALL");
        let array = res.data.filter(
          (item) => this.filterActions.indexOf(item.accectType) !== -1
        );
        array.map((item) => {
          item.name = this.$t(item.accectType);
        });
        this.actions = array;
      }
    },
    // 获取汇率
    async geCurrencyRate() {
      if (this.from.accectType && this.to.accectType) {
        let res = await api.currencyRate({
          fromType: this.from.accectType,
          toType: this.to.accectType,
        });
        if (res.status === 0) {
          this.rate = res.data;
        }
      }
    },
    onClickLeft() {
@@ -336,7 +364,7 @@
    padding: 0;
    height: 60px;
    color: var(--van-field-input-text-color);
    line-height: inherit;
    line-height: 60px;
    text-align: left;
    background-color: transparent;
    border: 0;