Browse Source

答题防止连点

master
kola-web 2 months ago
parent
commit
a9dd6ff57b
  1. 4
      src/pages/my/index.ts
  2. 5
      src/pages/topic/index.ts
  3. 2
      src/pages/topic/index.wxml

4
src/pages/my/index.ts

@ -83,9 +83,7 @@ Page({
this.setData({ this.setData({
toastShow: false, toastShow: false,
}); });
setTimeout(() => { wx.showTabBar({});
wx.showTabBar({});
}, 1000);
}, },
handleTopic() { handleTopic() {
wx.navigateTo({ wx.navigateTo({

5
src/pages/topic/index.ts

@ -1,4 +1,5 @@
const app = getApp<IAppOption>(); const app = getApp<IAppOption>();
const licia = require('miniprogram-licia');
Page({ Page({
data: { data: {
@ -29,7 +30,7 @@ Page({
}); });
}); });
}, },
handleBtn(e) { handleBtn: licia.debounce(function (e) {
const { index, id } = e.currentTarget.dataset; const { index, id } = e.currentTarget.dataset;
const { question, nav } = this.data; const { question, nav } = this.data;
question[index].answer = id; question[index].answer = id;
@ -38,7 +39,7 @@ Page({
nav: nav === question.length - 1 ? nav : nav + 1, nav: nav === question.length - 1 ? nav : nav + 1,
percentage: ((nav + 1) / question.length) * 100, percentage: ((nav + 1) / question.length) * 100,
}); });
}, }, 200),
handlePrev() { handlePrev() {
this.setData({ this.setData({
nav: this.data.nav - 1, nav: this.data.nav - 1,

2
src/pages/topic/index.wxml

@ -31,7 +31,7 @@
class="btn {{questionItem.answer==='1' && 'active'}}" class="btn {{questionItem.answer==='1' && 'active'}}"
bind:tap="handleBtn" bind:tap="handleBtn"
data-id="1" data-id="1"
data-index="{{index }}" data-index="{{index}}"
> >
非常了解 非常了解
</view> </view>

Loading…
Cancel
Save