This commit is contained in:
chaosBreaking
2019-10-09 08:10:18 +08:00
parent 9c0e433ef8
commit 7b246bebef
11 changed files with 206 additions and 181 deletions

View File

@@ -4,9 +4,9 @@ import store from './store'
import Home from './views/Home' import Home from './views/Home'
import Login from './views/Login' import Login from './views/Login'
import Owner from './views/Owner' import Users from './views/Users'
import Netnode from './views/Netnode' import Actions from './views/Actions'
import Network from './views/Network' import Tickets from './views/Tickets'
Vue.use(Router) Vue.use(Router)
@@ -21,20 +21,20 @@ const router = new Router({
component: Login, component: Login,
}, },
{ {
path: 'owner', path: 'users',
component: Owner, component: Users,
}, },
{ {
path: 'netnode', path: 'actions',
component: Netnode, component: Actions,
}, },
{ {
path: 'network', path: 'tickets',
component: Network, component: Tickets,
}, },
{ {
path: '*', path: '*',
redirect: 'owner', redirect: 'users',
}, },
], ],
}, },

View File

@@ -0,0 +1,69 @@
import axios from 'axios'
import { app } from '../../services'
import { ticApi } from '../../services/api'
export default {
namespaced: true,
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' },
],
itemList: [
{
type: 'loading',
_id: 'loading',
tokenType: 'loading',
createdAt: 'loading',
amount: 'loading',
},
],
userNumSum: 0,
},
mutations: {
inputFilter(state, filter) {
state.filter = filter
},
setUserNumSum(state, address) {
state.address = address
},
setUserList(state, actions) {
state.itemList = actions
},
},
actions: {
async queryUserInfo({ state, commit }) {
const { token } = JSON.parse(sessionStorage.getItem('KEY_ACCOUNT'))
const { userId, type = 0, op } = state
const pageSize = 20
const pageIndex = 1
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 nextPage({ state, commit }, event) {
const { token } = JSON.parse(sessionStorage.getItem('KEY_ACCOUNT'))
const { page, rowsPerPage } = event
// commit('nextPage', page)
const { userId, type = 0, op } = state
const pageSize = rowsPerPage
const pageIndex = page
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)
}
},
getters: {},
}

View File

@@ -1,4 +1,4 @@
export { default as network } from './network' export { default as network } from './tickets'
export { default as netnode } from './netnode' export { default as netnode } from './actions'
export { default as owner } from './owner' export { default as owner } from './users'
export { default as login } from './login' export { default as login } from './login'

View File

@@ -1,106 +0,0 @@
import axios from 'axios'
import { app } from '../../services'
import { ticApi } from '../../services/api'
export default {
namespaced: true,
state: {
pageEntity: [5, 10, 25],
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' },
],
itemList: [
{
type: 'loading',
_id: 'loading',
tokenType: 'loading',
createdAt: 'loading',
amount: 'loading',
},
],
userNumSum: 0,
},
mutations: {
inputFilter(state, filter) {
state.filter = filter
},
setUserNumSum(state, address) {
state.address = address
},
setUserList(state, actions) {
state.itemList = actions
},
},
actions: {
async queryUserInfo({ state, commit }) {
const { token } = JSON.parse(sessionStorage.getItem('KEY_ACCOUNT'))
const { userId, type = 0, op } = state
const result = await axios.post('admin/actions', { userId, type, op }, { headers: { token } })
axios.post('admin/actions', { userId, type, op }, { headers: { token } })
const arr = result.data && result.data.data || []
commit('setUserList', arr)
},
async performTransfer({ state, commit, rootState }) {
commit('updateSubmitting', true)
const {
targetAddress,
transferAmount,
transferFee,
// transferRemark,
} = state
let wrongAddress, wrongAmount, wrongFee
if (!(await ticApi.isAddress(targetAddress))) {
wrongAddress = '错误的地址'
} else {
wrongAddress = ''
}
if (!(+transferAmount > 0)) {
wrongAmount = '请输入正确的交易金额'
} else {
wrongAmount = ''
}
if (!(+transferFee > 0)) {
wrongFee = '请输入正确的手续费'
} else {
wrongFee = ''
}
commit('updateWrongAddress', wrongAddress)
commit('updateWrongAmount', wrongAmount)
commit('updateWrongFee', wrongFee)
if (wrongAddress || wrongAmount || wrongFee) {
commit('updateSubmitting', false)
return
}
const res = await ticApi.transferTic({
mnemonic: rootState.account.mnemonic,
to: targetAddress,
amount: +transferAmount,
fee: +transferFee,
})
if (res) {
// success
commit('updateTransferResult', '转账成功')
await app.delay(1000)
commit('toggleTransferDlg', false)
} else {
// fail
commit('updateTransferResult', '转账失败')
}
commit('updateSubmitting', false)
},
},
getters: {},
}

