From fa98da041a166812bd42a6341b1db14ab90c27ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=8F=AF?= <1284707383@qq.com> Date: Thu, 12 Aug 2021 17:12:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E9=99=A4=E5=A4=9A=E4=BD=99=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projectionscreenPc/src/store/index.js | 7 +- projectionscreenPc/src/store/modules/trend.js | 151 ------------------ projectionscreenPc/src/store/modules/user.js | 56 +------ 3 files changed, 2 insertions(+), 212 deletions(-) diff --git a/projectionscreenPc/src/store/index.js b/projectionscreenPc/src/store/index.js index 15055fb..329c353 100644 --- a/projectionscreenPc/src/store/index.js +++ b/projectionscreenPc/src/store/index.js @@ -6,12 +6,7 @@ Vue.use(Vuex) export default new Vuex.Store({ state: { - symbol: ' ', - renew: '0', - pair: '', - id: '1', - priceScale: 1000, - tv_option: {} + }, modules: { user, diff --git a/projectionscreenPc/src/store/modules/trend.js b/projectionscreenPc/src/store/modules/trend.js index 1e58810..25fad83 100644 --- a/projectionscreenPc/src/store/modules/trend.js +++ b/projectionscreenPc/src/store/modules/trend.js @@ -1,163 +1,12 @@ -import request from '@/assets/js/api' -import common from '@/assets/js/common' -//import {Toast} from 'mand-mobile' - export default { namespaced: true, //模块与文件同名 state: { - allCoinList: [], //所有币种 对应后台币种管理 --资产模块使用 - allPairList: [], //所有交易对 --行情模块使用 - allTrendList: [], //所有交易对+价格 - newList: [],//新币 - myCollectList: [] ,//我的收藏 - currentPair: 'BTC-USDT', //当前交易对 - buyList: [], //买盘 - sellList: [], //卖盘 - - // 实时成交 - transactions:[], }, mutations: { - setCoin(state, data) { //币种 --资产模块 - state.allCoinList = data; - }, - setPair(state, data) { //交易对 -- 行情、币币模块 - //console.log(JSON.stringify(data)); - state.allPairList = data; - }, - setTrend(state, data) { //行情 - //console.log(JSON.stringify(data)); - state.allTrendList = data; - }, - setNewCoin(state, data) { //行情 - //console.log(JSON.stringify(data)); - state.newList = data; - }, - setDepth(state, data) { //深度 - state.buyList = data.buyList; - state.sellList = data.sellList; - }, - - setCollect(state, data) { //收藏 -- 自选模块 - state.myCollectList = JSON.parse(data); - }, - resetPair(state, data) { //更新交易对 - state.currentPair = data; - }, - // 切换 当前交易对 - setSub(state,data){ - state.sub={ - dealCoin: data.dealCoin, - convertType: data.convertType, - name: data.symbolId - } - }, - - // 设置 实时成交 - setTransactions(state, data) { - state.transactions = data - }, }, actions: { - async init(context) { - let token = common.getItem(common.tokenKey); - if (token) { // 如果token存在,才去获取用户数据 - context.dispatch('getAllCoin'); - context.dispatch('getCollect'); - await context.dispatch('getTrend'); - await context.dispatch('getNewCoin'); - context.dispatch('getAllPair'); - context.dispatch('getTransactions'); - } - }, - - // 获取实时成交 - getTransactions(ctx) { - request.getAxios('/api/entrust/trade/list/'+`${ctx.state.currentPair.dealCoin}-${ctx.state.currentPair.convertType}`).then(res => { - ctx.commit('setTransactions', res) - }); - }, - - getAllCoin(context) { //获取资产的所有币种信息 - request.getAxios('/api/user/coin/list') - .then(res => { - context.commit('setCoin', res.data); - }) - }, - getAllPair(context) { //获取行情的交易对 - return request.getAxios('/api/coin/case/all') - .then(res => { - // let newData = [...this.allTrendList] - res.data.push({ - caseName: '涨跌榜', - caseCode: "4", - status: 'C_C_S_NORMAL', - childen: [{'prices': context.state.allTrendList}] - }) - res.data.push({ - caseName: '成交榜', - caseCode: "5", - status: 'C_C_S_NORMAL', - childen: [{'prices': context.state.allTrendList}] - }) - let list = [] - context.state.allTrendList.forEach(item=>{ - context.state.newList.forEach(item2=>{ - if(item.dealCoin == item2.coinId) { - list.push(item) - } - }) - - }) - res.data.push({ - caseName: '新币榜', - caseCode: "6", - status: 'C_C_S_NORMAL', - childen: [{'prices': list}] - }) - - if(!context.state.currentPair) context.commit('resetPair', res.data[0].childen[0].prices[0].dealCoin); - context.commit('setPair', res.data); - }) - }, - getTrend(context) { //获取行情 - common.setItem("loading", true); //不显示loading - return request.getAxios('/api/coin/price/all', {}) - .then(res => { - context.commit('setTrend', res.data); - }) - }, - getNewCoin(context) { //获取行情 - common.setItem("loading", true); //不显示loading - return request.getAxios('/api/new/coin/list', {}) - .then(res => { - context.commit('setNewCoin', res.data); - }) - }, - getDepth(context, params) { //获取深度 - common.setItem('loading', true); //不显示loading - request.postAxios('/api/entrust/depth/list', params) - .then(res => { - context.commit('setDepth', res.data); - }) - }, - - getCollect(context) { //获取收藏列表 - request.getAxios('/api/user/config/list') - .then(res => { - res.data.forEach(item => { - if (item.configKey == 'U_COLLECTION') { - context.commit('setCollect', item.configValue); - } - }) - }) - }, - - getNewPair(context, item) { //更新交易对 - context.commit('resetPair', item) - } } } diff --git a/projectionscreenPc/src/store/modules/user.js b/projectionscreenPc/src/store/modules/user.js index 00cbabc..25fad83 100644 --- a/projectionscreenPc/src/store/modules/user.js +++ b/projectionscreenPc/src/store/modules/user.js @@ -1,66 +1,12 @@ -import request from '@/assets/js/api' -import common from '@/assets/js/common' -import router from '../../router' -import { Message, MessageBox } from 'element-ui' -import i18n from '@/assets/js/language' - export default { namespaced: true, //模块与文件同名 state: { - userConfig: [], //用户设置参数 - userIsActive: '', //是否激活 - isLogin: '', }, mutations: { - setLoginStatus(state) { - if(common.getItem(common.tokenKey)) { - state.isLogin = true; - } else { - state.isLogin = false; - } - }, - // 更新 个人设置 - setUserConfig(state, data) { - state.userConfig = data; - }, - clearData(state) { - state.userConfig = []; - state.isLogin = false; - state.userIsActive = ''; - } + }, - actions: { - init(context) { //初始化 - let token = common.getItem(common.tokenKey); - if(token) { // 如果token存在,才去获取用户数据 - context.dispatch('getUserConfig'); - } - }, - - getUserConfig(context) { //获取用户配置 - request.getAxios('/api/user/config/list') - .then(res => { - context.commit('setUserConfig', res.data); - }) - }, - logout(context) { - common.setItem(common.tokenKey, ""); //清除Token - context.commit('clearData'); - - MessageBox.confirm(i18n.t('是否退出登录?'), i18n.t('提示'), { - cancelButtonText: i18n.t('稍后再说'), - confirmButtonText: i18n.t('退出'), - type: 'warning' - }) - .then(() => { - Message.success(i18n.t('退出登录成功!')); - }) - setTimeout(() => { - router.push('/login'); - }, 500) - } } }