BookboxColumnBig.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**分类书籍的box容器 横大*/
  2. import { Text, View, Image, Navigator } from "@tarojs/components";
  3. import React from 'react'
  4. import './index.less'
  5. import useApi from "@src/Hook/useApi";
  6. import Taro from "@tarojs/taro";
  7. let { getBookInfo } = useApi()
  8. export interface BookboxColumnBigProps {
  9. bookId: number,//书ID
  10. authorName: string,//作者
  11. bookName: string,//书名称
  12. bookDesc: string,//描述
  13. picUrl: string,//封面
  14. bookStatus: number,//完本|连载状态
  15. wordCount: number,//字数
  16. labelInfoList: { name: string }[],//标签
  17. vipFree: boolean
  18. }
  19. function BookboxColumnBig(props: BookboxColumnBigProps) {
  20. const { picUrl, bookName, bookId, authorName, vipFree } = props
  21. const click = () => {
  22. getBookInfo(bookId).then((res: { data: any, code: any }) => {
  23. if (res?.data?.code == 200) {
  24. console.log(res?.data?.data)
  25. let { wechatBookId,inBookshelf } = res?.data?.data
  26. let json = JSON.stringify({inBookshelf,bookId})
  27. let encode = encodeURIComponent(json)
  28. if (wechatBookId) {
  29. Taro.navigateTo({
  30. url: `plugin-private://wx293c4b6097a8a4d0/pages/novel/index?bookId=${wechatBookId}&customServerParams=${encode}`
  31. })
  32. }else{
  33. Taro.showToast({
  34. title: '小说未上架',
  35. icon: 'none'
  36. })
  37. }
  38. }
  39. })
  40. }
  41. return <View className='book_box_column_big' onClick={click} >
  42. <Image src={picUrl || ''} className={`img ${vipFree ? "isVip" : ""}`}></Image>
  43. <View className='bottom'>
  44. <Text className='title'>{bookName}</Text>
  45. <Text className='author'>{authorName}</Text>
  46. </View>
  47. </View>
  48. }
  49. export default React.memo(BookboxColumnBig)