actions.ts 917 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { title } from 'radash'
  2. import { cancelCircleReviewUpvote, cancelCircleUpvote, createCircleUpvote } from './requests'
  3. const toast = (title: string) => uni.showToast({ title, icon: 'none' })
  4. export const handleUpvoteClick = async (
  5. {
  6. upvote,
  7. circleId,
  8. userId,
  9. userName,
  10. }: {
  11. upvote: boolean
  12. circleId: number
  13. userId: number
  14. userName: string
  15. },
  16. callback?: () => void,
  17. ) => {
  18. if (!upvote) {
  19. const { code, msg } = await createCircleUpvote({ circleId, userId, userName })
  20. code === 0 && toast('点赞成功')
  21. } else {
  22. const { code } = await cancelCircleUpvote({ id: circleId.toString() })
  23. code === 0 && toast('取消点赞成功')
  24. }
  25. callback && callback()
  26. }
  27. export const toHomePage = (id: string) => {
  28. uni.navigateToMiniProgram({
  29. appId: 'wx4d95c9addba81089',
  30. envVersion: 'trial',
  31. path: '/pages/mine/homepage/index' + '?id=' + id,
  32. })
  33. }