交易所前端蓝色ui, 4.5 jiem
lxf
2025-04-18 66a33e936d39ec4db7fdffed5d646e044ccc43e9
src/page/exchange/exchangePage.vue
@@ -8,10 +8,13 @@
        
     </assets-head> -->
        <van-nav-bar left-arrow @click-left="onClickLeft">
            <template #right>
                <!-- <van-icon class="exchange-icon" name="question-o" /> -->
                <van-icon class="exchange-icon" @click="$router.push('/exchange/exchangeHistory')" name="clock-o" />
        <van-icon
          class="exchange-icon"
          @click="$router.push('/exchange/exchangeHistory')"
          name="clock-o"
        />
                <!-- <img src="../../assets/image/exchange/icon_1.png" alt="exchange-img" class="w-28 h-32 mr-20"
                     />
                     
@@ -21,39 +24,70 @@
            </template>
            <template #title>
                <div class="flex items-center">
                    {{ $t('闪兑') }}
                    <div class="fee ex-bg"> {{ $t('0手续费') }}</div>
          {{ $t("闪兑") }}
          <div class="fee ex-bg">{{ $t("0手续费") }}</div>
                </div>
            </template>
        </van-nav-bar>
        <list-account show class="mt-94" type="exchange" @exchange="onPopup" ref="exchange" />
        <van-popup class="tabBackground" v-model="show" position="bottom" :close-on-click-overlay="false" @close="onClose">
    <list-account
      show
      class="mt-94"
      type="exchange"
      @exchange="onPopup"
      ref="exchange"
    />
    <van-popup
      class="tabBackground"
      v-model="show"
      position="bottom"
      :close-on-click-overlay="false"
      @close="onClose"
    >
            <div class="pop-box relative">
                <img src="@/assets/image/icon-close.png" class="w-38 h-38 absolute right-20 top-20" @click="show = false" />
                <p class="font-38 text-center pt-60 textColor">{{ $t('确认报价') }}</p>
        <img
          src="@/assets/image/icon-close.png"
          class="w-38 h-38 absolute right-20 top-20"
          @click="show = false"
        />
        <p class="font-38 text-center pt-60 textColor">{{ $t("确认报价") }}</p>
                <!-- <p class="font-35 mt-49 text-grey text-center">{{ $t('您将获得') }}</p>
                <p class="font-50 mt-23 text-center textColor">{{ (detail.rate * detail.volume).toFixed(5) }} <span
                        class="font-35"> {{ detail.symbol_to && detail.symbol_to.toUpperCase() }}</span></p> -->
                <div class="px-30 flex items-center mt-30">
                    <div class="flex-1 textColor text-center">
                        <div>
                            <img v-if="detail.symbol" :src="`${HOST_URL}/symbol/${detail.symbol.toLowerCase()}.png`"
                                alt="logo" class="w-70 h-70 rounded-full" />
              <img
                v-if="detail.symbol"
                :src="`${HOST_URL}/wap/symbol/${detail.symbol.toLowerCase()}.png`"
                alt="logo"
                class="w-70 h-70 rounded-full"
              />
                        </div>
                        <div class="text-grey font-28 mt-20">{{ $t('从') }}</div>
                        <div class="font-30 mt-30">{{ detail.volume }} {{ detail.symbol }}</div>
            <div class="text-grey font-28 mt-20">{{ $t("从") }}</div>
            <div class="font-30 mt-30">
              {{ detail.volume }} {{ detail.symbol }}
                    </div>
                    <img src="../../assets/image/exchange/icon_6.png" class="w-30 h-20" style="margin-top:-65px" />
          </div>
          <img
            src="../../assets/image/exchange/icon_6.png"
            class="w-30 h-20"
            style="margin-top: -65px"
          />
                    <div class="flex-1 textColor text-center">
                        <div>
                            <img v-if="detail.symbol_to" :src="`${HOST_URL}/symbol/${detail.symbol_to.toLowerCase()}.png`"
                                alt="logo" class="w-70 h-70 rounded-full" />
              <img
                v-if="detail.symbol_to"
                :src="`${HOST_URL}/wap/symbol/${detail.symbol_to.toLowerCase()}.png`"
                alt="logo"
                class="w-70 h-70 rounded-full"
              />
                        </div>
                        <div class="text-grey font-28 mt-20">{{ $t('至') }}</div>
                        <div class="font-30 mt-30" v-if="detail.volume">{{ (detail.volume * detail.rate).toFixed(5) }}
                            {{ detail.symbol_to }}</div>
            <div class="text-grey font-28 mt-20">{{ $t("至") }}</div>
            <div class="font-30 mt-30" v-if="detail.volume">
              {{ (detail.volume * detail.rate).toFixed(5) }}
              {{ detail.symbol_to }}
            </div>
                    </div>
                </div>
@@ -63,8 +97,8 @@
                        <span class="color-green">1</span>
                    </li> -->
                    <li class="flex justify-between font-28 mt-25">
                        <span class="text-grey">{{ $t('类型') }}</span>
                        <span class="textColor">{{ $t('市价') }}</span>
            <span class="text-grey">{{ $t("类型") }}</span>
            <span class="textColor">{{ $t("市价") }}</span>
                    </li>
                    <!-- <li class="flex justify-between font-28 mt-25">
                        <span class="text-grey">{{ $t('闪兑自') }}</span>
