Skip to content

Commit

Permalink
perf: 优化创建动态时对用户条例的提示
Browse files Browse the repository at this point in the history
  • Loading branch information
fuqihao.foliet committed Dec 8, 2023
1 parent 1df791f commit a7786fc
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 53 deletions.
23 changes: 15 additions & 8 deletions src/pages/draft/BottomPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
{{ props.text }}
</button>
<view class="notice">
发布前请先阅读
<text class="nobody-will-read" @click="showDeal"> 《用户服务协议》 </text>
<text class="nobody-will-read" @click="showPolicy">
《个人信息保护政策》
</text>
,一旦发布即被视为同意上述协议和政策
<checkbox style="transform: scale(0.7)" @click="emits('agree')" />
<view
>请先阅读
<text class="nobody-will-read" @click="showDeal">
《用户服务协议》
</text>
<text class="nobody-will-read" @click="showPolicy">
《个人信息保护政策》
</text>
</view>
</view>
</view>
<deal v-if="isShow && type === 1" />
Expand All @@ -34,7 +38,7 @@ const props = withDefaults(defineProps<Props>(), {
canPublish: false,
text: "发布"
});
const emits = defineEmits(["publish"]);
const emits = defineEmits(["publish", "agree"]);
const isShow = ref(false);
const type = ref(0);
Expand Down Expand Up @@ -97,6 +101,9 @@ function showPolicy() {
}
}
.notice {
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
font-size: 3vw;
width: 88vw;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/draft/ChooseCat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<view class="all">
<view class="header" @click="chooseCats">
<text>关联猫咪:</text>
<text class="cat-name">{{ catName ? catName : "[]" }}</text>
<text class="cat-name">{{ catName ? catName : "[+]" }}</text>
</view>
<!-- <view v-if="!catId" class="button" @click="chooseCats">选择...</view>-->
<view v-if="catId" class="cat-box">
Expand Down
94 changes: 50 additions & 44 deletions src/pages/draft/draft-moment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
:can-publish="!isUploadingImages"
text="发布动态"
@publish="publish"
@agree="agree = !agree"
/>
<template v-if="showToastBox">
<ToastBoxWithShadow
Expand All @@ -45,6 +46,7 @@ const isUploadingImages = ref(false);
const toggleIsUploadingImages = (bool: boolean) => {
isUploadingImages.value = bool;
};
const agree = ref(false);
const isPublished = ref(false);
const title = ref("");
const content = ref("");
Expand Down Expand Up @@ -87,51 +89,55 @@ const publish = async () => {
});
return;
}
const res = await uni.showModal({
content: "是否同意《用户服务协议》及《隐私政策》",
cancelText: "不同意"
});
if (res.confirm) {
isPublished.value = true;
uni.setStorageSync(StorageKeys.DraftMoment, "");
newMoment({
title: title.value,
communityId: uni.getStorageSync(StorageKeys.CommunityId),
text: content.value,
photos: [...photos.value],
catId: uni.getStorageSync(StorageKeys.IdSelected)
})
.then((res) => {
console.log(res);
if (res.getFish) {
gottenFishNth.value = res.getFishTimes;
gottenFishAmount.value = res.getFishNum;
showToastBox.value = true;
} else {
refresh();
}
})
.catch((reason) => {
const code = reason.data.Code;
if (code === 10001) {
uni.showToast({
title: "文本含敏感内容",
icon: "none"
});
} else if (code === 10002) {
uni.showToast({
title: "图片含敏感内容",
icon: "none"
});
} else {
uni.showToast({
title: "发送失败",
icon: "none"
});
}
isPublished.value = false;
});
if (!agree.value) {
const res = await uni.showModal({
content: "是否同意《用户服务协议》及《隐私政策》",
cancelText: "不同意"
});
if (!res.confirm) {
return;
}
}
isPublished.value = true;
uni.setStorageSync(StorageKeys.DraftMoment, "");
newMoment({
title: title.value,
communityId: uni.getStorageSync(StorageKeys.CommunityId),
text: content.value,
photos: [...photos.value],
catId: uni.getStorageSync(StorageKeys.IdSelected)
})
.then((res) => {
console.log(res);
if (res.getFish) {
gottenFishNth.value = res.getFishTimes;
gottenFishAmount.value = res.getFishNum;
showToastBox.value = true;
} else {
refresh();
}
})
.catch((reason) => {
const code = reason.data.Code;
if (code === 10001) {
uni.showToast({
title: "文本含敏感内容",
icon: "none"
});
} else if (code === 10002) {
uni.showToast({
title: "图片含敏感内容",
icon: "none"
});
} else {
uni.showToast({
title: "发送失败",
icon: "none"
});
}
isPublished.value = false;
});
};
</script>

Expand Down

0 comments on commit a7786fc

Please sign in to comment.