index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="contract">
  3. <headContent :showleftRight="false">
  4. <template #content>
  5. <view class="navigation-box">
  6. <view :class="['navigation-item hide_1' , contractIndex === index ? 'active-navigation-item' : '']"
  7. v-for="(item , index) in contractArr" :key="`navigation_${index}`"
  8. @click.stop="contractIndex = index">
  9. {{ item }}
  10. </view>
  11. </view>
  12. </template>
  13. </headContent>
  14. <!-- 永续合约 -->
  15. <template v-if="contractIndex === 0">
  16. <sustainability ref="sustainabilityRef" :currency-info="currencyVal" :leverTransaction="lever_transaction"
  17. :pagesInfo="pagesInfo" :rate-profits-total="rate_profits_total"/>
  18. </template>
  19. <!-- 永续合约 -->
  20. <template v-if="contractIndex === 1">
  21. <shortcut :leverTransaction="lever_transaction" :pagesInfo="pagesInfo" @refreshData="init"/>
  22. </template>
  23. <!-- 赠金交易 -->
  24. <template v-if="contractIndex === 2">
  25. <grants />
  26. </template>
  27. <notarize />
  28. </view>
  29. </template>
  30. <script>
  31. import notarize from "./modules/notarize.vue"
  32. import sustainability from "./sustainability/index.vue"
  33. import grants from "./grants/index.vue"
  34. import shortcut from "./shortcut/index.vue"
  35. import {
  36. Api_getLeverDeal,
  37. Api_getRegister
  38. } from "@/api/index.js"
  39. import {
  40. Way_getUserInfo
  41. } from "@/utils/common-request.js"
  42. import {
  43. mapGetters
  44. } from 'vuex'
  45. // import { startWebSocket , startAjaxSocket} from "@/utils/websock.js"
  46. export default {
  47. name: 'contract',
  48. components: {
  49. notarize,
  50. sustainability,
  51. grants,
  52. shortcut
  53. },
  54. data() {
  55. return {
  56. contractIndex: 0,
  57. contractArr: [
  58. '永续合约',
  59. '快捷合约',
  60. '赠金交易'
  61. ],
  62. currency: {},
  63. UserInfo: {},
  64. pagesInfo: {},
  65. lever_transaction: [],
  66. rate_profits_total:{}
  67. };
  68. },
  69. onLoad() {
  70. this.setSocket();
  71. },
  72. computed: {
  73. ...mapGetters([
  74. 'currencyVal'
  75. ]),
  76. },
  77. watch: {
  78. currencyVal: {
  79. handler(newCurrency) {
  80. if (newCurrency && newCurrency?.legal_id) {
  81. this.init()
  82. }
  83. },
  84. deep: true,
  85. immediate: true
  86. },
  87. },
  88. onShow() {
  89. },
  90. methods: {
  91. init() {
  92. this.getLeverDeal();
  93. if([0,1].includes(this.contractIndex)){
  94. this.getRegister()
  95. }
  96. this.getAccountInfo()
  97. },
  98. getRegister() {
  99. Api_getRegister({
  100. status: 1,
  101. page: 1,
  102. limit: 10000,
  103. settled:this.contractIndex === 0 ? 0 : 9
  104. }).then(res => {
  105. console.log('Api_getRegister = ' , res)
  106. this.rate_profits_total = res.rate_profits_total
  107. }).catch(err => {
  108. })
  109. },
  110. setSocket() {
  111. this.$store.dispatch("websocket/openSocket", {
  112. type: 'market_depth',
  113. legal_id: this.currencyVal.legal_id,
  114. currency_id: this.currencyVal.currency_id
  115. })
  116. this.$store.dispatch("websocket/openSocket", {
  117. type: 'daymarket',
  118. legal_id: this.currencyVal.legal_id,
  119. currency_id: this.currencyVal.currency_id
  120. })
  121. },
  122. getLeverDeal() {
  123. Api_getLeverDeal({
  124. legal_id: this.currencyVal.legal_id,
  125. currency_id: this.currencyVal.currency_id
  126. }).then(res => {
  127. this.pagesInfo = res
  128. this.lever_transaction = res.lever_transaction?.in || []
  129. })
  130. },
  131. getAccountInfo() {
  132. this.$store.dispatch('possession/getPossession').then(res => {
  133. console.log('获取成功')
  134. }).catch(err => {
  135. console.log('获取shibai ')
  136. })
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .navigation-box {
  143. width: 100%;
  144. height: 100%;
  145. padding: 0 $pages-padding 11rpx;
  146. display: flex;
  147. align-items: flex-end;
  148. .navigation-item {
  149. // width: 25%;
  150. flex: 1;
  151. flex-shrink: 0;
  152. text-align: center;
  153. height: 60rpx;
  154. border: 2rpx solid #27ae83;
  155. line-height: 60rpx;
  156. font-size: 28rpx;
  157. font-family: PingFang SC, PingFang SC-Regular;
  158. font-weight: 400;
  159. color: #05c175;
  160. &:nth-child(n + 2) {
  161. border-left: none;
  162. }
  163. &:last-child {
  164. border-radius: 0 6rpx 6rpx 0;
  165. }
  166. &:first-child {
  167. border-radius: 6rpx 0 0 6rpx;
  168. }
  169. }
  170. .active-navigation-item {
  171. background-color: #05C175;
  172. color: #FFFFFF;
  173. }
  174. }
  175. </style>