shenwu 6 months ago
parent
commit
7cdf4f133a

+ 2 - 2
src/Hook/useApi.ts

@@ -4,9 +4,9 @@ import { getShortBanners, getShortHotCategory, getShortHotBooks } from '@src/ser
 /**用于长短篇小说区别,使用不同的接口
  * 传入appInfoStroe
 */
-function useApi(store) {
+function useApi() {
     //判断是长篇
-    let isLong = store?.appInfo?.appCategory === 1
+    let isLong = app?.appInfo?.appCategory === 1
     return {
         /**获取小说列表*/
         getBookPageList: isLong ? getShortBookInfoAppListOfPage : getShortBookInfoAppListOfPage,

+ 1 - 0
src/app.config.ts

@@ -7,6 +7,7 @@ export default {
     'pages/my/index',//我的
     'pages/book/bookDetails/index',//书籍详情
     'pages/vipCore/index',//会员中心
+    'pages/myAccount/index',//我的账户
     'pages/my/aboutUs/index',//关于我们
     'pages/my/contactService/index',//联系客服
     'pages/book/bookArticle/index',//书籍内容 阅读页

+ 10 - 12
src/app.tsx

@@ -6,7 +6,6 @@ import './app.less'
 import userInfoStore, { UserInfoStore } from './store/userInfo'
 import indexStore, { IndexStore } from './store/index'
 import Book, { BookStore } from './store/book'
-import appInfoStore, { AppInfoStore } from './store/appInfo'
 import classifyStore, { ClassifyStore } from './store/classIfy'
 import modalStore from './store/modalStore'
 
@@ -19,21 +18,19 @@ import api from './server/index'
 
 
 export interface Store {
-  appInfoStore: AppInfoStore
   userInfoStore: UserInfoStore,
   indexStore: IndexStore,
   bookStore: BookStore,
   classifyStore: ClassifyStore,
-  modalStore:{
+  modalStore: {
     visible: boolean,    // 弹窗开关
-    showModal:()=>void,
-    hideModal:()=>void
+    showModal: () => void,
+    hideModal: () => void
   }
 }
 const store: Store = {
   userInfoStore,
   indexStore,
-  appInfoStore,
   bookStore: Book,
   classifyStore,
   modalStore
@@ -41,15 +38,16 @@ const store: Store = {
 class App extends Component {
 
   //每次打开小程序触发,后台切入不算
-   onLaunch(options) {
+  onLaunch(options) {
+
   }
   componentDidMount() {
     console.log("APPcomponentDidMount")
     /**获取状态栏高度 */
     Taro.getSystemInfo({}).then(res => {
-      let { system, statusBarHeight } = res
+      let { system, statusBarHeight,platform } = res
       indexStore.setData({ navBarTop: statusBarHeight, system })//设置navbar高度和当前系统
-      setApp({ system })
+      setApp({ system:platform })
     })
   }
   async componentDidShow(options) {
@@ -62,8 +60,8 @@ class App extends Component {
     // 启动初始化
     console.log("初始化")
     initApp()//初始化全局变量
-    let appId = Taro.getAccountInfoSync().miniProgram.appId//获取当前小程序的APPID 
-    setApp({ appId })
+    let { appId, version, envVersion } = Taro.getAccountInfoSync().miniProgram//获取当前小程序的APPID 
+    setApp({ appId, proVersion: version, envVersion })
     // 初始化登录,获取登录使用的token存放用于登录使用
     await api.loginInit(appId)
   }
@@ -72,7 +70,7 @@ class App extends Component {
   componentDidCatchError() { }
 
   render() {
-    console.log("store.userInfoStore.userInfo",store.userInfoStore.userInfo)
+    console.log("store.userInfoStore.userInfo", store.userInfoStore.userInfo)
     return <Provider store={store}>
       {(this.props as ProviderProps).children}
     </Provider >

+ 1 - 2
src/components/bookConfigPup/index.tsx

@@ -1,7 +1,6 @@
 import { View, Text, Image, Navigator } from "@tarojs/components";
 import React from "react";
 import './index.less';
-import appInfoStore from "@src/store/appInfo";
 interface BookConfigPupProps {
     setOff: () => void,//设置开关
     setSize: (num: number) => void,//设置字体
@@ -16,7 +15,7 @@ interface BookConfigPupProps {
 }
 function BookConfigPuP(props: BookConfigPupProps) {
     let { setOff, setSize, setLh, setBg, size, off_on, bg, lh, booKId, chapter } = props
-    let isLong = appInfoStore?.appInfo?.appCategory === 1
+    let isLong = app?.appInfo?.appCategory === 1
     size = size?.split('_')[1]
     return <View className={off_on ? 'bottom_pup' : 'bottom_pup black'}>
         <View className='bg'>

+ 6 - 0
src/components/pay/IosShowPay/index.tsx

@@ -0,0 +1,6 @@
+function IosShowPay(props) {
+    return <>
+        {app?.iosShowPay ? props.children : null}
+    </>
+}
+export default IosShowPay

+ 92 - 2
src/config.ts

@@ -9,6 +9,66 @@ globalThis.app = {
     isLoding: false,//是否显示每次请求的加载loding弹窗
     initToken: "",//初始化toekn用于登录时使用
     token: "",//登录后的token
+    appInfo: null,//初始化
+    proVersion: "",
+    payVersion: "",
+    iosShowPay: true,
+    envVersion: "develop"
+}
+
+type ConfigParamList = {}
+export interface AppInfo {
+    appCategory: 1 | 2,//1长篇 2短篇
+    appName: string,//小程序名称
+    appVersion: string,//小程序版本
+    configParamList: ConfigParamList[],//小程序配置
+    distributorId: 1,//分销商ID
+    enabled: true,//启用状态
+    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 {
+    componentType: "banners" | "hot_books" | "hot_category",
+    id: number
 }
 export interface App {
     appName?: string;//小程序名称
@@ -20,14 +80,44 @@ export interface App {
     initToken?: string,//初始化toekn用于登录时使用
     token?: string,//登录后的token
     userInfo?: any
+    /**app初始化信息*/
+    appInfo?: AppInfo | null,
+    /**当前小程序线上版本*/
+    proVersion: string,
+    /**当前小程序支付版本*/
+    payVersion: string,
+    /**ios是否展示支付*/
+    iosShowPay: boolean,
+    /**小程序环境*/
+    envVersion: "develop" | "trial" | "release"
+}
+export interface SetApp {
+    appName?: string;//小程序名称
+    apiUrl?: string;//接口地址头部
+    appId?: string;//当前小程序ID
+    system?: string,//当前系统环境
+    showLog?: boolean,//控制台是否打印日志
+    isLoding?: boolean,//是否显示每次请求的加载loding弹窗
+    initToken?: string,//初始化toekn用于登录时使用
+    token?: string,//登录后的token
+    userInfo?: any
+    /**app初始化信息*/
+    appInfo?: AppInfo,
+    /**当前小程序线上版本*/
+    proVersion?: string,
+    /**当前小程序支付版本*/
+    payVersion?: string,
+    /**ios是否展示支付*/
+    iosShowPay?: boolean,
+    /**小程序环境*/
+    envVersion?: "develop" | "trial" | "release"
 }
-
 // // 定义全局日志函数
 globalThis.log = app.showLog ? console.log : () => { };
 /**
  * 传入参数设置全局变量(进入APP后固定不变的参数,并存入到本地)
 */
-export function setApp(props?: App) {
+export function setApp(props?: SetApp) {
     // log("初始化设置APP关键固定参数===>", props)
     if (props) {
         Object.keys(props).forEach((key) => {

+ 16 - 15
src/interceptor.ts

@@ -1,9 +1,9 @@
 import Taro from '@tarojs/taro';
 import api from './server/index';
 import { setApp } from './config';
-import appInfoStore from '@src/store/appInfo'
 import bookStore from '@src/store/book'
 import { getRechargeTemplate } from './server/index/index';
+import indexStore from './store/index'
 export interface ResData {
     code: number,
     data: any,
@@ -35,14 +35,6 @@ const requestInterceptor = (chain) => {
         // 返回一个被拒绝的Promise以中断请求
         return new Promise(() => { });
     }
-    // 处理参数
-    // 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,14 +63,23 @@ const responseInterceptor = (chain) => {
             case 200:
                 // 初始化接口调用登录接口,登录接口存在自己的执行判断
                 if (chain.requestParams.url.includes("loginInitialize")) {
-                    setApp({ initToken: data.data.token })
-                    appInfoStore.actionAppInfo(data.data.appInfo)
+                    // 存放初始token和app信息
+                    setApp({ initToken: data.data.token, appInfo: data.data.appInfo,payVersion:data.data.appInfo.iosPayment })
+                    // 登录
                     let user: any = await api.login()
+                    // 存放user信息到本地
                     Taro.setStorageSync("userInfo", user)
-                    let temp: any = await getRechargeTemplate()
-                    console.log("temp", temp)
-                    setApp({ appName: data?.data?.appInfo?.appName })
-                    appInfoStore.setData({ appInfo: data.data.appInfo, })
+                    // 获取充值模板
+                    await getRechargeTemplate()
+                    // 判断是否需要隐藏支付
+                    if(app.system === "ios"){
+                        let iosShowPay = app?.proVersion? app?.payVersion >= app?.proVersion : false
+                        console.log("是ios",iosShowPay)
+                        setApp({iosShowPay})
+                    }
+                    console.log("获取当前APP", app);  // 获取当前小程序版本号,
+                    // 设置已登录状态让页面刷新接口
+                    indexStore.setData({ isLogin: true })
                     // 检测待请求列表中是否存在请求,存在就执行请求
                     while (pendingRequests.length > 0) {
                         console.log("存在待请求")

+ 10 - 5
src/pages/book/BookArticle/index.tsx

@@ -11,6 +11,7 @@ import { BookStore } from '@src/store/book';
 import useApi from '@src/Hook/useApi';
 import { getReadLog, setReadLog } from '@src/utils/loginSto';
 import GlobalModal from '@src/components/bottomModal';
+import IosShowPay from '@src/components/pay/IosShowPay';
 
 interface Config {
     size: 'pre_15' | 'pre_17' | 'pre_19' | 'pre_21' | 'pre_23' | 'pre_25' | 'pre_27' | 'pre_29' | any;
@@ -32,12 +33,12 @@ interface BookArticleProps extends PageStateProps { }
 
 const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
     const [isLoad, setIsLoad] = useState(false)
-    const { bookStore, indexStore, appInfoStore, modalStore } = store
+    const { bookStore, indexStore, modalStore } = store
     const [showPay, setShowPay] = useState(false)//需要付费展示
     const { openBookData } = bookStore
     const [bookConfig, setBookConfig] = useState<Config>({ size: 'pre_21', off_on: true, bg: 'bg_b', lh: 'lh_72' });
     const [pup, setPup] = useState(false);
-    const { getBookContent, readingBook } = useApi(appInfoStore)
+    const { getBookContent, readingBook } = useApi()
     const [currentScrollId, setCurrentScrollId] = useState('');
     const newReadLogIdRef = useRef("");
     const readLogInterval = useRef<NodeJS.Timeout>()
@@ -70,7 +71,7 @@ const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
     // 上报阅读
     const onReport = () => {
         let scene = indexStore.scene
-        let { startReadBook } = useApi(appInfoStore)
+        let { startReadBook } = useApi()
         startReadBook({ bookId: bookStore.openBookData?.bookId, readCondition: scene })
     }
     // 页面卸载的操作
@@ -262,11 +263,15 @@ const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
                             </View> : null
                         })
                     }
+
                     {showPay && <View>
                         <View className='text-with-lines' >剩余内容需付费解锁</View>
-                        <View className='vip_btn' onClick={(e) => { payBtn(e, "vip") }}>开通会员,本书免费读</View>
-                        <View className='shubi_btn' onClick={(e) => { payBtn(e, "shubi") }}>购买本章</View>
+                        <IosShowPay>
+                            <View className='vip_btn' onClick={(e) => { payBtn(e, "vip") }}>开通会员,本书免费读</View>
+                            <View className='shubi_btn' onClick={(e) => { payBtn(e, "shubi") }}>购买本章</View>
+                        </IosShowPay>
                     </View>}
+
                 </View>
                 {/* 设置弹窗 */}
                 {pup && <BookConfigPuP {...bookConfig} off_on={off_on} setOff={setOff} setSize={setSize} setBg={setBg} setLh={setLh} />}

+ 1 - 2
src/pages/book/bookDetails/index.tsx

@@ -33,10 +33,9 @@ class BookDetails extends Component<Props> {
         //     fail: (err) => { log("err") }
         // });
         let params = Taro.getCurrentInstance()?.router?.params
-        let { bookStore, appInfoStore } = this.props.store
         // 获取书籍详情
         if (params?.bookId) {
-            let { getBookInfo } = useApi(appInfoStore)
+            let { getBookInfo } = useApi()
             log("分享进入")
             getBookInfo(params.bookId)
             log(params?.bookId)

+ 1 - 1
src/pages/bookrack/index.tsx

@@ -23,7 +23,7 @@ interface ContentData {
 
 const Index: React.FC<Props> = ({ store }) => {
     const { indexStore, modalStore } = store
-    const { bookrackList } = useApi(store.appInfoStore)
+    const { bookrackList } = useApi()
     const [readData, setReadData] = useState<ContentData>({
         current: 0,
         total: 0,

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

@@ -20,8 +20,8 @@ interface Props {
 }
 
 const Index = forwardRef((props: Props) => {
-    const { bookStore, appInfoStore, classifyStore, indexStore } = props.store
-    const { getBookPageList } = useApi(appInfoStore)
+    const { bookStore,  classifyStore, indexStore } = props.store
+    const { getBookPageList } = useApi()
     const [pageShow, setPageShow] = useState(false)//防止小程序切换页面组件不会被真实卸载,阻止不必要的操作
     const [isFixed, setIsFixed] = useState(false)
     // 获取分类列表

+ 9 - 7
src/pages/index/index.tsx

@@ -18,25 +18,26 @@ interface Props {
     store: Store;
 }
 const Index: React.FC<Props> = ({ store }) => {
-    const { appInfoStore, bookStore, indexStore } = store
-    const { indexComponents, getBookPageList } = useApi(appInfoStore)
+    const { bookStore, indexStore } = store
+    const { indexComponents, getBookPageList } = useApi()
     const [pageShow, setPageShow] = useState(false)//防止小程序切换页面组件不会被真实卸载,阻止不必要的操作
     // 首页配置信息
     const indexConfig = useMemo(() => {
         let obj = {}
-        let thatPage = appInfoStore?.appInfo?.appPageComponentList.find(item => item.pagePath === 'pages/index/index')
+        let thatPage = app?.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, bookStore.workDirection])
+    }, [indexComponents, pageShow, bookStore.workDirection,indexStore.isLogin])
     // 页面显示请求数据
     useEffect(() => {
         if (pageShow) {
+            console.log("页面显示请求数据")
             indexCompontent()
         }
-    }, [pageShow, appInfoStore.token, bookStore.workDirection, appInfoStore.appInfo]); // Dependency array, runs effect only once on mount and unmount
+    }, [pageShow, bookStore.workDirection, app.appInfo]); // Dependency array, runs effect only once on mount and unmount
     // 使用 useDidShow 代替 onShow
     useDidShow(() => {
         // 分享消息配置
@@ -51,6 +52,7 @@ const Index: React.FC<Props> = ({ store }) => {
     });
     // 处理首页展示的组件的请求
     const indexCompontent = () => {
+        console.log("indexConfig",indexConfig)
         // 小程序的组件配置
         Object.keys(indexConfig)?.forEach(key => {
             switch (key) {
@@ -99,10 +101,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?.[appInfoStore?.appInfo?.appCategory === 1 ? "longBookInfoAppVOS" : "shortBookInfoAppVOS"]?.[0]} /></View>
+            <View ><BookboxRowMiddle {...indexStore?.indexHotBooks?.[app?.appInfo?.appCategory === 1 ? "longBookInfoAppVOS" : "shortBookInfoAppVOS"]?.[0]} /></View>
             <View className='w row'>
                 {
-                    indexStore?.indexHotBooks?.[appInfoStore?.appInfo?.appCategory === 1 ? "longBookInfoAppVOS" : "shortBookInfoAppVOS"]?.map((item, index) => {
+                    indexStore?.indexHotBooks?.[app?.appInfo?.appCategory === 1 ? "longBookInfoAppVOS" : "shortBookInfoAppVOS"]?.map((item, index) => {
                         if (index > 0 && index < 5) {
                             return <View key={index}><BookboxColumnSmall {...item} /></View>
                         }

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

@@ -34,11 +34,11 @@ class AboutWe extends Component {
             <View className='aboutWe'>
                 <View className="content">
                     <Image src={""}  mode="widthFix" className="logo" style={{width: Taro.pxTransform(152)}}/>
-                    <Text className="logoName">{app.appName}</Text>
+                    <Text className="logoName">{app?.appInfo?.appName}</Text>
                     {
                         indexStore.openType === 1 ? <Text className="explain">致力于为用户提供精品阅读内容,精彩呈现</Text> :
                         <>
-                            <Text className="explain">{app.appName}是一个全正版的免费阅读平台</Text>
+                            <Text className="explain">{app?.appInfo?.appName}是一个全正版的免费阅读平台</Text>
                             <Text className="explain">致力于为用户提供更丰富更优质的免费阅读内</Text>
                         </>
                     }

+ 31 - 27
src/pages/my/index.tsx

@@ -5,6 +5,7 @@ import { observer, inject } from 'mobx-react'
 import './index.less'
 import { Store } from '@src/app'
 import ModalStore from '@src/store/modalStore'
+import IosShowPay from '@src/components/pay/IosShowPay'
 interface Props {
     store: Store;
 }
@@ -59,39 +60,42 @@ class My extends Component<Props> {
                             </View>
                         }
                     </View>
-                    {/* vip续费 */}
-                    <View className="bottom">
-                        <View>
-                            <View className="left">
-                                <Image lazy-load src={require('../../icon/VIP.png')} />
-                                <View className="txt">
-                                    <Text>会员尊享免费解锁权益</Text>
-                                    {
-                                        userInfoStore.isVip && <Text className="tfv">有效期至:{1111}</Text>
-                                    }
+                    {/* 付费功能 */}
+                    <IosShowPay>
+                        {/* vip续费 */}
+                        <View className="bottom">
+                            <View>
+                                <View className="left">
+                                    <Image lazy-load src={require('../../icon/VIP.png')} />
+                                    <View className="txt">
+                                        <Text>会员尊享免费解锁权益</Text>
+                                        {
+                                            userInfoStore.isVip && <Text className="tfv">有效期至:{1111}</Text>
+                                        }
+                                    </View>
                                 </View>
+                                <View className="right" onClick={() => { Taro.navigateTo({ url: '/pages/vipCore/index' }) }}>{userInfoStore.isVip ? '立即续费' : '立即开通'}</View>
                             </View>
-                            <View className="right" onClick={() => { Taro.navigateTo({ url: '/pages/vipCore/index' }) }}>{userInfoStore.isVip ? '立即续费' : '立即开通'}</View>
+                            <Image lazy-load src={require('../../icon/vipBack.png')} />
                         </View>
-                        <Image lazy-load src={require('../../icon/vipBack.png')} />
-                    </View>
-                    {/*我的账户  */}
-                    <View className='account_info'>
-                        <View className='account_info_title'>我的账户</View>
-                        <View className='account_info_content'>
-                            <View className='account_info_content_left'>
-                                <View className='account_info_content_text'>
-                                    <Text>12</Text>
-                                    <Text>书币</Text>
-                                </View>
-                                <View className='account_info_content_text' onClick={() => { }}>
-                                    <Text>300</Text>
-                                    <Text>赠币</Text>
+                        {/*我的账户  */}
+                        <View className='account_info'>
+                            <View className='account_info_title'>我的账户</View>
+                            <View className='account_info_content'>
+                                <View className='account_info_content_left'>
+                                    <View className='account_info_content_text'>
+                                        <Text>12</Text>
+                                        <Text>书币</Text>
+                                    </View>
+                                    <View className='account_info_content_text' onClick={() => { }}>
+                                        <Text>300</Text>
+                                        <Text>赠币</Text>
+                                    </View>
                                 </View>
+                                <View className='account_info_content_btn' onClick={() => { Taro.navigateTo({ url: '/pages/myAccount/index' }) }}>充值</View>
                             </View>
-                            <View className='account_info_content_btn' onClick={() => { ModalStore.showModal() }}>充值</View>
                         </View>
-                    </View>
+                    </IosShowPay>
                     {/* 底部功能入口 */}
                     <View className="list_bt" >
                         <Navigator className="item" url="/pages/my/contactService/index">

+ 4 - 0
src/pages/myAccount/index.config.ts

@@ -0,0 +1,4 @@
+export default {
+    navigationBarTitleText: '我的账户'
+}
+  

+ 18 - 0
src/pages/myAccount/index.less

@@ -0,0 +1,18 @@
+
+.myAccount{
+    padding: 30rpx;
+    box-sizing: border-box;
+    .title {
+        width: 144rpx;
+        height: 50rpx;
+        font-family: PingFang SC, PingFang SC;
+        font-weight: 400;
+        font-size: 36rpx;
+        color: #333333;
+        line-height: 42rpx;
+        text-align: left;
+        font-style: normal;
+        text-transform: none;
+        margin-bottom: 30rpx;
+    }
+}

+ 14 - 0
src/pages/myAccount/index.tsx

@@ -0,0 +1,14 @@
+import { View } from "@tarojs/components";
+import ShubiBox from "@src/components/pay/shubi";
+import "./index.less"
+
+function MyAccount() {
+    return <View className=".myAccount">
+        <View className=".title">选择套餐</View>
+        <ShubiBox data={
+            [100, 200, 300, 400, 500, 600]
+        } />
+    </View>
+}
+
+export default MyAccount

+ 1 - 1
src/pages/search/index.tsx

@@ -62,7 +62,7 @@ class Search extends Component {
         } catch (e) { }
     }
     componentDidMount(): void {
-        let api = useApi(this.props.store.appInfoStore)
+        let api = useApi()
         this.setState({ api })
     }
     /** 点击搜索历史 */

+ 27 - 39
src/pages/vipCore/index.tsx

@@ -5,25 +5,13 @@ import './index.less'
 // import { getProductInfo } from '../../api'
 // import { pay } from '../../ajax' 
 import Taro from '@tarojs/taro'
+import { Store } from '@src/app'
 type PageStateProps = {
-    store: {
-        indexStore: {
-            userInfo: userInfo,
-            SET_USERINFO: Function
-        }
-    }
+    store: Store
 }
 interface VipCore {
     props: PageStateProps;
 }
-
-type userInfo = {
-    user_name: string,
-    avatar_url: string,
-    is_auth: number,
-    is_vip: boolean
-}
-
 type state = {
     selectVip: number,
     productList: any[],
@@ -34,7 +22,6 @@ type state = {
 @inject('store')
 @observer
 class VipCore extends Component {
-    
     state: state = {
         selectVip: 0,
         productList: [],
@@ -74,12 +61,12 @@ class VipCore extends Component {
     purchase = () => {
         let { selectVip, productList, book_id, chapter_id } = this.state
         let product_id = productList[selectVip].product_id
-        let queryFor = {product_id, source: 1}
+        let queryFor = { product_id, source: 1 }
         book_id && (queryFor['book_id'] = book_id)
         chapter_id && (queryFor['chapter_id'] = chapter_id)
         // pay(queryFor).then(()=>{
         //     let { indexStore } = this.props.store
-        //     indexStore.SET_USERINFO()
+        //     SET_USERINFO()
         // }).catch(err => {
 
         // })
@@ -87,16 +74,16 @@ class VipCore extends Component {
 
     componentWillUnmount() {
         let { indexStore } = this.props.store
-        if (this.state.book_id !== 0) {
-            let pages = Taro.getCurrentPages(); //获取当前页面栈
-            if (pages.length > 1) {
-                let beforePage = pages[pages.length - 2]; //获取上一个页面实例对象
-                beforePage.setData({
-                    //返回参数 ps:这里我打印出beforePage只有一个setData能调用到
-                    'isVip': indexStore.userInfo?.is_vip
-                })
-            }
-        }
+        // if (this.state.book_id !== 0) {
+        //     let pages = Taro.getCurrentPages(); //获取当前页面栈
+        //     if (pages.length > 1) {
+        //         let beforePage = pages[pages.length - 2]; //获取上一个页面实例对象
+        //         beforePage.setData({
+        //             //返回参数 ps:这里我打印出beforePage只有一个setData能调用到
+        //             'isVip': userInfo?.is_vip
+        //         })
+        //     }
+        // }
     }
 
     showToast = (title: string, duration?: number, icon?: "none" | "success" | "loading" | undefined) => {
@@ -108,7 +95,8 @@ class VipCore extends Component {
     }
 
     render() {
-        let { indexStore } = this.props.store
+        let { userInfoStore } = this.props.store
+        let { userInfo } = userInfoStore
         return (
             <View className='VipCore'>
                 <View className="VipCoreTop">
@@ -116,11 +104,11 @@ class VipCore extends Component {
                         <View className="con">
                             <View className="top">
                                 <View className="left">
-                                    <Image mode="widthFix" lazy-load src={indexStore.userInfo?.avatar_url? indexStore.userInfo?.avatar_url : require('../../icon/avatar.jpg')}/>
+                                    <Image mode="widthFix" lazy-load src={require('../../icon/avatar.jpg')} />
                                 </View>
                                 <View className="right">
-                                    <Text className="ID">{indexStore.userInfo?.user_name || "三金金"}</Text>
-                                    <Text className="isVip">{indexStore.userInfo?.is_vip ? '已开通' : '未开通会员'}</Text>
+                                    <Text className="ID">{userInfo?.nickname || "三金金"}</Text>
+                                    <Text className="isVip">{userInfo?.vipExpireTime ? `有效期至:${userInfo?.vipExpireTime}` : '未开通会员'}</Text>
                                 </View>
                             </View>
                             <View className="bottom">
@@ -134,7 +122,7 @@ class VipCore extends Component {
 
                     <View className="vipSetMeal">
                         {
-                            this.state.productList?.map((item: any, index: number) => (<View key={item?.product_id || index} className={index === this.state.selectVip ? 'select' : ''} onClick={()=>{this.selectHanle(index)}}>
+                            this.state.productList?.map((item: any, index: number) => (<View key={item?.product_id || index} className={index === this.state.selectVip ? 'select' : ''} onClick={() => { this.selectHanle(index) }}>
                                 <View className="top">
                                     <View className="name">{item?.product_name}</View>
                                     <View className="price"><Text>¥</Text> {item?.product_amount}</View>
@@ -145,7 +133,7 @@ class VipCore extends Component {
                                 }
                                 {
                                     item?.is_default === 1 && <View className='cz'>
-                                        <Image lazy-load src={require('../../icon/spark.png')}/>
+                                        <Image lazy-load src={require('../../icon/spark.png')} />
                                         <Text>超值</Text>
                                     </View>
                                 }
@@ -154,12 +142,12 @@ class VipCore extends Component {
                     </View>
                 </View>
                 <View className="VipCoreBottom">
-                {
-                    this.state.productList.length > 0 && <View className="vipBt" onClick={this.purchase}>
-                        <Image lazy-load src={require('../../icon/weChat.png')} />
-                        {indexStore.userInfo?.is_vip ? '立即续费' : '立即开通'}
-                    </View>
-                }
+                    {
+                        this.state.productList.length > 0 && <View className="vipBt" onClick={this.purchase}>
+                            <Image lazy-load src={require('../../icon/weChat.png')} />
+                            {userInfo?.vipExpireTime ? '立即续费' : '立即开通'}
+                        </View>
+                    }
                 </View>
             </View>
         )

+ 0 - 2
src/server/dy/login.ts

@@ -1,6 +1,5 @@
 import { setApp } from "@src/config";
 import { ResData } from "@src/interceptor"
-import appInfoStore from "@src/store/appInfo";
 import Taro from "@tarojs/taro"
 
 /**
@@ -41,7 +40,6 @@ export function dylogin() {
             });
             if (response.code === 200) {
               setApp({token:response.data.token})//存放token
-              appInfoStore.actionToken(response.data.token )
               resolve(response.data)
             }
           } else {

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

@@ -2,7 +2,6 @@ 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)
  * */
@@ -42,7 +41,6 @@ export function wxlogin() {
             if (response.code === 200) {
               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 {

+ 93 - 93
src/store/appInfo.tsx

@@ -1,96 +1,96 @@
-import { observable } from 'mobx'
+// import { observable } from 'mobx'
 
 
-type ConfigParamList = {}
-export interface AppInfo {
-    appCategory: 1 | 2,//1长篇 2短篇
-    appName: string,//小程序名称
-    appVersion: string,//小程序版本
-    configParamList: ConfigParamList[],//小程序配置
-    distributorId: 1,//分销商ID
-    enabled: true,//启用状态
-    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 {
-    componentType: "banners" | "hot_books" | "hot_category",
-    id: number
-}
-export interface AppInfoStore {
-    /**app初始化信息*/
-    appInfo?: AppInfo,
-    /**登录后的token*/
-    token?: string,//token
-    /**进入的场景*/
-    scene?: number,
-    /**分享值*/
-    shareSources?: any,
-    /**设置app初始化信息*/
-    actionAppInfo: (appInfo: AppInfo) => void
-    /**设置登录后的token*/
-    actionToken: (token: string) => void
-    setData: (data: { [key: string]: any }) => void,
-}
-/**
- * APP初始化信息
- * */
-const appInfoStore: AppInfoStore = observable({
-    appInfo: undefined,
-    actionAppInfo(appInfo: AppInfo) {
-        if (appInfo) {
-            this.appInfo = appInfo
-        }
-    },
-    actionToken(token: string) {
-        console.log("设置token", token)
-        this.token = token
-    },
-    setData(data: { [key: string]: any }) {
-        if (data) {
-            Object.keys(data).forEach(key => {
-                this[key] = data[key]
-            })
-        }
-    },
-})
+// type ConfigParamList = {}
+// export interface AppInfo {
+//     appCategory: 1 | 2,//1长篇 2短篇
+//     appName: string,//小程序名称
+//     appVersion: string,//小程序版本
+//     configParamList: ConfigParamList[],//小程序配置
+//     distributorId: 1,//分销商ID
+//     enabled: true,//启用状态
+//     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 {
+//     componentType: "banners" | "hot_books" | "hot_category",
+//     id: number
+// }
+// export interface AppInfoStore {
+//     /**app初始化信息*/
+//     appInfo?: AppInfo,
+//     /**登录后的token*/
+//     token?: string,//token
+//     /**进入的场景*/
+//     scene?: number,
+//     /**分享值*/
+//     shareSources?: any,
+//     /**设置app初始化信息*/
+//     actionAppInfo: (appInfo: AppInfo) => void
+//     /**设置登录后的token*/
+//     actionToken: (token: string) => void
+//     setData: (data: { [key: string]: any }) => void,
+// }
+// /**
+//  * APP初始化信息
+//  * */
+// const appInfoStore: AppInfoStore = observable({
+//     appInfo: undefined,
+//     actionAppInfo(appInfo: AppInfo) {
+//         if (appInfo) {
+//             this.appInfo = appInfo
+//         }
+//     },
+//     actionToken(token: string) {
+//         console.log("设置token", token)
+//         this.token = token
+//     },
+//     setData(data: { [key: string]: any }) {
+//         if (data) {
+//             Object.keys(data).forEach(key => {
+//                 this[key] = data[key]
+//             })
+//         }
+//     },
+// })
 
-export default appInfoStore
+// export default appInfoStore

+ 2 - 0
src/store/index.ts

@@ -7,6 +7,7 @@ export interface IndexStore {
     navBarTop: number,//状态栏高度
     navHeight: number,//导航栏高度
     query: any,//本次进入小程序参数
+    isLogin:boolean,//是否登录用于页面刷新获取数据
     indexBanners: {
         "name": string,//名称
         "workDirection": number,//频道
@@ -54,6 +55,7 @@ const Index:IndexStore = observable({
         workDirection: 0,//频道
     },//首页热门分类
     indexCategoryId: 0,
+    isLogin:false,
     setData(data: { [key: string]: any }) {
         if (data) {
             Object.keys(data).forEach(key => {

+ 2 - 1
src/store/userInfo.tsx

@@ -5,8 +5,9 @@ export interface UserInfoStore {
     isVip: boolean,//是否是vip
     userInfo: {
         openId:string,
-        nickName:string,
+        nickname:string,
         avatarUrl:string
+        vipExpireTime:string
     } | null,
     setData: (data: { [key: string]: any }) => void,
 }

+ 5 - 0
src/utils/pay.ts

@@ -0,0 +1,5 @@
+
+export function isPay(data:any):boolean{
+    //判断
+    return true
+}