Skip to content

Commit

Permalink
Merge pull request #334 from oustr/main
Browse files Browse the repository at this point in the history
fix: 修复了多次按按钮导致重复发布动态的问题
  • Loading branch information
oustr authored Jul 24, 2023
2 parents af22352 + 699e946 commit 9d36b4d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/pages/draft/draft-moment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
</DraggableItem>
</view>
<view class="image-num"> {{ imagesData.length }}/30</view>
<view v-if="disablePublish" class="uploading"
>后台上传图片中,上传结束才能发布动态噢</view
>
<view class="m-2">
<FuiTextArea
v-model="title"
Expand Down Expand Up @@ -262,10 +265,12 @@ const onClickCat = () => {
};
function addImage() {
//点击+ 选择文件的时候 就到这里
disablePublish.value = true;
uni.chooseMedia({
mediaType: ["image"],
success: (chooseImageRes) => {
//成功在文件中选择了图片 在这里
let isTooManyImages = false;
let tempFilePaths = chooseImageRes.tempFiles as Array<any>;
if (imagesData.length + tempFilePaths.length > 30) {
Expand Down Expand Up @@ -297,6 +302,7 @@ function addImage() {
});
})
.finally(() => {
//图片成功在后端上传了 在这里
disablePublish.value = false;
});
if (isTooManyImages) {
Expand All @@ -318,15 +324,16 @@ function deleteImage(index: number) {
}
function publishMoment() {
if (isPublished.value === true) return;
if (photos.length == 0) {
uni.showToast({
title: "至少上传一张图片哦",
icon: "none"
});
return;
}
isPublished.value = true;
uni.setStorageSync(StorageKeys.DraftMoment, "");
isPublished.value = !isPublished.value;
newMoment({
title: title.value,
communityId: uni.getStorageSync(StorageKeys.CommunityId),
Expand Down Expand Up @@ -510,4 +517,9 @@ textarea ::selection {
display: inline;
color: #1fa1ff;
}
.uploading {
margin-left: 6vw;
color: #1d1d1d;
}
</style>

0 comments on commit 9d36b4d

Please sign in to comment.