switch.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <uni-popup ref="popupRef">
  3. <view class="unopen-box">
  4. <text class="z-close iconfont" @click.stop="close">&#xe621;</text>
  5. <view class="unopen-title">
  6. <text>资金划转</text>
  7. </view>
  8. <slot name="accounthint"></slot>
  9. <view class="unopen-content">
  10. <view class="account-box">
  11. <slot name="accountbox"></slot>
  12. </view>
  13. <view class="capital-type">
  14. <text class="type-left">全部</text>
  15. <input class="type-input" type="number" v-model="moneyNum">
  16. <text class="type-rigth">USDT</text>
  17. </view>
  18. <view class="capital-nums">
  19. <text class="num-title">可划转金额:</text>
  20. <text class="num">{{ availableMoney }} USDT</text>
  21. </view>
  22. <view class="capital-btn" @click.stop="changeAccount">
  23. 确定
  24. </view>
  25. </view>
  26. </view>
  27. </uni-popup>
  28. </template>
  29. <script>
  30. import {
  31. mapGetters
  32. } from 'vuex'
  33. import { biName , setChangeAccount} from "./card.js"
  34. // 合约 - 币币
  35. // 币币 - 合约 / 法币
  36. export default {
  37. name: "capitalSwitchModules",
  38. data() {
  39. return {
  40. moneyNum:''
  41. };
  42. },
  43. props:{
  44. availableMoney:{
  45. type:[Number , String],
  46. default:0
  47. },
  48. from_field:{
  49. type:String,
  50. default:''
  51. },
  52. to_field:{
  53. type:String,
  54. default:''
  55. },
  56. },
  57. watch:{
  58. activeBiType:{
  59. handler(newType , oldType){
  60. if(oldType === this.from_field){
  61. this.from_field = newType
  62. }
  63. if(oldType === this.to_field){
  64. this.to_field = newType
  65. };
  66. },
  67. immediate:true
  68. }
  69. },
  70. computed: {
  71. ...mapGetters([
  72. 'contractAccount',
  73. 'bibiAccount',
  74. 'legalAccount'
  75. ]),
  76. getBiName(){
  77. return function(key){
  78. return biName[key]
  79. }
  80. },
  81. getBiMoney(){
  82. return function(key){
  83. let nums = 0;
  84. switch(key){
  85. case 'lever':
  86. nums = this.contractAccount.usdt_totle
  87. break;
  88. case 'change':
  89. nums = this.bibiAccount.usdt_totle
  90. break;
  91. case 'legal':
  92. nums = this.legalAccount.usdt_totle
  93. break;
  94. };
  95. return nums || 0
  96. }
  97. }
  98. },
  99. mounted() {
  100. },
  101. methods: {
  102. // 切换币
  103. switchBiType(){
  104. const k = this.from_field;
  105. this.from_field = this.to_field;
  106. this.to_field = k;
  107. // this.from_field:'legal',
  108. // to_field:'change'
  109. },
  110. open() {
  111. this.$nextTick(() => {
  112. this.$refs.popupRef.open();
  113. })
  114. },
  115. close() {
  116. this.$refs.popupRef.close();
  117. },
  118. changeAccount(){
  119. let data = {
  120. currency_id: 3,
  121. number:this.moneyNum,
  122. from_field:this.from_field,
  123. to_field:this.to_field
  124. }
  125. setChangeAccount(data).then(res => {
  126. this.$store.dispatch('possession/getPossession').then(res => {
  127. console.log('获取成功')
  128. }).catch(err => {
  129. console.log('获取shibai ')
  130. })
  131. }).catch(err => {
  132. }).finally(() => {
  133. this.close()
  134. })
  135. },
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. @import "~./switch.scss";
  141. </style>