123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <template>
- <view class="contract">
- <headContent :showleftRight="false">
- <template #content>
- <view class="navigation-box">
- <view :class="['navigation-item hide_1' , contractIndex === index ? 'active-navigation-item' : '']"
- v-for="(item , index) in contractArr" :key="`navigation_${index}`"
- @click.stop="contractIndex = index">
- {{ item }}
- </view>
- </view>
- </template>
- </headContent>
- <!-- 永续合约 -->
- <template v-if="contractIndex === 0">
- <sustainability ref="sustainabilityRef" :currency-info="currencyVal" :leverTransaction="lever_transaction"
- :pagesInfo="pagesInfo" :rate-profits-total="rate_profits_total"/>
- </template>
- <!-- 永续合约 -->
- <template v-if="contractIndex === 1">
- <shortcut :leverTransaction="lever_transaction" :pagesInfo="pagesInfo" @refreshData="init"/>
- </template>
- <!-- 赠金交易 -->
- <template v-if="contractIndex === 2">
- <grants />
- </template>
- <notarize />
- </view>
- </template>
- <script>
- import notarize from "./modules/notarize.vue"
- import sustainability from "./sustainability/index.vue"
- import grants from "./grants/index.vue"
- import shortcut from "./shortcut/index.vue"
- import {
- Api_getLeverDeal,
- Api_getRegister
- } from "@/api/index.js"
- import {
- Way_getUserInfo
- } from "@/utils/common-request.js"
- import {
- mapGetters
- } from 'vuex'
- // import { startWebSocket , startAjaxSocket} from "@/utils/websock.js"
- export default {
- name: 'contract',
- components: {
- notarize,
- sustainability,
- grants,
- shortcut
- },
- data() {
- return {
- contractIndex: 0,
- contractArr: [
- '永续合约',
- '快捷合约',
- '赠金交易'
- ],
- currency: {},
- UserInfo: {},
- pagesInfo: {},
- lever_transaction: [],
- rate_profits_total:{}
- };
- },
- onLoad() {
- this.setSocket();
- },
- computed: {
- ...mapGetters([
- 'currencyVal'
- ]),
- },
- watch: {
- currencyVal: {
- handler(newCurrency) {
- if (newCurrency && newCurrency?.legal_id) {
- this.init()
- }
- },
- deep: true,
- immediate: true
- },
- },
- onShow() {
- },
- methods: {
- init() {
- this.getLeverDeal();
- if([0,1].includes(this.contractIndex)){
- this.getRegister()
- }
- this.getAccountInfo()
- },
- getRegister() {
- Api_getRegister({
- status: 1,
- page: 1,
- limit: 10000,
- settled:this.contractIndex === 0 ? 0 : 9
- }).then(res => {
- console.log('Api_getRegister = ' , res)
- this.rate_profits_total = res.rate_profits_total
- }).catch(err => {
-
- })
- },
- setSocket() {
- this.$store.dispatch("websocket/openSocket", {
- type: 'market_depth',
- legal_id: this.currencyVal.legal_id,
- currency_id: this.currencyVal.currency_id
- })
- this.$store.dispatch("websocket/openSocket", {
- type: 'daymarket',
- legal_id: this.currencyVal.legal_id,
- currency_id: this.currencyVal.currency_id
- })
- },
- getLeverDeal() {
- Api_getLeverDeal({
- legal_id: this.currencyVal.legal_id,
- currency_id: this.currencyVal.currency_id
- }).then(res => {
- this.pagesInfo = res
- this.lever_transaction = res.lever_transaction?.in || []
- })
- },
-
- getAccountInfo() {
- this.$store.dispatch('possession/getPossession').then(res => {
- console.log('获取成功')
- }).catch(err => {
- console.log('获取shibai ')
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .navigation-box {
- width: 100%;
- height: 100%;
- padding: 0 $pages-padding 11rpx;
- display: flex;
- align-items: flex-end;
- .navigation-item {
- // width: 25%;
- flex: 1;
- flex-shrink: 0;
- text-align: center;
- height: 60rpx;
- border: 2rpx solid #27ae83;
- line-height: 60rpx;
- font-size: 28rpx;
- font-family: PingFang SC, PingFang SC-Regular;
- font-weight: 400;
- color: #05c175;
- &:nth-child(n + 2) {
- border-left: none;
- }
- &:last-child {
- border-radius: 0 6rpx 6rpx 0;
- }
- &:first-child {
- border-radius: 6rpx 0 0 6rpx;
- }
- }
- .active-navigation-item {
- background-color: #05C175;
- color: #FFFFFF;
- }
- }
- </style>
|