交易所前端蓝色ui, 4.5 jiem
jhzh
2024-04-08 67357c691325dc3cf743267f1ef0e1f5c93d7528
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import {SET_CURRENCY, SET_ORDER_MODE, SET_CURRENCY_SYMBOL, REASON_FOR_CANCELLATION} from "@/store/const.store";
 
const SET_SYMBOL_LIST = 'SET_SYMBOL_LIST'
const SET_FIAT_LIST = 'SET_FIAT_LIST'
const SET_PAY_METHODS = 'SET_PAY_METHODS'
 
const SET_SYMBOL = 'SET_SYMBOL'
 
const SET_ADV_ID = 'SET_ADV_ID'
const SET_ORDER_NO = 'SET_ORDER_NO'
const SET_DIRECTION = 'SET_DIRECTION'
 
import { c2cGetCurrencyList, c2cGetPayCurrencyList, ctcPaymentMethodType } from "@/API/otc";
 
export default {
  namespaced: true,
  state: {
    orderMode: false, // 是否在接单模式
    symbolList: null,
    fiatList: null, // 法币列表
    payMethods: null,
    currency: null, // 当前法币
    symbol: 'USDT', // 当前加密货币
    currency_symbol: '', // 币种符号
    adv_id: '', // 广告id
    order_no: '', // 订单id
    direction: 'buy', // 买,卖
    reasonForCancellation: '', // 用户取消订单理由
  },
  getters: {
    symbolList: state => state.symbolList,
    fiatList: state => state.fiatList,
    payMethods: state => state.payMethods,
    exchangeCurrency: state =>  state.currency,
    currencySymbol: state => state.currency_symbol,
    symbol: state => state.symbol,
    direction: state => state.direction,
    advId: state => state.adv_id,
    orderNo: state => state.order_no,
    getReasonForCancellation: state => state.reasonForCancellation,
  },
  mutations: {
    [SET_ADV_ID](state, id) {
      state.adv_id = id
    },
    [SET_ORDER_NO](state, no) {
      state.order_no = no
    },
    [SET_DIRECTION](state, direction) {
      state.direction = direction
    },
    [SET_ORDER_MODE](state, payload) {
      state.orderMode = payload.state;
    },
    [SET_SYMBOL_LIST](state, list) {
      // console.log(list);
      state.symbolList = list
    },
    [SET_FIAT_LIST](state, list) {
      state.fiatList = list
    },
    [SET_PAY_METHODS] (state, list) {
      state.payMethods = list
    },
    [SET_CURRENCY](state, currency) {
      console.log(currency);
      state.currency = currency
    },
    [SET_CURRENCY_SYMBOL](state, symbol) {
      state.currency_symbol = symbol
    },
    [SET_SYMBOL](state, symbol) {
      state.symbol = symbol
    },
    [REASON_FOR_CANCELLATION](state, text) {
      state.reasonForCancellation = text;
    }
  },
  actions: {
    async [SET_SYMBOL_LIST]({ commit, state }) { // 设置加密货币币种
      const data = await c2cGetCurrencyList()
      commit(SET_SYMBOL_LIST, Object.values(data))
    },
    async [SET_FIAT_LIST]({commit, state }) { // 设置法币
      if (!state.fiatList) {
        const data = await c2cGetPayCurrencyList()
        const arr = {}
        data.map(item => {
          const label = item.currency.substr(0,1).toUpperCase()
          if (!arr[label]) {
            arr[label] = []
          }
          arr[label].push({...item, fLabel: item.currency_symbol, label: item.currency, type: 'EN'})
        })
        const keys = Object.keys(arr).sort()
        const result = []
        keys.map(key => {
          result.push({
            title: key,
            labels: arr[key]
          })
        })
        commit(SET_FIAT_LIST, result)
      }
    },
    async [SET_PAY_METHODS] ({ commit, state },obj) { // 设置支付方式
        const res = await ctcPaymentMethodType(obj)
        commit(SET_PAY_METHODS, res.data)
    }
  }
}