View File

@@ -1,55 +0,0 @@
import axios from 'axios'
import { app } from '../../services'
import { ticApi } from '../../services/api'
export default {
namespaced: true,
state: {
pageEntity: [5, 10, 25],
headers: [
{ text: '用户id', value: 'id', align: 'center' },
{ text: '手机号', value: 'phone', align: 'center' },
{ text: '邀请人数', value: 'group', align: 'center' },
{ text: '持有vic', value: 'vic', align: 'center' },
],
itemList: [
{
id: 'loading',
phone: 'loading',
group: 'loading',
vic: 'loading',
},
],
userNumSum: 0,
},
mutations: {
inputFilter(state, filter) {
state.filter = filter
},
setUserNumSum(state, sum) {
state.userNumSum = sum
},
setUserList(state, actions) {
state.itemList = actions
},
},
actions: {
async queryUserInfo({ state, commit }) {
const { token } = JSON.parse(sessionStorage.getItem('KEY_ACCOUNT'))
const { id, phone } = state
const result = await axios.post('admin/users', { id, phone }, { headers: { token } })
const arr = result.data && result.data.data || []
const sum = result.data && result.data.sum || 0
commit('setUserList', arr)
commit('setUserNumSum', sum)
},
},
getters: {},
}

View File

@@ -6,7 +6,7 @@ export default {
namespaced: true, namespaced: true,
state: { state: {
pageEntity: [5, 10, 25], pageEntity: [10, 20],
headers: [ headers: [
{ text: '类型', value: 'type', align: 'center' }, { text: '类型', value: 'type', align: 'center' },
{ text: '用户id', value: 'userId', align: 'center' }, { text: '用户id', value: 'userId', align: 'center' },
@@ -24,6 +24,7 @@ export default {
amount: 'loading', amount: 'loading',
}, },
], ],
currentPage: 1,
}, },
mutations: { mutations: {
@@ -34,6 +35,12 @@ export default {
updateTickets(state, tickets) { updateTickets(state, tickets) {
state.itemList = tickets state.itemList = tickets
}, },
nextPage(state, page) {
state.page = page
},
setRowsPerPage(state, num) {
state.rowsPerPage = num
},
}, },
actions: { actions: {
@@ -46,6 +53,17 @@ export default {
const arr = result.data && result.data.data || [] const arr = result.data && result.data.data || []
commit('updateTickets', arr) commit('updateTickets', arr)
}, },
async nextPage({ state, commit }, event) {
const { token } = JSON.parse(sessionStorage.getItem('KEY_ACCOUNT'))
const { page, rowsPerPage } = event
commit('nextPage', page)
const { userId, type = 0, op } = state
const pageSize = rowsPerPage
const pageIndex = page
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)
}
}, },
getters: {}, getters: {},

View File

@@ -0,0 +1,90 @@
import axios from 'axios'
import { app } from '../../services'
import { ticApi } from '../../services/api'
export default {
namespaced: true,
state: {
pageEntity: [10, 20],
headers: [
{ text: '用户id', value: 'id', align: 'center' },
{ text: '手机号', value: 'phone', align: 'center' },
{ text: '邀请人数', value: 'group', align: 'center' },
{ text: '持有vic', value: 'vic', align: 'center' },
],
itemList: [
{
id: 'loading',
phone: 'loading',
group: 'loading',
vic: 'loading',
},
],
userNumSum: 0,
itemSum: 100,
},
mutations: {
inputFilter(state, filter) {
state.filter = filter
},
setUserNumSum(state, sum) {
state.userNumSum = sum
},
setUserList(state, actions) {
state.itemList = actions
},
},
actions: {
async queryUserInfo({ state, commit }) {
const { token } = JSON.parse(sessionStorage.getItem('KEY_ACCOUNT'))
const { id, phone } = state
const pageSize = 20
const pageIndex = 1
const result = await axios.post('admin/users', { query: { id, phone }, option: { pageSize, pageIndex } }, { headers: { token } })
const arr = result.data && result.data.data || []
const sum = result.data && result.data.sum || 0
commit('setUserList', arr)
commit('setUserNumSum', sum)
},
async nextPage({ state, commit }, event) {
const { token } = JSON.parse(sessionStorage.getItem('KEY_ACCOUNT'))
const { page, rowsPerPage } = event
// 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 || []
const sum = result.data && result.data.sum || 0
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)
},
},
getters: {},
}

View File

@@ -24,17 +24,17 @@ const sideMenus = [
{ {
title: 'home.titleOwner', title: 'home.titleOwner',
icon: 'group', icon: 'group',
path: '/owner', path: '/users',
}, },
{ {
title: 'home.titleNode', title: 'home.titleNode',
icon: 'all_inclusive', icon: 'all_inclusive',
path: '/netnode', path: '/actions',
}, },
{ {
title: 'home.titleNetwork', title: 'home.titleNetwork',
icon: 'public', icon: 'public',
path: '/network', path: '/tickets',
}, },
// { // {
// title: 'home.titleChain', // title: 'home.titleChain',

View File

@@ -19,6 +19,7 @@
:rows-per-page-items="pageEntity" :rows-per-page-items="pageEntity"
:loading="fetching" :loading="fetching"
class="panel-content elevation-1" class="panel-content elevation-1"
@update:pagination="nextPage"
> >
<template slot="headerCell" slot-scope="props"> <template slot="headerCell" slot-scope="props">
<span>{{ $t(props.header.text) }}</span> <span>{{ $t(props.header.text) }}</span>
@@ -64,6 +65,7 @@ export default {
...mapActions([ ...mapActions([
'queryUserInfo', 'queryUserInfo',
'queryOne', 'queryOne',
'nextPage'
]), ]),
...mapMutations([ ...mapMutations([
'inputFilter', 'inputFilter',

View File

@@ -20,6 +20,8 @@
:rows-per-page-items="pageEntity" :rows-per-page-items="pageEntity"
:loading="fetching" :loading="fetching"
class="panel-content elevation-1" class="panel-content elevation-1"
:page="currentPage"
@update:pagination="nextPage"
> >
<template slot="headerCell" slot-scope="props"> <template slot="headerCell" slot-scope="props">
<span>{{ $t(props.header.text) }}</span> <span>{{ $t(props.header.text) }}</span>
@@ -56,6 +58,7 @@ export default {
'headers', 'headers',
'itemList', 'itemList',
'pageEntity', 'pageEntity',
'currentPage',
'fetching', 'fetching',
'filter', 'filter',
]), ]),
@@ -65,6 +68,7 @@ export default {
methods: { methods: {
...mapActions([ ...mapActions([
'queryTickets', 'queryTickets',
'nextPage'
]), ]),
...mapMutations([ ...mapMutations([
'inputFilter', 'inputFilter',
@@ -75,8 +79,7 @@ export default {
mounted() { mounted() {
this.queryTickets() this.queryTickets()
}, }
} }
</script> </script>

View File

@@ -23,6 +23,7 @@
<h3>用户列表</h3> <h3>用户列表</h3>
<div class="search-input"> <div class="search-input">
<v-text-field <v-text-field
@keyup.13="searchUser"
:placeholder="$t('owner.searchHolder')" :placeholder="$t('owner.searchHolder')"
:value="filter" :value="filter"
@input="inputFilter" @input="inputFilter"
@@ -34,10 +35,11 @@
<v-data-table <v-data-table
:headers="headers" :headers="headers"
:items="itemList" :items="itemList"
:total-items="100" :total-items="userNumSum"
:rows-per-page-items="pageEntity" :rows-per-page-items="pageEntity"
:loading="fetching" :loading="fetching"
class="panel-content elevation-1" class="panel-content elevation-1"
@update:pagination="nextPage"
> >
<template slot="headerCell" slot-scope="props"> <template slot="headerCell" slot-scope="props">
<span>{{ $t(props.header.text) }}</span> <span>{{ $t(props.header.text) }}</span>
@@ -82,6 +84,8 @@ export default {
...mapActions([ ...mapActions([
'queryUserInfo', 'queryUserInfo',
'queryOne', 'queryOne',
'nextPage',
'searchUser'
]), ]),
...mapMutations([ ...mapMutations([
'inputFilter', 'inputFilter',