|
@@ -64,7 +64,19 @@ const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
|
|
|
onReport()
|
|
|
//假如存在阅读记录获取对应章节的条数
|
|
|
let readLogId = getReadLog(openBookData?.bookId)
|
|
|
- getBookContent({ pageNum: 1, pageSize: readLogId ? Number(readLogId?.split('-')[1]) : 2 }).then(res => {
|
|
|
+ getBookContent({ pageNum: 1, pageSize: readLogId ? Number(readLogId?.split('-')[1]) : 2 }).then((res: any) => {
|
|
|
+ if (res?.data) {
|
|
|
+ for (let item of res?.data?.data?.records) {
|
|
|
+ let needPay = item.needPay //是否付费解锁
|
|
|
+ let isPay = item.isPay //是否已付费
|
|
|
+ if (!showPay && needPay && !isPay) {
|
|
|
+ setShowPay(true)
|
|
|
+ setShowVip(item.vipFree)
|
|
|
+ setPayBook(item)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//继续阅读时跳转到上次阅读的段落
|
|
|
console.log("上次阅读到readLogId", readLogId)
|
|
|
setCurrentScrollId(readLogId)
|
|
@@ -168,7 +180,20 @@ const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
|
|
|
if (records.length < total || reload) {
|
|
|
console.log("加载")
|
|
|
setIsLoad(true)
|
|
|
- await getBookContent({ pageNum: 1, pageSize: reload ? size : size + 1 }).then(res => {
|
|
|
+ await getBookContent({ pageNum: 1, pageSize: reload ? size : size + 1 }).then((res: any) => {
|
|
|
+ if (res?.data) {
|
|
|
+ for (let item of res?.data?.data?.records) {
|
|
|
+ let needPay = item.needPay //是否付费解锁
|
|
|
+ let isPay = item.isPay //是否已付费
|
|
|
+ // let isVip =
|
|
|
+ if (!showPay && needPay && !isPay) {
|
|
|
+ setShowPay(true)
|
|
|
+ setShowVip(item.vipFree)
|
|
|
+ setPayBook(item)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
setIsLoad(false)
|
|
|
})
|
|
|
} else {
|
|
@@ -218,13 +243,13 @@ const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
|
|
|
let res = await cashBuy(params, onLoad)
|
|
|
if (res) {
|
|
|
console.log("全本购买:", res)
|
|
|
- setTimeout(()=>{
|
|
|
+ setTimeout(() => {
|
|
|
setShowPay(false)
|
|
|
setShowVip(false)
|
|
|
setPayBook(null)
|
|
|
- },100)
|
|
|
+ }, 100)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
// 书币购买
|
|
@@ -240,14 +265,13 @@ const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
|
|
|
let res = await virtualBuy(params, onLoad)
|
|
|
if (res) {
|
|
|
console.log("书币购买章节:", res)
|
|
|
- setTimeout(()=>{
|
|
|
+ setTimeout(() => {
|
|
|
setShowPay(false)
|
|
|
setShowVip(false)
|
|
|
setPayBook(null)
|
|
|
modalStore.hideModal()
|
|
|
- },100)
|
|
|
+ }, 100)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -294,12 +318,12 @@ const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
|
|
|
let arr = item.paragraphInfo.content?.match(/[^\n]*\n?/g);
|
|
|
// 是否需要付费
|
|
|
if (!showPay && needPay && !isPay) {
|
|
|
- console.log("是否需要付费====>",item,)
|
|
|
+ console.log("是否需要付费====>", item,)
|
|
|
showText = false
|
|
|
- setShowPay(true)
|
|
|
- setShowVip(item.vipFree)
|
|
|
- setPayBook(item)
|
|
|
- }else{
|
|
|
+ // setShowPay(true)
|
|
|
+ // setShowVip(item.vipFree)
|
|
|
+ // setPayBook(item)
|
|
|
+ } else {
|
|
|
// if (showPay) {
|
|
|
// setShowPay(false)
|
|
|
// setShowVip(false)
|