shenwu 6 달 전
부모
커밋
b42d60e239
11개의 변경된 파일139개의 추가작업 그리고 26개의 파일을 삭제
  1. 0 11
      src/Hook/usePay.ts
  2. 0 1
      src/app.config.ts
  3. 0 1
      src/app.tsx
  4. 5 5
      src/components/TopNavBar/index.tsx
  5. 1 0
      src/interceptor.ts
  6. 22 2
      src/pages/bookrack/index.tsx
  7. 22 2
      src/pages/classify/index.tsx
  8. 21 1
      src/pages/index/index.tsx
  9. 22 2
      src/pages/my/index.tsx
  10. 25 0
      src/server/index/index.ts
  11. 21 1
      src/utils/index.tsx

+ 0 - 11
src/Hook/usePay.ts

@@ -1,11 +0,0 @@
-// 支付
-function usePay() {
-    const pay = () => {
-        console.log("支付数据",app.payData)
-    }
-    return {
-        pay
-    }
-
-}
-export default usePay

+ 0 - 1
src/app.config.ts

@@ -14,7 +14,6 @@ export default {
     'pages/search/index',//搜索
     'pages/indexMore/index', // 更多
   ],
-
   window: {
     backgroundTextStyle: 'dark',
     navigationBarBackgroundColor: '#fff',

+ 0 - 1
src/app.tsx

@@ -75,7 +75,6 @@ class App extends Component {
   componentDidHide() { }
 
   componentDidCatchError() { }
-
   render() {
     console.log("store.userInfoStore.userInfo", store.userInfoStore.userInfo)
     return <Provider store={store}>

+ 5 - 5
src/components/TopNavBar/index.tsx

@@ -7,6 +7,7 @@ import searchPng from '../../icon/search.png'
 import { observer, inject } from 'mobx-react'
 import { BookStore } from '@src/store/book';
 import indexStore from '@src/store/index';
+import { share } from '@src/utils';
 /**顶部自定义导航
  * 
  */
@@ -71,10 +72,10 @@ function CustomNavbar(WrappedComponent, props: Props) {
         //回上级
         gotoBack = () => {
             let pages = Taro.getCurrentPages(); //获取当前页面栈
-            if(pages?.length > 1 ){
+            if (pages?.length > 1) {
                 Taro.navigateBack()
-            }else{
-                this.gotoHome() 
+            } else {
+                this.gotoHome()
             }
         }
         //回主页
@@ -101,13 +102,12 @@ function CustomNavbar(WrappedComponent, props: Props) {
             }
 
         }
-
         render() {
             const { extraProp, ...passThroughProps } = this.props
             let { navBar, capsuleWidth } = this.state
             const { indexStore: { navBarTop }, bookStore } = this.props.store
             let stateIndex = bookStore.workDirection
-            return <View style={{ height: '100vh'}}>
+            return <View style={{ height: '100vh' }}>
                 <View className='navbarWrap' style={{ paddingTop: navBarTop + 5, height: navBar, backgroundColor: isReloadBook ? bookStore.bookConfig?.off_on ? "#FFF" : "#363738" : "#FFF" }}>
                     <View className='content'>
                         {

+ 1 - 0
src/interceptor.ts

@@ -113,6 +113,7 @@ const responseInterceptor = (chain) => {
                     const newRequestParams = chain.requestParams;
                     return Taro.request(newRequestParams).then(newResponse => newResponse.data);
                 }
+                break;
             default:
                 log("未知错误", data)
                 Taro.showToast({

+ 22 - 2
src/pages/bookrack/index.tsx

@@ -1,6 +1,6 @@
 import { useEffect, useState } from 'react'
 import { View } from '@tarojs/components'
-import Taro, { useDidHide, useDidShow } from '@tarojs/taro'
+import Taro, { useDidHide, useDidShow, useShareAppMessage } from '@tarojs/taro'
 import { observer, inject } from 'mobx-react'
 //==========components组件引用========================
 import TopNavBar from '@src/components/TopNavBar/index'
@@ -9,6 +9,7 @@ import BookboxRowSmall from '@src/components/PupPetry/BookBox/BookboxRowSmall'
 import { Store } from '@src/app'
 import useApi from '@src/Hook/useApi'
 import SwipeAction from '@src/components/SwipeAction'
+import { share } from '@src/utils'
 
 
 interface Props {
@@ -84,6 +85,25 @@ const Index: React.FC<Props> = ({ store }) => {
             }
         })
     }
+    // 分享
+    useShareAppMessage(async () => {
+        // 获取当前页面栈
+        const pages = Taro.getCurrentPages()
+        // 获取栈顶的页面,即当前页面
+        const currentPage = pages[pages.length - 1]
+        // 获取页面的路径和参数
+        const route = currentPage.route // 页面路径
+        if (route) {
+            let shareInfo = await share({ pagePath: route })
+            let { sharePicUrl, shareTitles, pageName, pagePath } = shareInfo
+            return {
+                title: shareTitles || app.appInfo?.appName + '-' + pageName,
+                path: pagePath || undefined,
+                imageUrl: sharePicUrl || undefined
+            }
+        }
+        return {}
+    })
     return <View>
         <ScrollViewHoc
             load={load}
@@ -106,4 +126,4 @@ const Index: React.FC<Props> = ({ store }) => {
 };
 export default TopNavBar((inject('store')(observer(Index))), {
     title: '阅读记录'
-});
+})

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

@@ -1,5 +1,5 @@
 import { forwardRef, useEffect, useState } from 'react'
-import Taro from '@tarojs/taro'
+import Taro, { useShareAppMessage } from '@tarojs/taro'
 import { useDidHide, useDidShow } from '@tarojs/taro'
 import { observer, inject } from 'mobx-react'
 import { View } from '@tarojs/components'
@@ -13,6 +13,7 @@ import Empty from '@src/components/Empty'
 import { Store } from '@src/app'
 import useApi from '@src/Hook/useApi'
 import { getBookCategoryList } from '@src/server/classify'
+import { share } from '@src/utils'
 
 
 interface Props {
@@ -20,7 +21,7 @@ interface Props {
 }
 
 const Index = forwardRef((props: Props) => {
-    const { bookStore,  classifyStore, indexStore } = props.store
+    const { bookStore, classifyStore, indexStore } = props.store
     const { getBookPageList } = useApi()
     const [pageShow, setPageShow] = useState(false)//防止小程序切换页面组件不会被真实卸载,阻止不必要的操作
     const [isFixed, setIsFixed] = useState(false)
@@ -81,6 +82,25 @@ const Index = forwardRef((props: Props) => {
     const getList = async (params) => {
         return getBookPageList(params)
     }
+    // 分享
+    useShareAppMessage(async () => {
+        // 获取当前页面栈
+        const pages = Taro.getCurrentPages()
+        // 获取栈顶的页面,即当前页面
+        const currentPage = pages[pages.length - 1]
+        // 获取页面的路径和参数
+        const route = currentPage.route // 页面路径
+        if (route) {
+            let shareInfo = await share({ pagePath: route })
+            let { sharePicUrl, shareTitles, pageName, pagePath } = shareInfo
+            return {
+                title: shareTitles || app.appInfo?.appName + '-' + pageName,
+                path: pagePath || undefined,
+                imageUrl: sharePicUrl || undefined
+            }
+        }
+        return {}
+    })
     return (
 
         <View className='index'>

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

@@ -1,6 +1,6 @@
 import React, { useEffect, useMemo, useState } from 'react';
 import { observer, inject } from 'mobx-react';
-import { useDidHide, useDidShow } from '@tarojs/taro';
+import { useDidHide, useDidShow, useShareAppMessage } from '@tarojs/taro';
 //==========components组件引用========================
 import TopNavBar1 from '@src/components/TopNavBar/index1';
 import ScrollViewHoc from '@src/components/ScrollView';
@@ -14,6 +14,7 @@ import BookHotTabs from '@src/components/PupPetry/BookHotTabs';
 import BookboxColumnSmall from '@src/components/PupPetry/BookBox/BookboxColumnSmall';
 import BookboxRowMiddle from '@src/components/PupPetry/BookBox/BookboxRowMiddle';
 import BookboxColumnBig from '@src/components/PupPetry/BookBox/BookboxColumnBig';
+import { share } from '@src/utils';
 
 
 
@@ -163,6 +164,25 @@ const Index: React.FC<Props> = ({ store }) => {
             })
         }
     }
+    // 分享
+    useShareAppMessage(async () => {
+        // 获取当前页面栈
+        const pages = Taro.getCurrentPages()
+        // 获取栈顶的页面,即当前页面
+        const currentPage = pages[pages.length - 1]
+        // 获取页面的路径和参数
+        const route = currentPage.route // 页面路径
+        if (route) {
+            let shareInfo = await share({ pagePath: route })
+            let { sharePicUrl, shareTitles, pageName, pagePath } = shareInfo
+            return {
+                title: shareTitles || app.appInfo?.appName + '-' + pageName,
+                path: pagePath || undefined,
+                imageUrl: sharePicUrl || undefined
+            }
+        }
+        return {}
+    })
     return <ScrollViewHoc load={load} filterClassName='.searchTs' navHeight={indexStore.navHeight}>
         <TopNavBar1 {...{
             tab: true,

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

@@ -1,5 +1,5 @@
-import {  useState } from 'react'
-import Taro, { useDidHide } from '@tarojs/taro'
+import { useState } from 'react'
+import Taro, { useDidHide, useShareAppMessage } from '@tarojs/taro'
 import { View, Text, Image, Navigator } from '@tarojs/components'
 import { observer, inject } from 'mobx-react'
 import './index.less'
@@ -7,6 +7,7 @@ import { Store } from '@src/app'
 import ModalStore from '@src/store/modalStore'
 import IosShowPay from '@src/components/pay/IosShowPay'
 import GlobalModal from '@src/components/bottomModal'
+import { share } from '@src/utils'
 interface Props {
     store: Store;
 }
@@ -25,6 +26,25 @@ function My(props: Props) {
     useDidHide(() => {
         ModalStore.hideModal()
     });
+    // 分享
+    useShareAppMessage(async () => {
+        // 获取当前页面栈
+        const pages = Taro.getCurrentPages()
+        // 获取栈顶的页面,即当前页面
+        const currentPage = pages[pages.length - 1]
+        // 获取页面的路径和参数
+        const route = currentPage.route // 页面路径
+        if (route) {
+            let shareInfo = await share({ pagePath: route })
+            let { sharePicUrl, shareTitles, pageName, pagePath } = shareInfo
+            return {
+                title: shareTitles || app.appInfo?.appName + '-' + pageName,
+                path: pagePath || undefined,
+                imageUrl: sharePicUrl || undefined
+            }
+        }
+        return {}
+    })
     return <View className='my'>
         <View className="userInfo">
             <View className="userInfo_box">

+ 25 - 0
src/server/index/index.ts

@@ -293,3 +293,28 @@ export function enumDictList() {
         }
     })
 }
+
+/**
+ * 分享信息获取
+ * @param path 路径
+*/
+export function getShareInfo(pagePath:string) {
+    return new Promise(async (resolve, reject) => {
+        try {
+            // 初始化
+            Taro.request({
+                url: '/app/appPage/getShareInfo',
+                method: 'GET',
+                data:{pagePath},
+                success: (res) => {
+                    resolve(res)
+                },
+                fail: (err) => {
+                    reject(err);
+                }
+            })
+        } catch (error) {
+            reject(error);
+        }
+    })
+}

+ 21 - 1
src/utils/index.tsx

@@ -1,4 +1,24 @@
+import { getShareInfo } from "../server/index/index"
+/**
+ * 枚举处理
+ * */
 export const getEnum = (enumName: string) => {
     let arr = app?.enumDictList?.[enumName]?.values
     return arr?.map(({ value, description }: any) => ({ value, key: value, text: description }))
-}
+}
+
+
+
+interface ShareProps {
+    pagePath: string,//分享路径
+}
+/**
+ * 分享
+ * @param props
+ * @param props.pagePath 分享路径
+ * */
+export async function share(props: ShareProps) {
+    let { pagePath } = props
+    let shareInfo: any = await getShareInfo(pagePath)
+    return shareInfo?.data?.data
+}