新增更新上级节流操作,避免用户连续点击添加多次

This commit is contained in:
weipengfei 2023-09-04 09:42:25 +08:00
parent 3b862ecdd3
commit a193cef232
3 changed files with 24 additions and 10 deletions

View File

@ -24,7 +24,7 @@
<view v-if="uniMP" style="height: 44px;">
<u-icon name="arrow-left" color="#fff" size="20" @click="leftClick"></u-icon>
</view>
<!-- <view style="height: 30rpx"></view> -->
<view v-else style="height: 30rpx"></view>
<!-- <view v-if="uniMP" style="height: 44px;"></view> -->
<!-- #endif -->
<view class="my_info">

View File

@ -13,7 +13,7 @@
<view v-if="uniMP" style="height: 44px;">
<u-icon name="arrow-left" color="#fff" size="20" @click="leftClick"></u-icon>
</view>
<!-- <view style="height: 30rpx"></view> -->
<view v-else style="height: 30rpx"></view>
<!-- <view style="height: 100rpx"></view> -->
<!-- <view v-if="uniMP" style="height: 44px"></view> -->
<!-- #endif -->

View File

@ -56,6 +56,8 @@
</u--form>
<!-- <button @click="addArchives" class="btn">完成更新</button> -->
<mybtn text="完成更新" @click="addArchives"></mybtn>
<u-modal :show="modelShow" title="警告" content='确定要删除该信息吗' closeOnClickOverlay showCancelButton
@close="modelShow=false" @cancel="modelShow=false" @confirm="deleteDemand(deleteIndex)"></u-modal>
</view>
</view>
</template>
@ -111,6 +113,8 @@
showDemandList: [], //
updateFlag: true,
task_id: 0,
modelShow: false, //
deleteIndex: -1, //
formData: {
id_card: '',
sex: '',
@ -210,22 +214,32 @@
}
},
//
changeDemand: throttle(function(e) {
changeDemand(e){
this.$u.throttle(()=>this.addDemand(e), 2000)
},
addDemand(e){
uni.showLoading({
title: '添加中',
mask: true
})
this.demandShow = false;
if (e.value[1]) {
this.showDemandList.push(e.value[1]);
} else {
this.showDemandList.push(e.value[0]);
}
}, 3000),
this.$nextTick(()=>{
uni.hideLoading();
})
},
//
removeShowDemand(index) {
uni.showModal({
title: '确定删除这一部分内容吗',
success: (res) => {
if (res.confirm) this.showDemandList.splice(index, 1);
}
})
this.modelShow = true;
this.deleteIndex = index;
},
deleteDemand(index){
this.showDemandList.splice(index, 1);
this.modelShow = false;
}
},
onPullDownRefresh() {