shenwu 6 mēneši atpakaļ
vecāks
revīzija
5adf6f22d1

+ 1 - 1
src/app.tsx

@@ -72,7 +72,7 @@ class App extends Component {
   componentDidCatchError() { }
 
   render() {
-    console.log("1111",1111)
+    console.log("store.userInfoStore.userInfo",store.userInfoStore.userInfo)
     return <Provider store={store}>
       {(this.props as ProviderProps).children}
     </Provider >

+ 3 - 2
src/components/PupPetry/BannerBox/index.tsx

@@ -19,9 +19,10 @@ function BannerBox(props: BannerBoxProps) {
     >
         {
             data?.map((item, index: number) => {
-                let { bookId,bannerType, bannerImage,activityPagePath } = item
+                let { bookId, bannerType, bannerImage, activityPagePath } = item
+                console.log(bannerType === 0 ? '/pages/book/bookDetails/index?bookId=' + bookId : '/' + activityPagePath)
                 return <SwiperItem key={index}>
-                    <Navigator url={bannerType === 0 ?'/pages/book/bookDetails/index?bookId=' + bookId : activityPagePath} hoverClass="none">
+                    <Navigator url={bannerType === 0 ? '/pages/book/bookDetails/index?bookId=' + bookId : '/' + activityPagePath} hoverClass="none">
                         <Image src={bannerImage} className='img' />
                     </Navigator>
                 </SwiperItem>

+ 3 - 3
src/components/PupPetry/BookTypeTabs/index.tsx

@@ -13,16 +13,16 @@ type props = {
         id: number
     },  // tab选中第几个  默认1
     onCallback?: (value: string | number, isType?: boolean) => void,     // 切换回调函数
-    workDirection: string,//频道
+    workDirection: 0 | 1,//频道
 }
 
 
-/**分类页面顶部分类选择*/ 
+/**分类页面顶部分类选择*/
 const BookTypeTabs = (props: props) => {
     let { typeValue, typeTabIndex, workDirection } = props
     let [open, setOpen] = useState<boolean>(false)
     //选择
-    let selectHandle = useCallback((value: {id:number,name:string}) => {
+    let selectHandle = useCallback((value: { id: number, name: string }) => {
         classifyStore.setData({ categoryId: value })
     }, [])
     //展示更多

+ 2 - 3
src/components/TopNavBar/index.tsx

@@ -32,7 +32,6 @@ type Props = {
 
 
 function CustomNavbar(WrappedComponent, props: Props) {
-    console.log(props)
     let { children, title, color, fontSize, backgroundColor, tab = false, tabVal, search = false, searchBack = false, isToBack = false, isReloadBook = false } = props
     interface Page {
         props: {
@@ -56,7 +55,6 @@ function CustomNavbar(WrappedComponent, props: Props) {
 
         }
         componentDidMount() {
-            log('计算高')
             const { indexStore: { navBarTop } } = this.props.store
             let buttonBounding = Taro.getMenuButtonBoundingClientRect()
             log(buttonBounding);
@@ -67,6 +65,7 @@ function CustomNavbar(WrappedComponent, props: Props) {
         }
 
         selectHandle = (value: string | number) => {
+            console.log(value)
             this.props.store.bookStore.setWorkDirection(value as 0 | 1)
         }
         //回上级
@@ -81,7 +80,6 @@ function CustomNavbar(WrappedComponent, props: Props) {
         }
         // 去搜索页面
         searchBackHandle = () => {
-            console.log(1111)
             Taro.navigateTo({
                 url: '/pages/search/index'
             })
@@ -104,6 +102,7 @@ function CustomNavbar(WrappedComponent, props: Props) {
             let { navBar, capsuleWidth } = this.state
             const { indexStore: { navBarTop }, bookStore } = this.props.store
             let stateIndex = bookStore.workDirection
+            console.log(this.props.store.bookStore)
             return <View style={{ height: navBar + navBarTop + 5 }}>
                 <View className='navbarWrap' style={{ paddingTop: navBarTop + 5, height: navBar, backgroundColor: isReloadBook ? bookStore.bookConfig?.off_on ? "#FFF" : "#363738" : "#FFF" }}>
                     <View className='content'>

+ 1 - 0
src/config.ts

@@ -19,6 +19,7 @@ export interface App {
     isLoding?: boolean,//是否显示每次请求的加载loding弹窗
     initToken?: string,//初始化toekn用于登录时使用
     token?: string,//登录后的token
+    userInfo?: any
 }
 
 // // 定义全局日志函数

+ 11 - 11
src/interceptor.ts

@@ -35,13 +35,13 @@ const requestInterceptor = (chain) => {
         return new Promise(() => { });
     }
     // 处理参数
-    if (requestParams.data?.workDirection) {
-        if (requestParams.data?.workDirection === "男生") {
-            requestParams.data.workDirection = 0
-        } else {
-            requestParams.data.workDirection = 1
-        }
-    }
+    // if (requestParams.data?.workDirection) {
+    //     if (requestParams.data?.workDirection === "男生") {
+    //         requestParams.data.workDirection = 0
+    //     } else {
+    //         requestParams.data.workDirection = 1
+    //     }
+    // }
     //分类列表假如上次请求的频道没变就不再获取
     if (requestParams.url.includes('/app/bookCategory/list')) {
         if (requestParams.data.workDirection === bookStore.oldWorkDirection) {
@@ -71,11 +71,12 @@ const responseInterceptor = (chain) => {
                 // 初始化接口调用登录接口,登录接口存在自己的执行判断
                 if (chain.requestParams.url.includes("loginInitialize")) {
                     setApp({ initToken: data.data.token })
-                    // appInfoStore.actionAppInfo(data.data.appInfo)
-                    let res: any = await api.getAppComponent()
+                    appInfoStore.actionAppInfo(data.data.appInfo)
+                    // let res: any = await api.getAppComponent()
                     let user: any = await api.login()
+                    Taro.setStorageSync("userInfo", user)
                     setApp({ appName: data?.data?.appInfo?.appName })
-                    appInfoStore.setData({ appInfo: data.data.appInfo, appComponent: res.data.data, token: user.token })
+                    appInfoStore.setData({ appInfo: data.data.appInfo, })
                     // 检测待请求列表中是否存在请求,存在就执行请求
                     while (pendingRequests.length > 0) {
                         console.log("存在待请求")
@@ -92,7 +93,6 @@ const responseInterceptor = (chain) => {
                 console.log("登录后重新请求===>")
                 const newRequestParams = chain.requestParams;
                 return Taro.request(newRequestParams).then(newResponse => newResponse.data);
-                break;
             default:
                 log("未知错误", data)
                 Taro.showToast({

+ 4 - 4
src/pages/classify/index.tsx

@@ -31,7 +31,7 @@ const Index = forwardRef((props: Props) => {
             getBookCategoryList(workDirection)
 
         }
-    }, [appInfoStore.token, bookStore.workDirection, pageShow]); // Dependency array, runs effect only once on mount and unmount
+    }, [bookStore.workDirection, pageShow]); // Dependency array, runs effect only once on mount and unmount
     //获取书籍列表
     useEffect(() => {
         if (pageShow) {
@@ -39,7 +39,7 @@ const Index = forwardRef((props: Props) => {
             let { categoryId } = classifyStore
             categoryId.id != 0 && classifyStore.categoryId && getList({ workDirection, categoryId: categoryId.id, pageNum: 1, pageSize: 10 })
         }
-    }, [appInfoStore.token, bookStore.workDirection, classifyStore.categoryId, pageShow])
+    }, [bookStore.workDirection, classifyStore.categoryId, pageShow])
     // 使用 useDidShow 代替 onShow
     useDidShow(() => {
         setPageShow(true)
@@ -55,7 +55,7 @@ const Index = forwardRef((props: Props) => {
         let { categoryId } = classifyStore
         getList({ workDirection, categoryId: categoryId.id, pageNum: 1, pageSize: 10 })
     }
-    //下加载
+    //下加载
     const load = () => {
         return new Promise((resolve, reject) => {
             let { size, total, records } = bookStore.bookList
@@ -105,7 +105,7 @@ const Index = forwardRef((props: Props) => {
 });
 export default TopNavBar(inject('store')(observer(Index)), {
     tab: true,
-    tabVal: [{ value: "男生", text: "男生" }, { value: "女生", text: "女生" }],
+    tabVal: [{ value: 0, text: "男生" }, { value: 1, text: "女生" }],
     backgroundColor: '#fff',
     color: "#333",
     search: false,

+ 10 - 8
src/pages/index/index.tsx

@@ -24,17 +24,19 @@ const Index: React.FC<Props> = ({ store }) => {
     // 首页配置信息
     const indexConfig = useMemo(() => {
         let obj = {}
-        appInfoStore.appComponent?.forEach((item, index) => {
+        let thatPage = appInfoStore?.appInfo?.appPageComponentList.find(item => item.pagePath === 'pages/index/index')
+        let thatWd = thatPage?.appComponentListVOS?.find(item => item.workDirection === bookStore.workDirection)
+        thatWd?.appComponentListVOS?.forEach((item, index) => {
             return obj[item.componentType] = { ...item, eq: index }
         })
         return obj
-    }, [indexComponents, pageShow])
+    }, [indexComponents, pageShow, bookStore.workDirection])
     // 页面显示请求数据
     useEffect(() => {
-        if (pageShow && appInfoStore.token) {
+        if (pageShow) {
             indexCompontent()
         }
-    }, [pageShow, appInfoStore.token, , bookStore.workDirection, appInfoStore.appComponent]); // Dependency array, runs effect only once on mount and unmount
+    }, [pageShow, appInfoStore.token, bookStore.workDirection, appInfoStore.appInfo]); // Dependency array, runs effect only once on mount and unmount
     // 使用 useDidShow 代替 onShow
     useDidShow(() => {
         // 分享消息配置
@@ -97,10 +99,10 @@ const Index: React.FC<Props> = ({ store }) => {
             <BookHead showBtn={indexStore?.indexHotBooks?.showRightButton} title={indexStore?.indexHotBooks?.name || "今日热书"} fitTitle="更多" imgUrl={require('../../icon/right.png')} fitOnBack={() => {
                 Taro.navigateTo({ url: `/pages/indexMore/index?title=今日热书&dataName=indexHotBooks` })
             }}></BookHead>
-            <View ><BookboxRowMiddle {...indexStore?.indexHotBooks?.shortBookInfoListVOS?.[0]} /></View>
+            <View ><BookboxRowMiddle {...indexStore?.indexHotBooks?.[appInfoStore?.appInfo?.appCategory === 1 ? "longBookInfoAppVOS" : "shortBookInfoAppVOS"]?.[0]} /></View>
             <View className='w row'>
                 {
-                    indexStore?.indexHotBooks?.shortBookInfoListVOS?.map((item, index) => {
+                    indexStore?.indexHotBooks?.[appInfoStore?.appInfo?.appCategory === 1 ? "longBookInfoAppVOS" : "shortBookInfoAppVOS"]?.map((item, index) => {
                         if (index > 0 && index < 5) {
                             return <View key={index}><BookboxColumnSmall {...item} /></View>
                         }
@@ -110,7 +112,7 @@ const Index: React.FC<Props> = ({ store }) => {
         </View>}
         {/* 热门分类 */}
         {indexConfig['hot_category'] && <View style={{ order: indexConfig['banners'].eq }}>
-            <BookHead  showBtn={indexStore?.indexHotCategory?.showRightButton}  title={indexStore?.indexHotCategory?.name || "热门分类"} fitTitle="全部分类" imgUrl={require('../../icon/right.png')} fitOnBack={() => { Taro.switchTab({ url: '/pages/classify/index' }) }} />
+            <BookHead showBtn={indexStore?.indexHotCategory?.showRightButton} title={indexStore?.indexHotCategory?.name || "热门分类"} fitTitle="全部分类" imgUrl={require('../../icon/right.png')} fitOnBack={() => { Taro.switchTab({ url: '/pages/classify/index' }) }} />
             <BookHotTabs hotValue={indexStore?.indexHotCategory?.bookCategoryList || []} onBack={(value) => {
                 getHotBooks(value)
             }} />
@@ -126,7 +128,7 @@ const Index: React.FC<Props> = ({ store }) => {
 };
 export default TopNavBar(inject('store')(observer(Index)), {
     tab: true,
-    tabVal: [{ value: "男生", text: "男生" }, { value: "女生", text: "女生" }],
+    tabVal: [{ value: 0, text: "男生" }, { value: 1, text: "女生" }],
     backgroundColor: '#fff',
     color: "#333",
     search: true

+ 3 - 2
src/pages/my/index.tsx

@@ -17,6 +17,7 @@ class My extends Component<Props> {
     }
     render() {
         let { userInfoStore } = this.props.store
+        let userInfo = userInfoStore?.userInfo || Taro.getStorageSync("userInfo")?.userInfo
         return <View className='my'>
             <View className="userInfo">
                 {/* <Image src={require('../../icon/myBack.png')} /> */}
@@ -29,8 +30,8 @@ class My extends Component<Props> {
                             </View>
                             <View className="name" style={userInfoStore.isAuth ? { width: Taro.pxTransform(120) } : {}}>
                                 {
-                                    userInfoStore.userInfo?.nickName ? <View className="ID">{userInfoStore.userInfo?.nickName || ""}</View> :
-                                        <View className="ID">读友_sdajhsd</View>
+                                    userInfo?.nickName ? <View className="ID">{userInfo?.nickName || ""}</View> :
+                                        <View className="ID">{userInfo?.openId}</View>
                                 }
                                 {
                                     userInfoStore.isVip && <View className="grade">

+ 1 - 1
src/server/book/short/index.tsx

@@ -4,7 +4,7 @@ import bookStore from "@src/store/book";
 import { setReadLog } from "@src/utils/loginSto";
 
 interface BookParams {
-    workDirection: string,//频道
+    workDirection: 0 | 1,//频道
     categoryId: number,//分类ID
     pageNum: number,//分页
     pageSize: number//页数

+ 0 - 3
src/server/index.ts

@@ -1,6 +1,5 @@
 import { wxlogin, wxloginInit } from './wx/login'
 import { dylogin, dyloginInit } from './dy/login'
-import { getAppComponent } from './index/index'
 import { getBookCategoryList } from './classify'
 const isWechat = process.env.TARO_ENV === 'weapp'
 //统一导出接口,用于判断打包时的环境,使用不同的接口
@@ -9,8 +8,6 @@ const apiObj = {
     login: isWechat ? wxlogin : dylogin,
     /**初始化*/
     loginInit: isWechat ? wxloginInit : dyloginInit,
-    /**小程序组件列表*/
-    getAppComponent,
     /**小说分类列表*/
     getBookCategoryList,
 }

+ 21 - 21
src/server/index/index.ts

@@ -3,25 +3,25 @@ import indexStore from "@src/store/index";
 /**
  * 获取小程序组件配置列表
  * */
-export function getAppComponent() {
-    return new Promise(async (resolve, reject) => {
-        try {
-            // 初始化
-            Taro.request({
-                url: '/app/appComponent/list',
-                method: 'GET',
-                success: (res) => {
-                    resolve(res)
-                },
-                fail: (err) => {
-                    reject(err);
-                }
-            })
-        } catch (error) {
-            reject(error);
-        }
-    })
-}
+// export function getAppComponent() {
+//     return new Promise(async (resolve, reject) => {
+//         try {
+//             // 初始化
+//             Taro.request({
+//                 url: '/app/appComponent/list',
+//                 method: 'GET',
+//                 success: (res) => {
+//                     resolve(res)
+//                 },
+//                 fail: (err) => {
+//                     reject(err);
+//                 }
+//             })
+//         } catch (error) {
+//             reject(error);
+//         }
+//     })
+// }
 
 
 
@@ -33,7 +33,7 @@ export function getShortBanners(workDirection) {
         try {
             // 初始化
             Taro.request({
-                url: '/app/appComponent/getShortBookBanners',
+                url: '/app/appComponent/getBanners',
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
@@ -81,7 +81,7 @@ export function getShortHotBooks(workDirection) {
         try {
             // 初始化
             Taro.request({
-                url: '/app/appComponent/getShortBookHotBooks',
+                url: '/app/appComponent/getHotBooks',
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {

+ 4 - 2
src/server/wx/login.ts

@@ -2,6 +2,7 @@ import { setApp } from "@src/config";
 import { ResData } from "@src/interceptor"
 import Taro from "@tarojs/taro"
 import userInfoStore from '@src/store/userInfo'
+import appInfoStore from "@src/store/appInfo";
 /**
  * 用户登录初始化(用来获取应用相关信息,并获取登录token)
  * */
@@ -39,8 +40,9 @@ export function wxlogin() {
               data: { jsCode: res.code },
             });
             if (response.code === 200) {
-              setApp({token:response.data.token})//存放token
+              setApp({token:response.data.token,userInfo:response.data.userInfo})//存放token
               userInfoStore.setData({userInfo:response.data.userInfo})
+              appInfoStore.actionToken(response.data.token )
               resolve(response.data)
             }
           } else {
@@ -54,6 +56,6 @@ export function wxlogin() {
     })
   } else {
     log("已登录")
-    return Promise.resolve({token:app.token})
+    return Promise.resolve({token:app.token,userInfo:app?.userInfo})
   }
 }

+ 41 - 12
src/store/appInfo.tsx

@@ -12,16 +12,52 @@ export interface AppInfo {
     homePage: string,//主页路径
     id: 4,//
     wechatAppId: string,//小程序ID
+    appPageComponentList: AppPageComponent[],//组件配置
+    appRechargeTemplateList: RechargeTemplate[],//支付模板
+}
+interface RechargeTemplate {
+    templateDescription:string,//模板描述
+    templateName:string,//模板名称
+    templateType:1|2,//模板类型 1书币 2vip
+    remark:string,//备注
+    appType:1|2,//1微信 2抖音
+    id:number,
+    activateTemplate:boolean,//激活
+    rechargeConfigs:{
+        firstRecharge:boolean,//是否是首充档位
+        rechargeConfigList:Config[],//
+    }[]
+}
+interface Config{
+    color:boolean,//背景色
+    description:string,//整数购买文案
+    extra:string,//右上角描述值
+    gearType:1|2,//充值类型 1书币 2 vip
+    gift:string,//赠送
+    obtain:string,//获得书币/vip每天价格
+    price:number,//价格
+    subscript:string,//右上角文案 首充|超值等
+    vipDays:number,//vip天数
+}
+interface AppPageComponent {
+    pageName: string,//页面名称
+    pagePath: string,//页面路径
+    id: number,//组件ID
+    sharePicUrl: string,//分享图
+    shareTitles: string,//分享标题
+    pageDesc: string,//页面描述
+    appComponentListVOS: {
+        workDirection: 0 | 1,//男频女频
+        appComponentListVOS: AppComponent[]
+    }[]
 }
 interface AppComponent {
-    id: number,
-    componentType: string,//组件名称
+    componentType: "banners" | "hot_books" | "hot_category",
+    id: number
 }
 export interface AppInfoStore {
     /**app初始化信息*/
     appInfo?: AppInfo,
-    /**主页组件展示信息*/
-    appComponent?: AppComponent[],
     /**登录后的token*/
     token?: string,//token
     /**进入的场景*/
@@ -32,8 +68,6 @@ export interface AppInfoStore {
     actionAppInfo: (appInfo: AppInfo) => void
     /**设置登录后的token*/
     actionToken: (token: string) => void
-    /**设置组件列表*/
-    setAppComponent: (appComponent: AppComponent[]) => void
     setData: (data: { [key: string]: any }) => void,
 }
 /**
@@ -47,14 +81,9 @@ const appInfoStore: AppInfoStore = observable({
         }
     },
     actionToken(token: string) {
-        console.log("设置token",token)
+        console.log("设置token", token)
         this.token = token
     },
-    setAppComponent(appComponent: AppComponent[]) {
-        if (appComponent) {
-            this.appComponent = appComponent
-        }
-    },
     setData(data: { [key: string]: any }) {
         if (data) {
             Object.keys(data).forEach(key => {

+ 5 - 7
src/store/book.ts

@@ -32,8 +32,8 @@ export interface BookStore {
     readId: number,//
     bookList: any,
     /**1女频 0男频 默认男频*/
-    workDirection: "男生" | "女生",
-    oldWorkDirection: "男生" | "女生",
+    workDirection: 0 | 1,
+    oldWorkDirection?: 0 | 1,
     /**分类列表*/
     classifyData: ClassifyData[],
     /**阅读背景*/
@@ -57,8 +57,8 @@ export interface BookStore {
  */
 const Book: BookStore = observable({
     openBookData: null,
-    workDirection: "男生",
-    oldWorkDirection: "男生",
+    workDirection: 0,
+    oldWorkDirection: undefined,
     classifyData: [],
     bookList: [],
     readId: 0,
@@ -76,9 +76,7 @@ const Book: BookStore = observable({
         }
     },
     setWorkDirection(workDirection: 0 | 1) {
-        if (workDirection) {
-            this.workDirection = workDirection
-        }
+        this.workDirection = workDirection
     },
     setClassifyData(classifyData: ClassifyData[]) {
         if (classifyData) {

+ 4 - 2
src/store/index.ts

@@ -19,7 +19,8 @@ export interface IndexStore {
         name: string,//名称
         showRightButton: boolean,//右侧按钮是否展示
         workDirection: number,//频道
-        shortBookInfoListVOS:any[],//书籍内容
+        longBookInfoAppVOS:any[]
+        shortBookInfoAppVOS:any[],//书籍内容
     },//首页热门数据
     indexHotCategory: {
         bookCategoryList: { id: number, name: string }[],//分类
@@ -41,7 +42,8 @@ const Index = observable({
         name: "今日热书",//名称
         showRightButton: true,//右侧按钮是否展示
         workDirection: 0,//频道
-        shortBookInfoListVOS:[],//书籍内容
+        shortBookInfoAppVOS:[],//短篇
+        longBookInfoAppVOS:[],//长篇
     },//首页热门数据
     indexHotCategory: {
         bookCategoryList: [],//分类