Commit 775c2beb authored by xhx's avatar xhx

加载调整

parent 350c6ff3
...@@ -46,7 +46,6 @@ import Vue from 'vue' ...@@ -46,7 +46,6 @@ import Vue from 'vue'
import Card from '@/components/Card.vue' import Card from '@/components/Card.vue'
import CardTwo from '@/components/Card_two.vue' import CardTwo from '@/components/Card_two.vue'
import { service } from '@/service/index' import { service } from '@/service/index'
// import { test } from '@/constants/test'
import { Dialog } from 'vant' import { Dialog } from 'vant'
export default Vue.extend({ export default Vue.extend({
components: { components: {
...@@ -71,7 +70,7 @@ export default Vue.extend({ ...@@ -71,7 +70,7 @@ export default Vue.extend({
getBlockHeight() { getBlockHeight() {
service.getHeight().then(res => { service.getHeight().then(res => {
this.blockHeight = res.data.result.mainHeight this.blockHeight = res.data.result.mainHeight
this.blockTime = +res.data.result.paraBlockTime this.blockTime = +res.data.result.mainBlockTime
}) })
}, },
goPage(item: any, n: number, i?: any) { goPage(item: any, n: number, i?: any) {
...@@ -123,12 +122,11 @@ export default Vue.extend({ ...@@ -123,12 +122,11 @@ export default Vue.extend({
}) })
}) })
}, },
setRank() { // 统一 description
setDesc() {
for (const item of this.lists) { for (const item of this.lists) {
if (item.type === 2) { if (item.type === 2) {
item.voteOptions = item.voteOptions.sort((a: any, b: any) => b.score - a.score) item.voteOptions.forEach((item: any) => {
item.voteOptions.forEach((item: any, index: number) => {
item.rank = index + 1
item.description = item.desc item.description = item.desc
}) })
} }
...@@ -148,7 +146,6 @@ export default Vue.extend({ ...@@ -148,7 +146,6 @@ export default Vue.extend({
execer: 'user.p.szhtest.rankvote', execer: 'user.p.szhtest.rankvote',
funcName: 'GetRankVoteList', funcName: 'GetRankVoteList',
payload: { payload: {
// addr: test.addr,
addr: this.$store.state.app.address, addr: this.$store.state.app.address,
count: -1, count: -1,
direction: 0, direction: 0,
...@@ -157,7 +154,7 @@ export default Vue.extend({ ...@@ -157,7 +154,7 @@ export default Vue.extend({
} }
}).then(res => { }).then(res => {
this.lists = res.data.result && res.data.result.list || [] this.lists = res.data.result && res.data.result.list || []
this.setRank() this.setDesc()
this.filterSetList() this.filterSetList()
if (fn) fn() if (fn) fn()
}) })
...@@ -168,7 +165,6 @@ export default Vue.extend({ ...@@ -168,7 +165,6 @@ export default Vue.extend({
execer: 'user.p.szhtest.rankvote', execer: 'user.p.szhtest.rankvote',
funcName: 'GetUserVotedList', funcName: 'GetUserVotedList',
payload: { payload: {
// addr: test.addr,
addr: this.$store.state.app.address, addr: this.$store.state.app.address,
index: 0, index: 0,
count: -1, count: -1,
...@@ -178,7 +174,7 @@ export default Vue.extend({ ...@@ -178,7 +174,7 @@ export default Vue.extend({
}).then(res => { }).then(res => {
this.lists = res.data.result && res.data.result.list || [] this.lists = res.data.result && res.data.result.list || []
this.lists = this.lists.filter(item => item.type === 1) this.lists = this.lists.filter(item => item.type === 1)
this.setRank() this.setDesc()
}) })
}, },
getAttendOption() { getAttendOption() {
...@@ -198,7 +194,6 @@ export default Vue.extend({ ...@@ -198,7 +194,6 @@ export default Vue.extend({
this.lists.forEach((item: any) => { this.lists.forEach((item: any) => {
item.description = item.desc item.description = item.desc
}) })
// this.setRank()
}) })
}, },
getSetOption() { getSetOption() {
...@@ -206,7 +201,6 @@ export default Vue.extend({ ...@@ -206,7 +201,6 @@ export default Vue.extend({
execer: 'user.p.szhtest.rankvote', execer: 'user.p.szhtest.rankvote',
funcName: 'GetUserSignUpList', funcName: 'GetUserSignUpList',
payload: { payload: {
// addr: test.addr,
addr: this.$store.state.app.address, addr: this.$store.state.app.address,
index: 0, index: 0,
count: -1, count: -1,
...@@ -218,10 +212,8 @@ export default Vue.extend({ ...@@ -218,10 +212,8 @@ export default Vue.extend({
this.lists.forEach((item: any) => { this.lists.forEach((item: any) => {
item.description = item.desc item.description = item.desc
}) })
// this.setRank()
}) })
}, },
updateTab() { updateTab() {
console.log(this.tab) console.log(this.tab)
if (this.tab === 1) { if (this.tab === 1) {
......
...@@ -10,8 +10,15 @@ import { whiteList } from "@/constants/whiteList" ...@@ -10,8 +10,15 @@ import { whiteList } from "@/constants/whiteList"
function isSame(w: any, c: any) { function isSame(w: any, c: any) {
const _d = c.data
let o = {} as any
if (typeof _d === 'string') {
o = JSON.parse(_d)
} else {
o = _d
}
for (const item of w) { for (const item of w) {
if (item.method === c.data.method && item.funcName === c.data.params[0].funcName) { if (item.method === o.method && item.funcName === o.params[0].funcName) {
return true return true
} }
} }
...@@ -41,8 +48,12 @@ class ChainService { ...@@ -41,8 +48,12 @@ class ChainService {
method:'post' method:'post'
}) })
this.service.interceptors.request.use(config => { this.service.interceptors.request.use(config => {
// 加载页设置 (过滤等待验证接口及名称校验接口)
if (config.data.method !== 'Chain33.QueryTransaction' && !isSame(whiteList, config)) { if (config.data.method !== 'Chain33.QueryTransaction' && !isSame(whiteList, config)) {
loading.showLoading() loading.showLoading()
store.commit('app/ADD_REQUEST')
// console.log('request:',(store as any).state.app.requestCount)
// console.log(config.data)
} }
return config return config
}, error => { }, error => {
...@@ -50,8 +61,21 @@ class ChainService { ...@@ -50,8 +61,21 @@ class ChainService {
}) })
this.service.interceptors.response.use(res => { this.service.interceptors.response.use(res => {
if (res.config.data.method !== 'Chain33.QueryTransaction' && !isSame(whiteList, res.config)) { const _d = res.config.data
loading.hideLoading() let o = {} as any
if (typeof _d === 'string') {
o = JSON.parse(_d)
} else {
o = _d
}
// 加载页设置
if (o.method !== 'Chain33.QueryTransaction' && !isSame(whiteList, res.config)) {
store.commit('app/DEC_REQUEST')
// console.log('res:',(store as any).state.app.requestCount)
// console.log(res.config.data)
if ((store as any).state.app.requestCount === 0) {
loading.hideLoading()
}
} }
return res return res
}, error => { }, error => {
......
...@@ -8,6 +8,7 @@ const stateData = { ...@@ -8,6 +8,7 @@ const stateData = {
}, },
members: [] as any, members: [] as any,
loading: 0, loading: 0,
requestCount: 0,
type: 1, type: 1,
res: '', // 提交失败信息 res: '', // 提交失败信息
text: '', // 提交提示 text: '', // 提交提示
...@@ -88,7 +89,13 @@ export const appStore = { ...@@ -88,7 +89,13 @@ export const appStore = {
}, },
CLEAR_FORM(state: AppType) { CLEAR_FORM(state: AppType) {
state.form = {} state.form = {}
} },
ADD_REQUEST(state: AppType) {
state.requestCount++
},
DEC_REQUEST(state: AppType) {
state.requestCount--
},
}, },
actions: { actions: {
......
...@@ -77,7 +77,6 @@ export default Vue.extend({ ...@@ -77,7 +77,6 @@ export default Vue.extend({
this.timer = setInterval(() => { this.timer = setInterval(() => {
if (+this.timeStamp <= Date.now()) { if (+this.timeStamp <= Date.now()) {
this.getList() this.getList()
// clearInterval(this.timer)
} }
}, waiter) }, waiter)
}, },
...@@ -148,7 +147,7 @@ export default Vue.extend({ ...@@ -148,7 +147,7 @@ export default Vue.extend({
} }
}).then(res => { }).then(res => {
if (res.data.error != null) { if (res.data.error != null) {
clearInterval(this.timer) if (this.timer) clearInterval(this.timer)
return return
} }
this.res = res.data.result this.res = res.data.result
...@@ -161,22 +160,10 @@ export default Vue.extend({ ...@@ -161,22 +160,10 @@ export default Vue.extend({
this.voteId = res.data.result.ID this.voteId = res.data.result.ID
const end = res.data.result?.endHeight const end = res.data.result?.endHeight
const start = res.data.result?.startHeight const start = res.data.result?.startHeight
if (this.status === 3) { //
clearInterval(this.timer) if (this.status && this.status === 3) {
if (this.timer) clearInterval(this.timer)
} }
// chainService.getLastBlocks().then(res => {
// const v = res.data.result.height
// if (+start > v) {
// this.voteType = 1
// this.timeStamp = res.data.result.blockTime * 1000 + (+start - v) * 5000 + ''
// } else if (+end > v) {
// this.voteType = 2
// this.timeStamp = res.data.result.blockTime * 1000 + (+end - v) * 5000 + ''
// } else {
// this.voteType = 3
// this.timeStamp = res.data.result.blockTime * 1000 + (+end - v) * 5000 + ''
// }
// })
service.getHeight().then(res => { service.getHeight().then(res => {
const v = res.data.result.mainHeight const v = res.data.result.mainHeight
if (+start > v) { if (+start > v) {
...@@ -189,9 +176,11 @@ export default Vue.extend({ ...@@ -189,9 +176,11 @@ export default Vue.extend({
this.voteType = 3 this.voteType = 3
this.timeStamp = res.data.result.mainBlockTime * 1000 + (+end - v) * 5000 + '' this.timeStamp = res.data.result.mainBlockTime * 1000 + (+end - v) * 5000 + ''
} }
// this.timeStamp = Date.now() + 10000 + ''
// this.createInterval(7000)
}) })
}).catch(() => { }).catch(() => {
clearInterval(this.timer) if (this.timer) clearInterval(this.timer)
}) })
} }
}, },
......
...@@ -84,6 +84,9 @@ export default Vue.extend({ ...@@ -84,6 +84,9 @@ export default Vue.extend({
methods: { methods: {
goVote() { goVote() {
if (this.community.status < 3) { if (this.community.status < 3) {
if (this.community.type === 2) {
return
}
this.$router.push({ path: '/Square/SquareVote', query: { ...this.$route.query }}) this.$router.push({ path: '/Square/SquareVote', query: { ...this.$route.query }})
} else { } else {
this.$router.push({ path: '/Square/SquareDetails', query: { ...this.$route.query }}) this.$router.push({ path: '/Square/SquareDetails', query: { ...this.$route.query }})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment