| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- import { View } from "@tarojs/components";
- import { More } from "@nutui/icons-react-taro";
- import { ActionSheet } from "@nutui/nutui-react-taro";
- import { useState } from "react";
- import { interactionApi } from "../../api/interaction";
- import { navigateTo } from "@tarojs/taro";
- export default function MoreButton({
- postIndex,
- followeeId,
- postId,
- postItem,
- onClick,
- }: {
- postIndex: number;
- followeeId: number;
- postId: number;
- postItem: any;
- onClick?: (postIndex: number) => void;
- }) {
- const [showMore, setShowMore] = useState(false);
- const moreOptions = [
- {
- name: "不喜欢该动态",
- value: "post_dislike",
- },
- {
- name: "不喜欢该作者",
- value: "author_dislike",
- },
- {
- name: "举报该动态",
- value: "post_report",
- },
- ];
- const handleSelectMore = (item: any) => {
- const { value } = item;
- if (value === "post_dislike") {
- interactionApi({
- target_type: "post",
- target_id: postId,
- interaction_type: "dislike",
- });
- onClick && onClick(postIndex);
- } else if (value === "author_dislike") {
- interactionApi({
- target_type: "author",
- target_id: followeeId,
- interaction_type: "dislike",
- });
- onClick && onClick(postIndex);
- } else if (value === "post_report") {
- navigateTo({
- url: `/pages/report/index?target_type=post&target_id=${postId}`,
- // events: {
- // onBack: (data) => console.log("返回数据:", data),
- // onUpdate: (data) => console.log("更新数据:", data),
- // },
- // success: function (res) {
- // // 通过eventChannel向被打开页面传送数据
- // console.log("===");
- // res.eventChannel.emit("init", postItem);
- // },
- });
- }
- setShowMore(false);
- };
- return (
- <>
- <View
- onClick={(e) => {
- e.stopPropagation();
- setShowMore(true);
- }}
- >
- <More size={12} color="#949494" />
- </View>
- <ActionSheet
- visible={showMore}
- cancelText="取消"
- options={moreOptions}
- onSelect={handleSelectMore}
- onCancel={() => {
- setShowMore(false);
- }}
- />
- </>
- );
- }
|