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

防止重复提交

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