@@ -72,17 +106,30 @@
                        }}</span>
                    </li> -->
                    <li class="flex justify-between font-28 mt-25">
                        <span class="text-grey">{{ $t('汇率') }}</span>
                        <span class="textColor">1 {{ detail.symbol &&
                            detail.symbol.toUpperCase() }}≈{{ (detail.rate * 1).toFixed(5) }} {{ detail.symbol_to &&
        detail.symbol_to.toUpperCase() }}</span>
            <span class="text-grey">{{ $t("汇率") }}</span>
            <span class="textColor"
              >1 {{ detail.symbol && detail.symbol.toUpperCase() }}≈{{
                (detail.rate * 1).toFixed(5)
              }}
              {{ detail.symbol_to && detail.symbol_to.toUpperCase() }}</span
            >
                    </li>
                </ul>
                <div class="h-100 rounded flex justify-between px-32 box-border items-center mt-56 mb-48 text-white w-full">
                    <p class="w-360 h-80 rounded flex justify-center items-center bgDark" @click="show = false">
                        {{ $t('返回') }}</p>
                    <p class="w-360 h-80 rounded btnMain text-white flex justify-center items-center" @click="onConfirm">
                        {{ $t('闪兑') }}({{ count }}{{ $t('秒') }})</p>
        <div
          class="h-100 rounded flex justify-between px-32 box-border items-center mt-56 mb-48 text-white w-full"
        >
          <p
            class="w-360 h-80 rounded flex justify-center items-center bgDark"
            @click="show = false"
          >
            {{ $t("返回") }}
          </p>
          <p
            class="w-360 h-80 rounded btnMain text-white flex justify-center items-center"
            @click="onConfirm"
          >
            {{ $t("闪兑") }}({{ count }}{{ $t("秒") }})
          </p>
                </div>
            </div>
        </van-popup>
@@ -91,84 +138,88 @@
<script>
import assetsHead from "@/components/assets-head";
import ListAccount from '@/components/mining-account'
import ListAccount from "@/components/mining-account";
import { _initExchange, _exchange } from "@/API/fund.api";
import { Popup } from "vant"
import { HOST_URL } from '@/config'
import { Popup } from "vant";
import { HOST_URL } from "@/config";
export default {
    components: {
        assetsHead,
        ListAccount,
        [Popup.name]: Popup
    [Popup.name]: Popup,
    },
    data() {
        return {
            show: false,
            session_token: '',
      session_token: "",
            detail: {},
            interval: null,
            count: 5,
            HOST_URL,
        }
    };
    },
    created() {
        this.getSessionToken()
    this.getSessionToken();
    },
    methods: {
        getSessionToken() { // 获取凭证
            _initExchange().then(data => {
                const { session_token } = data
                console.log(data)
                this.session_token = session_token
            })
    getSessionToken() {
      // 获取凭证
      _initExchange().then((data) => {
        const { session_token } = data;
        console.log(data);
        this.session_token = session_token;
      });
        },
        onPopup(evt) {
            console.log(evt)
            this.clearInterval()
            this.detail = evt
            this.show = true
            this.count = 5
      console.log(evt);
      this.clearInterval();
      this.detail = evt;
      this.show = true;
      this.count = 5;
            this.interval = setInterval(() => {
                this.count--
        this.count--;
                if (this.count <= 0) {
                    this.clearInterval()
                    this.$toast(this.$t('汇率已变化,请重新确认'))
                    this.show = false
          this.clearInterval();
          this.$toast(this.$t("汇率已变化,请重新确认"));
          this.show = false;
                }
            }, 1000)
      }, 1000);
        },
        onClose() {
            this.$refs.exchange.fetchRate(true)
            this.clearInterval()
      this.$refs.exchange.fetchRate(true);
      this.clearInterval();
        },
        onClickLeft() {
            this.$router.go(-1)
      this.$router.go(-1);
        },
        onConfirm() { // 闪兑
            this.clearInterval()
            _exchange({ ...this.detail, session_token: this.session_token }).then(() => {
                this.$router.push('/exchange/exchangeSubmit?data=' + JSON.stringify(this.detail))
                this.getSessionToken()
                this.show = false
            }).catch(() => {
                this.getSessionToken()
                this.show = false
    onConfirm() {
      // 闪兑
      this.clearInterval();
      _exchange({ ...this.detail, session_token: this.session_token })
        .then(() => {
          this.$router.push(
            "/exchange/exchangeSubmit?data=" + JSON.stringify(this.detail)
          );
          this.getSessionToken();
          this.show = false;
            })
        .catch(() => {
          this.getSessionToken();
          this.show = false;
        });
        },
        clearInterval() {
            if (this.interval) {
                clearInterval(this.interval)
                this.interval = null
            }
        clearInterval(this.interval);
        this.interval = null;
        }
    },
  },
    beforeRouteLeave(to, from, next) {
        this.clearInterval()
        next()
    }
}
    this.clearInterval();
    next();
  },
};
</script>
<style>
.van-popup.van-popup--bottom {
@@ -220,18 +271,17 @@
}
.bg-grey-light {
    background: #F5F5F5;
  background: #f5f5f5;
}
.bg-grey-dark {
    background: #C8CAD2;
  background: #c8cad2;
}
.fee {
    // background: #21353A;
    border-radius: 4px;
    color: #00B087;
  color: #00b087;
    font-size: 24px;
    padding: 5px 10px;
    margin-left: 10px;
@@ -253,11 +303,11 @@
}
.btnMain {
    background: linear-gradient(90deg, #2C64D4 0%, #38AEEA 100%);
  background: linear-gradient(90deg, #2c64d4 0%, #38aeea 100%);
}
.color-green {
    color: #00B087;
  color: #00b087;
}
.exchange-icon {