提交 e0231b60 编写于 作者: guangjun.yang's avatar guangjun.yang

防止重复提交

上级 94590e31
...@@ -48,6 +48,7 @@ export default { ...@@ -48,6 +48,7 @@ export default {
methods: { methods: {
// 上一页 // 有可能要触发上分页(前端的个数只有一条) // 上一页 // 有可能要触发上分页(前端的个数只有一条)
previous() { previous() {
if(!this.canRun()) return;
if (this.currentQuestion.titleNo == 1) { if (this.currentQuestion.titleNo == 1) {
Toast("已是第一题"); Toast("已是第一题");
} else { } else {
...@@ -66,6 +67,7 @@ export default { ...@@ -66,6 +67,7 @@ export default {
// 下一页 // 有可能要触发下分页(后面的个数只有一条) // 下一页 // 有可能要触发下分页(后面的个数只有一条)
// TODO // TODO
next() { next() {
if(!this.canRun()) return;
if (this.currentQuestion.titleNo == this.totalCount if (this.currentQuestion.titleNo == this.totalCount
// if (this.currentQuestion.titleNo == this.questionList.length // if (this.currentQuestion.titleNo == this.questionList.length
|| this.currentQuestion.titleNo == this.questionList[this.questionList.length - 1].titleNo) { || this.currentQuestion.titleNo == this.questionList[this.questionList.length - 1].titleNo) {
...@@ -96,11 +98,13 @@ export default { ...@@ -96,11 +98,13 @@ export default {
// 收藏/不收藏 // 收藏/不收藏
toggleCollect() { toggleCollect() {
this.favor(this.currentQuestion); this.favor(this.currentQuestion);
this.$emit("scrollTop");
// this.$store.commit('SET_CURRENT_QUESTION', this.currentQuestion); // this.$store.commit('SET_CURRENT_QUESTION', this.currentQuestion);
}, },
// 收藏/取消收藏 // 收藏/取消收藏
favor() { favor() {
if(!this.canRun()) return;
let favorFlag = this.currentQuestion.favorFlag; let favorFlag = this.currentQuestion.favorFlag;
let param = { let param = {
dataType: 2, dataType: 2,
......
...@@ -15,5 +15,6 @@ const getters = { ...@@ -15,5 +15,6 @@ const getters = {
commitKind: state => state.question.titleConfig.commitKind, commitKind: state => state.question.titleConfig.commitKind,
freeFlag: state => state.question.titleConfig.freeFlag, freeFlag: state => state.question.titleConfig.freeFlag,
totalCount: state => state.question.titleConfig.totalCount, totalCount: state => state.question.titleConfig.totalCount,
canRunNext: state => state.question.canRunNext,
} }
export default getters export default getters
const coop = { const coop = {
state: { state: {
userInfo: {appVersion: "343", userToken: "EFC0A4A5EC4B49FBBBBCD1AD0E46515F"}, userInfo: {appVersion: "343", userToken: "8E28243680E44C2A9275BF3F18F90494"},
statusBarHeight: {}, statusBarHeight: {},
projectTabIndex: 1, projectTabIndex: 1,
jumpURLForI: "", //中华医学会一类跳转地址 jumpURLForI: "", //中华医学会一类跳转地址
......
...@@ -67,7 +67,8 @@ const question = { ...@@ -67,7 +67,8 @@ const question = {
currentTitleNo: 0, // 定位答题题目id currentTitleNo: 0, // 定位答题题目id
resultId: 0, // 刷题库轮次ID resultId: 0, // 刷题库轮次ID
totalCount: 0, // 题目总数 totalCount: 0, // 题目总数
} },
canRunNext: true,
}, },
mutations: { mutations: {
SET_COMMON_CONIFG: (state, payload) => { SET_COMMON_CONIFG: (state, payload) => {
...@@ -91,6 +92,9 @@ const question = { ...@@ -91,6 +92,9 @@ const question = {
SET_CURRENT_QUESTION: (state, payload) => { SET_CURRENT_QUESTION: (state, payload) => {
state.currentQuestion = payload; state.currentQuestion = payload;
}, },
SET_CAN_RUN_NEXT: (state, payload) => {
state.canRunNext = payload;
},
}, },
actions: { actions: {
......
import fetch from '@/utils/fetch' import fetch from '@/utils/fetch'
import { getBaseUrl, getApiUrl } from '@/utils/index' import { getBaseUrl, getApiUrl } from '@/utils/index';
import store from '../store'; import { mapGetters } from 'vuex';
// import store from '../store';
module.exports = { module.exports = {
data: function () { data: function () {
...@@ -16,9 +18,13 @@ module.exports = { ...@@ -16,9 +18,13 @@ module.exports = {
// alert('this.token' + this.token) // alert('this.token' + this.token)
this.token = this.getUrlKey('token') || (query && query.token) this.token = this.getUrlKey('token') || (query && query.token)
}, },
mounted() { computed: {
...mapGetters(['canRunNext'])
},
mounted() {
}, },
methods: { methods: {
getUrlPara(obj) { getUrlPara(obj) {
let dataStr = '' let dataStr = ''
...@@ -250,5 +256,20 @@ module.exports = { ...@@ -250,5 +256,20 @@ module.exports = {
} }
}); });
}, },
// 防止重复点击的最简单实现
canRun(delayTime = 500){
if(this.canRunNext) {
this.$store.commit('SET_CAN_RUN_NEXT', false);
setTimeout( () => {
this.$store.commit('SET_CAN_RUN_NEXT', true)
}, delayTime);
console.log('in canRan ', this.canRunNext);
return true;
} else {
console.log('in canRan', this.canRunNext);
return false;
}
}
} }
} }
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<no-content v-show="!questionList.length" :listType="commitKind"></no-content> <no-content v-show="!questionList.length" :listType="commitKind"></no-content>
</article> </article>
<!-- <free-tips ></free-tips> --> <!-- <free-tips ></free-tips> -->
<question-footer v-show="questionList.length" @statistics="statistics" @pageQuestion="pageQuestion"></question-footer> <question-footer v-show="questionList.length" @statistics="statistics" @scrollTop="scrollTop" @pageQuestion="pageQuestion"></question-footer>
<ExperienceDialog <ExperienceDialog
:showDialog="experienceDialog" :showDialog="experienceDialog"
:statisConfig="statisConfig" :statisConfig="statisConfig"
...@@ -474,6 +474,11 @@ export default { ...@@ -474,6 +474,11 @@ export default {
rocNative.getPositionData({ rocNative.getPositionData({
__funcName: "__getPositionData" __funcName: "__getPositionData"
}); });
},
// 滚动到最上面
scrollTop() {
} }
} }
}; };
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册