Commit 775c2beb authored by xhx's avatar xhx

加载调整

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