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 Login from './views/Login'
import Owner from './views/Owner'
import Netnode from './views/Netnode'
import Network from './views/Network'
import Users from './views/Users'
import Actions from './views/Actions'
import Tickets from './views/Tickets'
Vue.use(Router)
@@ -21,20 +21,20 @@ const router = new Router({
component: Login,
},
{
path: 'owner',
component: Owner,
path: 'users',
component: Users,
},
{
path: 'netnode',
component: Netnode,
path: 'actions',
component: Actions,
},
{
path: 'network',
component: Network,
path: 'tickets',
component: Tickets,
},
{
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 netnode } from './netnode'
export { default as owner } from './owner'
export { default as network } from './tickets'
export { default as netnode } from './actions'
export { default as owner } from './users'
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,
state: {
pageEntity: [5, 10, 25],
pageEntity: [10, 20],
headers: [
{ text: '类型', value: 'type', align: 'center' },
{ text: '用户id', value: 'userId', align: 'center' },
@@ -24,6 +24,7 @@ export default {
amount: 'loading',
},
],
currentPage: 1,
},
mutations: {
@@ -34,6 +35,12 @@ export default {
updateTickets(state, tickets) {
state.itemList = tickets
},
nextPage(state, page) {
state.page = page
},
setRowsPerPage(state, num) {
state.rowsPerPage = num
},
},
actions: {
@@ -46,6 +53,17 @@ export default {
const arr = result.data && result.data.data || []
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: {},

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',
icon: 'group',
path: '/owner',
path: '/users',
},
{
title: 'home.titleNode',
icon: 'all_inclusive',
path: '/netnode',
path: '/actions',
},
{
title: 'home.titleNetwork',
icon: 'public',
path: '/network',
path: '/tickets',
},
// {
// title: 'home.titleChain',

View File

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

View File

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

View File

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