diff --git a/src/services/axios.js b/src/services/axios.js index b870dca..52ff7ea 100644 --- a/src/services/axios.js +++ b/src/services/axios.js @@ -2,8 +2,8 @@ import axios from 'axios' // import app from './app' // let baseURL = `${window.location.protocol}//${window.location.hostname}:${window.location.port}/api/` // let baseURL = `${location.protocol}//${location.hostname}:80/api/` -// let baseURL = `https://server.vic.yuanjin.net/v1/` -let baseURL = `http://localhost:80/v1/` +let baseURL = `https://server.vic.yuanjin.net/v1/` +// let baseURL = `http://localhost:80/v1/` // 控制台应当默认访问控制台所在主机(localhost 或者 window.location.hostname)的 TIC后台,或者让用户在控制台启动时,自己设置一个节点主机。 axios.defaults.baseURL = baseURL diff --git a/src/store/modules/actions.js b/src/store/modules/actions.js index 79d27cd..eb24b48 100644 --- a/src/store/modules/actions.js +++ b/src/store/modules/actions.js @@ -8,11 +8,11 @@ export default { state: { pageEntity: [10, 20], headers: [ - { text: '类型', value: 'type', align: 'center' }, - { text: '用户id', value: '_id', align: 'center' }, - { text: '资金类型', value: 'tokenType', align: 'center' }, - { text: '金额', value: 'amount', align: 'center' }, - { text: '创建时间', value: 'createdAt', align: 'center' }, + { text: '类型type', value: 'type', align: 'center' }, + { text: '用户userId', value: 'userId', align: 'center' }, + { text: '资金类型tokenType', value: 'tokenType', align: 'center' }, + { text: '金额amount', value: 'amount', align: 'center' }, + { text: '创建时间createdAt', value: 'createdAt', align: 'center' }, ], itemList: [ { @@ -62,7 +62,23 @@ export default { const result = await axios.post('admin/actions', { query: { userId, type, op }, option: { pageSize, pageIndex } }, { headers: { token } }) const arr = result.data && result.data.data || [] commit('setUserList', arr) - } + }, + async searchTicket({ state, commit }, event) { + const { token } = JSON.parse(sessionStorage.getItem('KEY_ACCOUNT')) + const { page, rowsPerPage } = event + const t = state.filter + if (!t) return 0 + const query = {} + t.replace(/{|}| /g, '').replace(',', ',').replace(':', ':').replace('id', '_id').split(',').map(obj => { + const [k, v] = obj.split(':') + query[k] = v + }) + const pageSize = rowsPerPage + const pageIndex = page + const result = await axios.post('admin/actions', { query, option: { pageSize, pageIndex } }, { headers: { token } }) + const arr = result.data && result.data.data || [] + commit('setUserList', arr) + }, }, getters: {}, diff --git a/src/store/modules/tickets.js b/src/store/modules/tickets.js index a733b9b..15eb3f7 100644 --- a/src/store/modules/tickets.js +++ b/src/store/modules/tickets.js @@ -8,12 +8,12 @@ export default { state: { pageEntity: [10, 20], headers: [ - { text: '类型', value: 'type', align: 'center' }, - { text: '用户id', value: 'userId', align: 'center' }, - { text: '状态', value: 'status', align: 'center' }, - { text: '目标地址', value: 'amount', align: 'center' }, - { text: '目标地址', value: 'targetAddress', align: 'center' }, - { text: '创建时间', value: 'createdAt', align: 'center' }, + { text: '类型type', value: 'type', align: 'center' }, + { text: '用户userId', value: 'userId', align: 'center' }, + { text: '状态type', value: 'status', align: 'center' }, + { text: '目标地址targetAddress', value: 'targetAddress', align: 'center' }, + { text: '金额amount', value: 'amount', align: 'center' }, + { text: '创建时间createdAt', value: 'createdAt', align: 'center' }, ], itemList: [ { @@ -46,7 +46,7 @@ export default { actions: { async queryTickets({ state, commit }) { const { token } = JSON.parse(sessionStorage.getItem('KEY_ACCOUNT')) - const { userId, type = 0, op } = state + const { userId, type, op } = state const pageSize = 20 const pageIndex = 1 const result = await axios.post('admin/tickets', { query: { userId, type, op }, option: { pageSize, pageIndex } }, { headers: { token } }) @@ -63,7 +63,23 @@ export default { const result = await axios.post('admin/tickets', { query: { userId, type, op }, option: { pageSize, pageIndex } }, { headers: { token } }) const arr = result.data && result.data.data || [] commit('updateTickets', arr) - } + }, + async searchTicket({ state, commit }, event) { + const { token } = JSON.parse(sessionStorage.getItem('KEY_ACCOUNT')) + const { page, rowsPerPage } = event + const t = state.filter + if (!t) return 0 + const query = {} + t.replace(/{|}| /g, '').replace(',', ',').replace(':', ':').replace('id', '_id').split(',').map(obj => { + const [k, v] = obj.split(':') + query[k] = v + }) + const pageSize = rowsPerPage + const pageIndex = page + const result = await axios.post('admin/tickets', { query, option: { pageSize, pageIndex } }, { headers: { token } }) + const arr = result.data && result.data.data || [] + commit('updateTickets', arr) + }, }, getters: {}, diff --git a/src/store/modules/users.js b/src/store/modules/users.js index 6503690..217cac9 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -1,6 +1,7 @@ import axios from 'axios' import { app } from '../../services' import { ticApi } from '../../services/api' +import lodash from 'lodash' export default { namespaced: true, @@ -9,9 +10,14 @@ export default { pageEntity: [10, 20], headers: [ { text: '用户id', value: 'id', align: 'center' }, - { text: '手机号', value: 'phone', align: 'center' }, + { text: '手机号phone', value: 'phone', align: 'center' }, { text: '邀请人数', value: 'group', align: 'center' }, { text: '持有vic', value: 'vic', align: 'center' }, + { text: '买入vic总额', value: 'fundSum', align: 'center' }, + { text: '邀请人', value: 'inviter', align: 'center' }, + { text: '注册时间', value: 'createdAt', align: 'center' }, + { text: '上次充值', value: 'lastDeposit', align: 'center' }, + { text: '矿晶', value: 'fundList', align: 'center' }, ], itemList: [ { @@ -19,6 +25,11 @@ export default { phone: 'loading', group: 'loading', vic: 'loading', + inviter: 'loading', + fundSum: 'loading', + createdAt: 'loading', + lastDeposit: 'loading', + fundList: 'loading', }, ], @@ -65,24 +76,27 @@ export default { commit('setUserList', arr) commit('setUserNumSum', sum) }, - async searchUser ({ state, commit }, event) { - // const { token } = JSON.parse(sessionStorage.getItem('KEY_ACCOUNT')) - // const { page, rowsPerPage } = event - console.log(state.filter) - try { - console.log(`{${state.filter.x}}`) - const query = JSON.parse(`{${state.filter}}`) - } catch (error) { - console.log(error) - alert('输入格式错误!') - } - // commit('nextPage', page) - // const pageSize = rowsPerPage - // const pageIndex = page - // const { id, phone } = state - // const result = await axios.post('admin/users', { query: { id, phone }, option: { pageSize, pageIndex } }, { headers: { token } }) - // const arr = result.data && result.data.data || [] - // commit('setUserList', arr) + async searchUser({ state, commit }, event) { + const { token } = JSON.parse(sessionStorage.getItem('KEY_ACCOUNT')) + const { page, rowsPerPage } = event + const t = state.filter + if (!t) return 0 + const query = {} + t.replace(/{|}| /g, '').replace(',', ',').replace(':', ':').replace('id', '_id').split(',').map(obj => { + const [k, v] = obj.split(':') + query[k] = v + }) + const pageSize = rowsPerPage + const pageIndex = page + const [result, { data: { data: funds } }] = await Promise.all([ + axios.post('admin/users', { query, option: { pageSize, pageIndex } }, { headers: { token } }), + query._id && axios.post('admin/funds', { query: query._id ? { userId: query._id } : {}, option: { pageSize, pageIndex } }, { headers: { token } }), + ]) + // 只有查某个具体用户 才会查fund + let users = result.data.data || [] + delete funds[0]['_id'] + Object.assign(users[0], funds[0]) + commit('setUserList', users) }, }, diff --git a/src/views/Actions.vue b/src/views/Actions.vue index 96cbe25..bfe8253 100644 --- a/src/views/Actions.vue +++ b/src/views/Actions.vue @@ -5,7 +5,8 @@