Commit 68ac68b2 authored by huanglu's avatar huanglu

feat: 在线作业

parent 0093a090
module.exports = { module.exports = {
root: true, root: true,
extends: '@react-native-community', extends: '@react-native-community',
rules: {
'react-hooks/exhaustive-deps': 0,
'react-native/no-inline-styles': 0,
'prettier/prettier': 0,
},
}; };
module.exports = { module.exports = {
bracketSpacing: false, bracketSpacing: true,
jsxBracketSameLine: true, jsxBracketSameLine: true,
singleQuote: true, singleQuote: true,
trailingComma: 'all', trailingComma: 'all'
}; };
...@@ -2,15 +2,16 @@ module.exports = { ...@@ -2,15 +2,16 @@ module.exports = {
presets: ['module:metro-react-native-babel-preset'], presets: ['module:metro-react-native-babel-preset'],
plugins: [ plugins: [
[ [
"babel-plugin-root-import", 'babel-plugin-root-import',
{ {
"paths": [ paths: [
{ {
"rootPathSuffix": "./src/", rootPathSuffix: './src/',
"rootPathPrefix": "@/" rootPathPrefix: '@/',
} },
] ],
} },
] ],
] ['import', { libraryName: '@ant-design/react-native' }], // 与 Web 平台的区别是不需要设置 style
],
}; };
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
RCT_EXPORT_MODULE(); RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(openWorkPicker) { RCT_EXPORT_METHOD(openWorkPicker) {
[self showPicker]; // [self showPicker];
} }
...@@ -52,12 +52,9 @@ RCT_EXPORT_METHOD(showWorkResult:(NSString *)imageUrl ...@@ -52,12 +52,9 @@ RCT_EXPORT_METHOD(showWorkResult:(NSString *)imageUrl
} }
- (void) showPicker { - (void) showPicker:(NSString *)imageUrl {
self.picker = [[GeekCameraVC alloc] init]; self.picker = [[GeekCameraVC alloc] init];
self.picker.modalPresentationStyle = UIModalPresentationFullScreen; self.picker.modalPresentationStyle = UIModalPresentationFullScreen;
// UIImagePickerController *picker = [[UIImagePickerController alloc] init];
// picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
// picker.delegate = self;
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:self.picker animated:YES completion:nil]; [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:self.picker animated:YES completion:nil];
self.picker.imageBlock = ^(UIImage * _Nonnull image) { self.picker.imageBlock = ^(UIImage * _Nonnull image) {
NSString *imgPath = [GeekUtil saveImageTosandBox:image]; NSString *imgPath = [GeekUtil saveImageTosandBox:image];
......
...@@ -38,6 +38,7 @@ target 'GeekTeacherWork' do ...@@ -38,6 +38,7 @@ target 'GeekTeacherWork' do
pod "Masonry" pod "Masonry"
pod "SVProgressHUD" pod "SVProgressHUD"
pod "LCActionSheet" pod "LCActionSheet"
pod 'SDWebImage'
target 'GeekTeacherWorkTests' do target 'GeekTeacherWorkTests' do
inherit! :search_paths inherit! :search_paths
......
...@@ -202,12 +202,14 @@ PODS: ...@@ -202,12 +202,14 @@ PODS:
- React-cxxreact (= 0.61.5) - React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5) - React-jsi (= 0.61.5)
- React-jsinspector (0.61.5) - React-jsinspector (0.61.5)
- react-native-safe-area-context (3.1.8): - react-native-image-picker (2.3.4):
- React-Core
- react-native-safe-area-context (3.1.9):
- React-Core - React-Core
- react-native-version-number (0.3.6):
- React
- react-native-viewpager (3.3.1): - react-native-viewpager (3.3.1):
- React - React
- react-native-webview (10.10.2):
- React-Core
- React-RCTActionSheet (0.61.5): - React-RCTActionSheet (0.61.5):
- React-Core/RCTActionSheetHeaders (= 0.61.5) - React-Core/RCTActionSheetHeaders (= 0.61.5)
- React-RCTAnimation (0.61.5): - React-RCTAnimation (0.61.5):
...@@ -247,20 +249,22 @@ PODS: ...@@ -247,20 +249,22 @@ PODS:
- React - React
- rn-fetch-blob (0.12.0): - rn-fetch-blob (0.12.0):
- React-Core - React-Core
- RNCAsyncStorage (1.12.0): - RNCAsyncStorage (1.12.1):
- React - React-Core
- RNCMaskedView (0.1.10): - RNCMaskedView (0.1.10):
- React - React
- RNFastImage (8.3.2): - RNDeviceInfo (7.0.2):
- React - React-Core
- RNFastImage (8.3.4):
- React-Core
- SDWebImage (~> 5.8) - SDWebImage (~> 5.8)
- SDWebImageWebPCoder (~> 0.6.1) - SDWebImageWebPCoder (~> 0.6.1)
- RNGestureHandler (1.8.0): - RNGestureHandler (1.8.0):
- React - React
- RNReanimated (1.13.1): - RNReanimated (1.13.1):
- React - React
- RNScreens (2.11.0): - RNScreens (2.14.0):
- React - React-Core
- SDWebImage (5.9.0): - SDWebImage (5.9.0):
- SDWebImage/Core (= 5.9.0) - SDWebImage/Core (= 5.9.0)
- SDWebImage/Core (5.9.0) - SDWebImage/Core (5.9.0)
...@@ -292,9 +296,10 @@ DEPENDENCIES: ...@@ -292,9 +296,10 @@ DEPENDENCIES:
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- react-native-version-number (from `../node_modules/react-native-version-number`)
- "react-native-viewpager (from `../node_modules/@react-native-community/viewpager`)" - "react-native-viewpager (from `../node_modules/@react-native-community/viewpager`)"
- react-native-webview (from `../node_modules/react-native-webview`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
- React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
- React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`)
...@@ -310,10 +315,12 @@ DEPENDENCIES: ...@@ -310,10 +315,12 @@ DEPENDENCIES:
- rn-fetch-blob (from `../node_modules/rn-fetch-blob`) - rn-fetch-blob (from `../node_modules/rn-fetch-blob`)
- "RNCAsyncStorage (from `../node_modules/@react-native-community/async-storage`)" - "RNCAsyncStorage (from `../node_modules/@react-native-community/async-storage`)"
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)" - "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
- RNDeviceInfo (from `../node_modules/react-native-device-info`)
- RNFastImage (from `../node_modules/react-native-fast-image`) - RNFastImage (from `../node_modules/react-native-fast-image`)
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`) - RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNReanimated (from `../node_modules/react-native-reanimated`) - RNReanimated (from `../node_modules/react-native-reanimated`)
- RNScreens (from `../node_modules/react-native-screens`) - RNScreens (from `../node_modules/react-native-screens`)
- SDWebImage
- SVProgressHUD - SVProgressHUD
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`) - Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
- YYModel - YYModel
...@@ -363,12 +370,14 @@ EXTERNAL SOURCES: ...@@ -363,12 +370,14 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsiexecutor" :path: "../node_modules/react-native/ReactCommon/jsiexecutor"
React-jsinspector: React-jsinspector:
:path: "../node_modules/react-native/ReactCommon/jsinspector" :path: "../node_modules/react-native/ReactCommon/jsinspector"
react-native-image-picker:
:path: "../node_modules/react-native-image-picker"
react-native-safe-area-context: react-native-safe-area-context:
:path: "../node_modules/react-native-safe-area-context" :path: "../node_modules/react-native-safe-area-context"
react-native-version-number:
:path: "../node_modules/react-native-version-number"
react-native-viewpager: react-native-viewpager:
:path: "../node_modules/@react-native-community/viewpager" :path: "../node_modules/@react-native-community/viewpager"
react-native-webview:
:path: "../node_modules/react-native-webview"
React-RCTActionSheet: React-RCTActionSheet:
:path: "../node_modules/react-native/Libraries/ActionSheetIOS" :path: "../node_modules/react-native/Libraries/ActionSheetIOS"
React-RCTAnimation: React-RCTAnimation:
...@@ -397,6 +406,8 @@ EXTERNAL SOURCES: ...@@ -397,6 +406,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@react-native-community/async-storage" :path: "../node_modules/@react-native-community/async-storage"
RNCMaskedView: RNCMaskedView:
:path: "../node_modules/@react-native-community/masked-view" :path: "../node_modules/@react-native-community/masked-view"
RNDeviceInfo:
:path: "../node_modules/react-native-device-info"
RNFastImage: RNFastImage:
:path: "../node_modules/react-native-fast-image" :path: "../node_modules/react-native-fast-image"
RNGestureHandler: RNGestureHandler:
...@@ -430,9 +441,10 @@ SPEC CHECKSUMS: ...@@ -430,9 +441,10 @@ SPEC CHECKSUMS:
React-jsi: cb2cd74d7ccf4cffb071a46833613edc79cdf8f7 React-jsi: cb2cd74d7ccf4cffb071a46833613edc79cdf8f7
React-jsiexecutor: d5525f9ed5f782fdbacb64b9b01a43a9323d2386 React-jsiexecutor: d5525f9ed5f782fdbacb64b9b01a43a9323d2386
React-jsinspector: fa0ecc501688c3c4c34f28834a76302233e29dc0 React-jsinspector: fa0ecc501688c3c4c34f28834a76302233e29dc0
react-native-safe-area-context: 79fea126c6830c85f65947c223a5e3058a666937 react-native-image-picker: c6d75c4ab2cf46f9289f341242b219cb3c1180d3
react-native-version-number: b415bbec6a13f2df62bf978e85bc0d699462f37f react-native-safe-area-context: b6e0e284002381d2ff29fa4fff42b4d8282e3c94
react-native-viewpager: f730c1d175a2c1ae789464855d4a2c14247d3109 react-native-viewpager: f730c1d175a2c1ae789464855d4a2c14247d3109
react-native-webview: 0aa2cde4ee7e3e1c5fffdf64dbce9c709aa18155
React-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76 React-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76
React-RCTAnimation: 791a87558389c80908ed06cc5dfc5e7920dfa360 React-RCTAnimation: 791a87558389c80908ed06cc5dfc5e7920dfa360
React-RCTBlob: d89293cc0236d9cb0933d85e430b0bbe81ad1d72 React-RCTBlob: d89293cc0236d9cb0933d85e430b0bbe81ad1d72
...@@ -445,12 +457,13 @@ SPEC CHECKSUMS: ...@@ -445,12 +457,13 @@ SPEC CHECKSUMS:
ReactCommon: 198c7c8d3591f975e5431bec1b0b3b581aa1c5dd ReactCommon: 198c7c8d3591f975e5431bec1b0b3b581aa1c5dd
ReactNativeART: 78edc68dd4a1e675338cd0cd113319cf3a65f2ab ReactNativeART: 78edc68dd4a1e675338cd0cd113319cf3a65f2ab
rn-fetch-blob: f065bb7ab7fb48dd002629f8bdcb0336602d3cba rn-fetch-blob: f065bb7ab7fb48dd002629f8bdcb0336602d3cba
RNCAsyncStorage: 2a692bcb9b69b76a2f1a95f33db057129700af64 RNCAsyncStorage: b03032fdbdb725bea0bd9e5ec5a7272865ae7398
RNCMaskedView: 5a8ec07677aa885546a0d98da336457e2bea557f RNCMaskedView: 5a8ec07677aa885546a0d98da336457e2bea557f
RNFastImage: e19ba191922e7dab9d932a4d59d62d76660aa222 RNDeviceInfo: e1d82a27d0c1ea6278e3b141784dc38e51fc90f4
RNFastImage: d4870d58f5936111c56218dbd7fcfc18e65b58ff
RNGestureHandler: 7a5833d0f788dbd107fbb913e09aa0c1ff333c39 RNGestureHandler: 7a5833d0f788dbd107fbb913e09aa0c1ff333c39
RNReanimated: dd8c286ab5dd4ba36d3a7fef8bff7e08711b5476 RNReanimated: dd8c286ab5dd4ba36d3a7fef8bff7e08711b5476
RNScreens: 0e91da98ab26d5d04c7b59a9b6bd694124caf88c RNScreens: 2e278a90eb15092ed261d4f2271e3fc9b60d08d4
SDWebImage: 62ae4a18473520c67b79e9724c31a63599cc9423 SDWebImage: 62ae4a18473520c67b79e9724c31a63599cc9423
SDWebImageWebPCoder: d0dac55073088d24b2ac1b191a71a8f8d0adac21 SDWebImageWebPCoder: d0dac55073088d24b2ac1b191a71a8f8d0adac21
SSZipArchive: 62d4947b08730e4cda640473b0066d209ff033c9 SSZipArchive: 62d4947b08730e4cda640473b0066d209ff033c9
...@@ -458,6 +471,6 @@ SPEC CHECKSUMS: ...@@ -458,6 +471,6 @@ SPEC CHECKSUMS:
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b
YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30 YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30
PODFILE CHECKSUM: 8b8a582a803563a2f2d3eaff4db0254084a15277 PODFILE CHECKSUM: aee9cbf12b10829e7ccb4373a4dd99bc0d5a3710
COCOAPODS: 1.9.1 COCOAPODS: 1.9.1
...@@ -16,31 +16,29 @@ ...@@ -16,31 +16,29 @@
"build-android": "cd android && ./gradlew assembleRelease" "build-android": "cd android && ./gradlew assembleRelease"
}, },
"dependencies": { "dependencies": {
"@geek/request": "^1.0.0", "@ant-design/react-native": "^4.0.5",
"@react-native-community/art": "^1.1.2", "@react-native-community/art": "^1.1.2",
"@react-native-community/async-storage": "^1.12.0", "@react-native-community/async-storage": "^1.12.1",
"@react-native-community/masked-view": "^0.1.10", "@react-native-community/masked-view": "^0.1.10",
"@react-native-community/viewpager": "^3.3.0", "@react-native-community/viewpager": "^3.3.0",
"geekbase": "https://dev.jiuaoedu.com/sunzheng/geekbase.git#v2.1.4", "geekbase": "^2.0.2",
"react": "16.9.0", "react": "16.9.0",
"react-native": "0.61.5", "react-native": "0.61.5",
"react-native-code-push": "https://dev.jiuaoedu.com/sunzheng/react-native-code-push.git", "react-native-code-push": "https://dev.jiuaoedu.com/sunzheng/react-native-code-push.git",
"react-native-extra-dimensions-android": "^1.2.5", "react-native-device-info": "^7.0.2",
"react-native-fast-image": "^8.3.2", "react-native-fast-image": "^8.3.4",
"react-native-gesture-handler": "^1.8.0", "react-native-gesture-handler": "^1.8.0",
"react-native-modal": "^11.5.6", "react-native-image-picker": "^2.3.4",
"react-native-reanimated": "^1.13.0", "react-native-reanimated": "^1.13.0",
"react-native-refresh-list-view": "^1.0.12", "react-native-refresh-list-view": "^1.0.12",
"react-native-root-siblings": "^4.0.6",
"react-native-safe-area-context": "^3.1.7", "react-native-safe-area-context": "^3.1.7",
"react-native-screens": "^2.10.1", "react-native-screens": "^2.10.1",
"react-native-scrollable-tab-view": "^1.0.0", "react-native-tbswebview": "https://dev.jiuaoedu.com/sunzheng/react-native-tbswebview.git#v1.1.0",
"react-native-version-number": "^0.3.6", "react-native-webview": "^10.10.2",
"react-navigation": "^4.4.0", "react-navigation": "^4.4.0",
"react-navigation-stack": "^2.8.2", "react-navigation-stack": "^2.8.2",
"react-navigation-tabs": "^2.9.0", "react-navigation-tabs": "^2.9.0",
"react-redux": "^7.2.1", "rn-fetch-blob": "^0.12.0"
"rn-fetch-blob": "https://dev.jiuaoedu.com/sunzheng/rn-fetch-blob.git"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.11.6", "@babel/core": "^7.11.6",
...@@ -51,6 +49,7 @@ ...@@ -51,6 +49,7 @@
"@types/react-native": "^0.63.18", "@types/react-native": "^0.63.18",
"@types/react-test-renderer": "^16.9.3", "@types/react-test-renderer": "^16.9.3",
"babel-jest": "^26.3.0", "babel-jest": "^26.3.0",
"babel-plugin-import": "^1.13.1",
"babel-plugin-root-import": "^6.5.0", "babel-plugin-root-import": "^6.5.0",
"eslint": "^7.9.0", "eslint": "^7.9.0",
"metro-react-native-babel-preset": "^0.63.0", "metro-react-native-babel-preset": "^0.63.0",
......
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { AppState, AppStateStatus } from 'react-native' import { AppState, AppStateStatus } from 'react-native';
import AppContainer from './router' import AppContainer from './router';
import { GeekAppModals, store, appModel, Toast, navigationService } from 'geekbase' import models from '@/models';
import { StoreProvider, createStore } from 'easy-peasy' import { GeekAppModals, store, Toast, navigationService } from 'geekbase';
import { StoreProvider, createStore } from 'easy-peasy';
import { Provider } from '@ant-design/react-native';
store.store = createStore({ store.store = createStore({
...appModel ...models,
}) });
export default function App() { export default function App() {
useEffect(() => { useEffect(() => {
console.log('--app进入') console.log('--app进入');
console.log('App', '注册微信') console.log('App', '注册微信');
AppState.addEventListener('change', handleAppStateChange) AppState.addEventListener('change', handleAppStateChange);
return () => { return () => {
AppState.removeEventListener('change', handleAppStateChange) AppState.removeEventListener('change', handleAppStateChange);
} };
}, []) }, []);
const handleAppStateChange = (appState:AppStateStatus) => { const handleAppStateChange = (appState: AppStateStatus) => {
console.log('当前app状态', appState) console.log('当前app状态', appState);
if (appState === 'background') { if (appState === 'background') {
Toast.hideLoading() Toast.hideLoading();
} }
} };
return ( return (
<StoreProvider store={store.store}> <Provider>
<AppContainer ref={navigatorRef => { <StoreProvider store={store.store}>
navigationService.setTopLevelNavigator(navigatorRef) <AppContainer
}} /> ref={(navigatorRef) => {
<GeekAppModals /> navigationService.setTopLevelNavigator(navigatorRef);
</StoreProvider> }}
/>
<GeekAppModals />
</StoreProvider>
</Provider>
); );
} }
/* eslint-disable react/prop-types */ import React, { useEffect, useState, useImperativeHandle, useRef } from 'react';
import React, { useEffect, useState, useImperativeHandle, useRef } from "react"; import { View } from 'react-native';
import { View } from "react-native"; import WebView from 'react-native-webview';
import WebView from "react-native-webview"; import { X5WebView } from 'react-native-tbswebview';
import { X5WebView } from "react-native-tbswebview"; import { device } from 'geekbase';
import { device } from "geekbase";
/** /**
* 极客webview * 极客webview
...@@ -23,7 +22,7 @@ export const GeekWebView = React.forwardRef((props, ref) => { ...@@ -23,7 +22,7 @@ export const GeekWebView = React.forwardRef((props, ref) => {
onTitle, onTitle,
renderLoading, renderLoading,
onPlayVideo, onPlayVideo,
onLog onLog,
} = props; } = props;
const [url, setUrl] = useState(uri); const [url, setUrl] = useState(uri);
const webViewRef = useRef(null); const webViewRef = useRef(null);
...@@ -32,25 +31,25 @@ export const GeekWebView = React.forwardRef((props, ref) => { ...@@ -32,25 +31,25 @@ export const GeekWebView = React.forwardRef((props, ref) => {
const handleMessage = (event) => { const handleMessage = (event) => {
const data = const data =
device.os === "ios" ? JSON.parse(event.nativeEvent.data) : JSON.parse(event.data); device.os === 'ios' ? JSON.parse(event.nativeEvent.data) : JSON.parse(event.data);
if (data.type === "share") { if (data.type === 'share') {
onShare && onShare(data.data); onShare && onShare(data.data);
return; return;
} }
if (data.type === "shareTimeline") { if (data.type === 'shareTimeline') {
onShareTimeline && onShareTimeline(data.data); onShareTimeline && onShareTimeline(data.data);
return; return;
} }
if (data.type === "title") { if (data.type === 'title') {
onTitle && onTitle(data.data); onTitle && onTitle(data.data);
return; return;
} }
if (data.type === 'video') { if (data.type === 'video') {
console.log('play', data) console.log('play', data);
onPlayVideo && onPlayVideo(data.data) onPlayVideo && onPlayVideo(data.data);
} }
if (data.type === 'log') { if (data.type === 'log') {
onLog && onLog(data.data) onLog && onLog(data.data);
} }
onMessage(data); onMessage(data);
}; };
...@@ -62,7 +61,7 @@ export const GeekWebView = React.forwardRef((props, ref) => { ...@@ -62,7 +61,7 @@ export const GeekWebView = React.forwardRef((props, ref) => {
[uri, useToken] [uri, useToken]
); );
const excuteJSMethod = ({ method = "", data = "" }) => { const excuteJSMethod = ({ method = '', data = '' }) => {
const params = JSON.stringify({ method, data }); const params = JSON.stringify({ method, data });
if (webViewRef.current) { if (webViewRef.current) {
webViewRef.current.injectJavaScript(`window.$geek_excuteJS('${params}')`); webViewRef.current.injectJavaScript(`window.$geek_excuteJS('${params}')`);
...@@ -100,8 +99,8 @@ export const GeekWebView = React.forwardRef((props, ref) => { ...@@ -100,8 +99,8 @@ export const GeekWebView = React.forwardRef((props, ref) => {
})); }));
return ( return (
<View style={{ flex: 1, width: "100%", backgroundColor: "red", ...style }}> <View style={{ flex: 1, width: '100%', backgroundColor: 'red', ...style }}>
{device.os === "ios" && ( {device.os === 'ios' && (
<WebView <WebView
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
...@@ -110,7 +109,7 @@ export const GeekWebView = React.forwardRef((props, ref) => { ...@@ -110,7 +109,7 @@ export const GeekWebView = React.forwardRef((props, ref) => {
style={{ flex: 1 }} style={{ flex: 1 }}
source={{ uri: url }} source={{ uri: url }}
onMessage={handleMessage} onMessage={handleMessage}
originWhitelist={["*"]} originWhitelist={['*']}
useWebKit={true} useWebKit={true}
startInLoadingState={true} startInLoadingState={true}
renderLoading={renderLoading} renderLoading={renderLoading}
...@@ -121,7 +120,7 @@ export const GeekWebView = React.forwardRef((props, ref) => { ...@@ -121,7 +120,7 @@ export const GeekWebView = React.forwardRef((props, ref) => {
}} }}
/> />
)} )}
{device.os === "android" && ( {device.os === 'android' && (
<> <>
<X5WebView <X5WebView
ref={webViewRef} ref={webViewRef}
...@@ -139,7 +138,7 @@ export const GeekWebView = React.forwardRef((props, ref) => { ...@@ -139,7 +138,7 @@ export const GeekWebView = React.forwardRef((props, ref) => {
}} }}
style={{ flex: 1 }} style={{ flex: 1 }}
onMessage={(data) => { onMessage={(data) => {
console.log('onMessage : ', data) console.log('onMessage : ', data);
const nativeData = JSON.parse(data); const nativeData = JSON.parse(data);
handleMessage(nativeData); handleMessage(nativeData);
}} }}
......
const Config = { const Config = {
// appConfigUrl: 'https://profile-1257124244.cos.ap-chengdu.myqcloud.com/app_resource/geek_math_app_config.json', // appConfigUrl: 'https://profile-1257124244.cos.ap-chengdu.myqcloud.com/app_resource/geek_math_app_config.json',
appConfigUrl:'jj',//填写配置文件路径 appConfigUrl: 'jj', //填写配置文件路径
AppConfig: { AppConfig: {
weChatCode: '', weChatCode: '',
universalLink: '', universalLink: '',
timeout: 15000, timeout: 15000,
// 生产 // 生产
baseUrl: __DEV__ ? 'http://192.168.32.37:3000' : 'https://geek.jkwljy.com', baseUrl: __DEV__ ? 'http://192.168.44.93:8400' : 'https://geek.jkwljy.com',
stopServer: { stopServer: {
stop: false, stop: false,
description: '暂时停服' description: '暂时停服',
}, },
appVersion: { // 最新的系统版本【不是热更新版本!!!,而是上架应用商店的APP最新版本】 appVersion: {
ios: { // 最新的系统版本【不是热更新版本!!!,而是上架应用商店的APP最新版本】
versionNumber: "1.0", ios: {
versionDescription: "测试ios", versionNumber: '1.0',
isMandatory: false, versionDescription: '测试ios',
appStoreUrl: "111" // ios下载路径 isMandatory: false,
}, appStoreUrl: '111', // ios下载路径
android: { },
versionNumber: "1.0", android: {
versionDescription: "测试android", versionNumber: '1.0',
isMandatory: false, versionDescription: '测试android',
apkUrl: "111" // Android下载路径 isMandatory: false,
} apkUrl: '111', // Android下载路径
}, },
codePush: { },
open: true, codePush: {
isRelease: true, open: true,
ios: { isRelease: true,
releaseKey: "IPIj65rPV5R4EIYYioZGNtazsufY4ksvOXqog", ios: {
stagingKey: "c5XU3KTuISEnHAtAA0IRx3e4ejV14ksvOXqog" releaseKey: 'IPIj65rPV5R4EIYYioZGNtazsufY4ksvOXqog',
}, stagingKey: 'c5XU3KTuISEnHAtAA0IRx3e4ejV14ksvOXqog',
android: { },
releaseKey: "UWQrx8vNd4uWeE4EgGH42HTTXNRM4ksvOXqog", android: {
stagingKey: "T22PvpZAdiwpmzNw27qxIVqLPEHS4ksvOXqog" releaseKey: 'UWQrx8vNd4uWeE4EgGH42HTTXNRM4ksvOXqog',
} stagingKey: 'T22PvpZAdiwpmzNw27qxIVqLPEHS4ksvOXqog',
}, },
} },
} },
};
export default Config export default Config;
\ No newline at end of file
import {useEffect, useState, useLayoutEffect} from 'react'; import { useEffect } from 'react';
import {NavigationStackProp} from 'react-navigation-stack'; import { NavigationStackProp } from 'react-navigation-stack';
import {StatusBar} from 'react-native'; import { StackNavigationOptions } from 'react-navigation-stack/lib/typescript/src/vendor/types';
import {device} from 'geekbase';
import {StackNavigationOptions} from 'react-navigation-stack/lib/typescript/src/vendor/types';
import {navigationOptions} from '@/router/constant';
import { createTypedHooks } from 'easy-peasy'; import { createTypedHooks } from 'easy-peasy';
import StoreModels from '@/models' import StoreModels from '@/models';
import { navigationOptions } from '@/router/constant';
import { NavigationScreenProp } from 'react-navigation';
// 路由进入时hook // 路由进入时hook
export const useStackFocus = ( export const useStackFocus = (
navigation: NavigationStackProp<{name: string}>, navigation: NavigationStackProp<{ name: string }>,
cb: Function, cb: Function,
) => { ) => {
function handleFocus() { function handleFocus() {
...@@ -39,77 +38,27 @@ export const useStackBlur = ( ...@@ -39,77 +38,27 @@ export const useStackBlur = (
}, []); }, []);
}; };
export function useFocusBlur(navigation: NavigationStackProp) { type StackConfigParam<S, P> = (args: {
const [isFocus, setIsFocus] = useState(false); navigation: NavigationScreenProp<S, P>;
const [isBlur, setIsBlur] = useState(false); }) => StackNavigationOptions;
// 第二个参数如果为undefined,则代表什么都依赖【componentDidMount + componentDidUpdate】
// 第二个参数如果为[],代表什么都不依赖【componentDidMount】
// 第二个参数如果为[status],代表依赖status,status变化才会触发useLayoutEffect 、useEffect
// DOM变更后,内核渲染前触发,其会同步触发渲染(阻塞,故只有在useEffect出问题时再用它)
// 此处监听页面的didFocus和didBlur,发现useEffect会出问题(switchNavigator切换时无法触发),故选用useLayoutEffect
useLayoutEffect(() => {
console.log('useFocusBlur', 'isFocus');
const focusListener = navigation.addListener('didFocus', (payload) => {
setIsFocus(true);
setIsBlur(false);
});
const blurListener = navigation.addListener('didBlur', (payload) => {
setIsFocus(false);
setIsBlur(true);
});
return () => {
// didUnmount
focusListener && focusListener.remove();
blurListener && blurListener.remove();
};
}, []);
return {isFocus, isBlur};
}
export function useStatusBar(isFocus: boolean, show = true, color = 'black') {
useEffect(() => {
if (!isFocus) {
return;
}
if (!show) {
// 不显示状态栏
StatusBar.setHidden(true, 'none');
return;
}
StatusBar.setHidden(false, 'none');
if (device.os === 'android') {
StatusBar.setTranslucent(true);
StatusBar.setBackgroundColor('transparent');
}
switch (color) {
case 'black':
StatusBar.setBarStyle('dark-content');
break;
case 'white':
StatusBar.setBarStyle('light-content');
break;
default:
StatusBar.setBarStyle('dark-content');
}
}, [isFocus]);
}
export const withStackScreen = ( export const withStackScreen = (
Wrapp: React.ReactNode, Wrapp: React.ReactNode,
config: StackNavigationOptions, config: StackNavigationOptions | StackConfigParam<any, any>,
) => { ) => {
(Wrapp as any).navigationOptions = { (Wrapp as any).navigationOptions =
...navigationOptions, typeof config === 'function'
...config, ? (args: any) => ({ ...(config(args) || {}), ...navigationOptions })
}; : {
...navigationOptions,
...config,
};
return Wrapp; return Wrapp;
}; };
export const { useStoreActions, useStoreState, useStoreDispatch, useStore } = createTypedHooks<typeof StoreModels>() export const {
useStoreActions,
useStoreState,
useStoreDispatch,
useStore,
} = createTypedHooks<typeof StoreModels>();
import { createStore } from 'easy-peasy' import { appModel } from 'geekbase';
import { appModel } from 'geekbase' import correctModels from '@/pages/geek-correct-list/model';
export default createStore(appModel) export default {
\ No newline at end of file ...appModel,
correctModels,
};
import React from 'react' import { navigationService, getAppConfig } from 'geekbase';
import { navigationService, getAppConfig } from 'geekbase' import cache from '@/cache';
import cache from '@/cache'
export default { export default {
/** /**
* 去webview页面 * 去webview页面
* @param {uri, useToken, initTitle, onMessage } props * @param {uri, useToken, initTitle, onMessage } props
*/ */
navigateGeekWebViewPage(props: { navigateGeekWebViewPage(props: {
uri: string, uri: string;
useToken: boolean, useToken?: boolean;
initTitle: string, initTitle?: string;
onMessage: Function onMessage?: Function;
}) { }) {
const { uri, useToken, ...others } = props const { uri, useToken, ...others } = props;
let url = uri let url = uri;
if (useToken) { if (useToken) {
cache.getToken().then((token: string) => { cache.getToken().then((token: string) => {
if (url.indexOf("?") !== -1) { if (url.indexOf('?') !== -1) {
if (url[uri.length - 1] === "&") { if (url[uri.length - 1] === '&') {
url = `${url}token=${token}`; url = `${url}token=${token}`;
} else { } else {
url = `${url}&token=${token}`; url = `${url}&token=${token}`;
...@@ -27,25 +25,32 @@ export default { ...@@ -27,25 +25,32 @@ export default {
} else { } else {
url = `${url}?token=${token}`; url = `${url}?token=${token}`;
} }
navigationService.navigate('GeekWebViewPage', { navigationService.navigate('GeekWebView', {
uri: /^https?:\/\//g.test(url) ? url : `${getAppConfig().baseUrl}${url}`, uri: /^https?:\/\//g.test(url)
...others ? url
}) : `${getAppConfig().baseUrl}${url}`,
...others,
});
}); });
} else { } else {
navigationService.navigate('GeekWebViewPage', { navigationService.navigate('GeekWebView', {
uri: /^https?:\/\//g.test(url) ? url : `${getAppConfig().baseUrl}${url}`, uri: /^https?:\/\//g.test(url)
...others ? url
}) : `${getAppConfig().baseUrl}${url}`,
...others,
});
} }
}, },
navigateAbout: () => { navigateAbout: () => {
navigationService.navigate('About') navigationService.navigate('About');
}, },
navigateAuth: () => { navigateAuth: () => {
navigationService.navigate('auth') navigationService.navigate('auth');
},
navigateCorrectList: () => {
navigationService.navigate('CorrectList');
}, },
};
}
\ No newline at end of file
import { useStoreActions, useStoreState, withStackScreen } from '@/hooks';
import { GeekFlatList, rpx, Toast } from 'geekbase';
import React, { useCallback, useEffect } from 'react';
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { NavigationScreenProp } from 'react-navigation';
import FastImage from 'react-native-fast-image'
import imagePicker from 'react-native-image-picker';
import navigate from '@/navigate';
type CorrectListState = {
name: String;
};
type CorrectListNavigationParams = {
name: String;
rightAdd: () => void;
};
type CorrectListType = {
navigation: NavigationScreenProp<
CorrectListState,
CorrectListNavigationParams
>;
};
const CorrectList = ({ navigation }: CorrectListType) => {
const refreshing = useStoreState((state) => state.correctModels.refreshing);
const loadCorrect = useStoreActions((actions) => actions.correctModels.loadCorrectList);
const setRefreshing = useStoreActions((actions) => actions.correctModels.setRefreshing);
const list = useStoreState((state) => state.correctModels.list);
const uploadImage = useStoreActions((state) => state.correctModels.uploadImage);
const toTakeHomeWorkPhoto = useCallback(async () => {
Toast.showLoading();
imagePicker.launchCamera(
{
title: '拍照',
mediaType: 'photo',
videoQuality: 'medium',
},
async (res) => {
const { uri, didCancel } = res || {};
if (didCancel) {
Toast.hideLoading();
Toast.msg('取消上传!!!');
}
if (uri) {
const data = await uploadImage(uri);
Toast.hideLoading();
toHomeWorkDetail(data.onlineHomeworkImageId || '');
}
},
);
}, []);
const toHomeWorkDetail = useCallback((id: number | string) => {
navigate.navigateGeekWebViewPage({
uri: `http://192.168.44.178:3000/mobile-webview/#/home-workcorrect/${id}`,
useToken: true,
initTitle: '作业批阅',
});
}, []);
const rightAdd = useCallback(() => {
toTakeHomeWorkPhoto();
}, []);
useEffect(() => {
navigation.setParams({ rightAdd });
setRefreshing(true);
}, []);
return (
<GeekFlatList
renderItem={(itm: any) => {
const { item, index } = itm || {};
return (
<TouchableOpacity onPress={() => {
toHomeWorkDetail(item.id);
}}>
<View style={styles.listItem} key={index}>
<FastImage style={styles.sourceImg} source={{ uri: item.imageUrl }} />
<Text style={{ alignContent: 'center', textAlign: 'center', marginTop: rpx(10) }}>{item.status === 1 ? '解析完成' : '解析中'}</Text>
</View>
</TouchableOpacity>
);
}}
keyExtractor={(itm, index) => {
return `${index}`;
}}
data={list}
emptyText="暂无数据"
refreshing={refreshing}
onRefresh={() => loadCorrect()}
numColumns={3}
/>
);
};
withStackScreen(CorrectList, ({ navigation }) => {
const rightAdd = navigation.getParam('rightAdd');
return {
headerTitle: '列表',
headerRight: () => {
return (
<TouchableOpacity onPress={() => rightAdd()}>
<Text style={{ marginRight: rpx(10) }}>添加</Text>
</TouchableOpacity>
);
},
};
});
const styles = StyleSheet.create({
listItem: {
height: rpx(750 / 3),
width: rpx(750 / 3),
padding: rpx(30),
flexDirection: 'column',
},
sourceImg: {
flex: 1,
},
});
export default CorrectList;
import { addOnlineHomeworkImageInterface, loadOnlineHomeworkImages } from '@/service';
import { Action, thunk, Thunk, action } from 'easy-peasy';
import { Toast } from 'geekbase';
type CorrectListStoreModelType = {
list: Array<any>;
setList: Action<CorrectListStoreModelType, Array<any>>;
refreshing: boolean;
setRefreshing: Action<CorrectListStoreModelType, boolean>;
uploadImage: Thunk<CorrectListStoreModelType, String, any>;
loadCorrectList: Thunk<CorrectListStoreModelType, any, any>;
};
export default <CorrectListStoreModelType>{
refreshing: false,
list: [],
uploadImage: thunk(async (actions, payload) => {
const [res, error] = await addOnlineHomeworkImageInterface(payload, 123);
console.log('==== done', res);
if (!error) {
console.log(error);
return res;
} else {
return null;
}
}),
setRefreshing: action((state, payload) => {
state.refreshing = payload;
}),
setList: action((state, payload) => {
state.list = payload;
}),
loadCorrectList: thunk(async (actions) => {
actions.setRefreshing(true);
let [list, error] = await loadOnlineHomeworkImages();
console.log('====', list, error);
actions.setRefreshing(false);
if (error) {
Toast.warn('请求数据失败');
} else {
actions.setList(list);
}
}),
};
import bgImg from './bg.png'
export {
bgImg
}
\ No newline at end of file
import React, { useEffect, useState } from 'react' /* eslint-disable react-native/no-inline-styles */
import { View, Text } from "react-native"; import React, { useCallback, useEffect } from 'react';
import { TouchableHighlight } from 'react-native-gesture-handler'; import {
View,
ImageBackground,
StyleSheet,
Text,
TouchableHighlight,
} from 'react-native';
import { withStackScreen } from '@/hooks'; import { withStackScreen } from '@/hooks';
import { showWorkPicker } from '@/rn-module/work-correct'; import { SafeAreaView } from 'react-native-safe-area-context';
import { bgImg } from './assets';
import { rpx, useStatusBar } from 'geekbase';
import navigate from '@/navigate';
const Home = (props: any) => { const Home = ({}: any) => {
useStatusBar(true, true, 'black');
useEffect(() => { useEffect(() => {
}, []) console.log('bg: ', bgImg);
}, []);
const update =()=>{ const toCorrect = useCallback(() => {
} navigate.navigateCorrectList();
return ( }, []);
<View style={{ flex: 1 }}>
<TouchableHighlight onPress={() => { return (
showWorkPicker(123) <ImageBackground source={bgImg} style={styles.bgStyle}>
}}> <SafeAreaView style={{ flex: 1 }}>
<View> <View style={styles.functionalArea}>
<Text style={{ height: 60, backgroundColor: 'blue' }}>tap ll</Text> <TouchableHighlight
<Text style={{ height: 60, backgroundColor: 'blue' }}>tap ll</Text> onPress={() => {
</View> toCorrect();
</TouchableHighlight> }}
style={styles.funItem}>
<View style={styles.funContainer}>
<Text style={styles.fucText}>作业批阅</Text>
</View>
</TouchableHighlight>
<TouchableHighlight onPress={() => {}} style={styles.funItem}>
<View style={styles.funContainer}>
<Text style={styles.fucText}>其他功能</Text>
</View>
</TouchableHighlight>
</View> </View>
) </SafeAreaView>
} </ImageBackground>
);
};
const styles = StyleSheet.create({
bgStyle: {
flex: 1,
},
functionalArea: {
flex: 1,
marginTop: rpx(500),
borderTopLeftRadius: rpx(375),
flexDirection: 'row',
justifyContent: 'space-around',
},
funItem: {
width: rpx(300),
height: rpx(200),
borderRadius: rpx(10),
backgroundColor: 'rgba(0,0,0,0.1)',
alignItems: 'center',
justifyContent: 'center',
},
funContainer: {
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
},
fucText: {
color: 'white',
fontSize: rpx(30),
fontWeight: 'bold',
},
});
export default withStackScreen(Home, { export default withStackScreen(Home, {
headerTitle: 'kkkkkkk' header: () => null,
}) });
\ No newline at end of file
import React from 'react' import React from 'react';
import { View, Text } from 'react-native' import { View, Text } from 'react-native';
import { TouchableOpacity } from 'react-native-gesture-handler' import { TouchableOpacity } from 'react-native-gesture-handler';
import navigate from '@/navigate' import { navigationService } from 'geekbase';
export default () => { export default () => {
return ( return (
<View> <View>
<Text> this is login page </Text> <Text> this is login page </Text>
<TouchableOpacity onPress={() => { <TouchableOpacity
navigate.navigateAbout() onPress={() => {
}}> navigationService.navigate('home');
}}>
<Text>home</Text> <Text>home</Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
) );
} };
\ No newline at end of file
...@@ -18,7 +18,7 @@ function SplashPage(props: any) { ...@@ -18,7 +18,7 @@ function SplashPage(props: any) {
useEffect(() => { useEffect(() => {
if (!appConfigFinish) return if (!appConfigFinish) return
navigationService.navigate('THome') navigationService.navigate('home')
}, [appConfigFinish]) }, [appConfigFinish])
......
/* eslint-disable react/prop-types */ import React, { useEffect, useRef, useState } from 'react';
import React, { useEffect, useRef, useState } from "react";
import { import {
View, View,
StyleSheet, StyleSheet,
...@@ -7,23 +6,20 @@ import { ...@@ -7,23 +6,20 @@ import {
TouchableWithoutFeedback, TouchableWithoutFeedback,
Image, Image,
ActivityIndicator, ActivityIndicator,
} from "react-native"; SafeAreaView,
import { device, rpx } from "geekbase"; } from 'react-native';
import { useFocusBlur, useStatusBar, navigationOptions } from "@/appbase"; import { device, rpx, useFocusBlur, useStatusBar } from 'geekbase';
import { colors } from "@/assets"; import { back } from './assets';
import { back } from "./assets"; import { GeekWebView } from '@/components';
import { GeekWebView } from "@/components"; import { navigationOptions } from '@/router/constant';
import { shareByWeb } from "@/utils";
import * as utils from '@/utils'
function GeekWebViewPage(props) { function GeekWebViewPage(props) {
const uri = props.navigation.getParam("uri"); const uri = props.navigation.getParam('uri');
const useToken = props.navigation.getParam("useToken"); const onMessage = props.navigation.getParam('onMessage');
const onMessage = props.navigation.getParam("onMessage");
const webviewRef = useRef(); const webviewRef = useRef();
const [url, setUrl] = useState(uri); const [url] = useState(uri);
const { isFocus } = useFocusBlur(props.navigation); const { isFocus } = useFocusBlur(props.navigation);
useStatusBar(isFocus, true, "black"); useStatusBar(isFocus, true, 'black');
// 返回逻辑 // 返回逻辑
...@@ -41,88 +37,90 @@ function GeekWebViewPage(props) { ...@@ -41,88 +37,90 @@ function GeekWebViewPage(props) {
}; };
const onTitle = (title) => { const onTitle = (title) => {
const initTitle = props.navigation.getParam("initTitle"); const initTitle = props.navigation.getParam('initTitle');
props.navigation.setParams({ title: title || initTitle }); props.navigation.setParams({ title: title || initTitle });
}; };
const handleMessage = (event) => { const handleMessage = (event) => {
if (onMessage) { if (onMessage) {
onMessage(event) onMessage(event);
} }
}; };
// 分享逻辑 // 分享逻辑
const handleShare = (data) => { const handleShare = (data) => {
shareByWeb(data); // shareByWeb(data);
}; };
// 分享朋友圈 // 分享朋友圈
const handleShareTimeline = (data) => { const handleShareTimeline = (data) => {
console.log("onShareTimeline"); console.log('onShareTimeline');
shareByWeb(data, true); // shareByWeb(data, true);
}; };
// 播放视频 // 播放视频
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
const playVideo = ({ url }) => { const playVideo = ({ url }) => {
utils.playVideo(url, (result) => { // utils.playVideo(url, (result) => {
setTimeout(() => { // setTimeout(() => {
webviewRef.current && webviewRef.current.excuteJSMethod({ // webviewRef.current && webviewRef.current.excuteJSMethod({
method: 'uploadPlayInfo', // method: 'uploadPlayInfo',
data: result // data: result,
}) // });
}, 500); // }, 500);
}) // });
} };
// h5 的log日志 // h5 的log日志
const handleLog = (args) => { const handleLog = (args) => {
if (__DEV__) { if (__DEV__) {
console.log('H5 LOG: ', args) console.log('H5 LOG: ', args);
} }
} };
useEffect(() => { useEffect(() => {
const backEffect = () => { const backEffect = () => {
onBack(); onBack();
return true; return true;
} };
if (device.os === "android") { if (device.os === 'android') {
// 针对安卓的实体返回键 true 返回无效;false 正常返回 // 针对安卓的实体返回键 true 返回无效;false 正常返回
BackHandler.addEventListener("hardwareBackPress", backEffect); BackHandler.addEventListener('hardwareBackPress', backEffect);
} }
props.navigation.setParams({ onBack, onClose }); props.navigation.setParams({ onBack, onClose });
return () => { return () => {
BackHandler.removeEventListener("hardwareBackPress", backEffect); BackHandler.removeEventListener('hardwareBackPress', backEffect);
}; };
}, []); }, []);
return ( return (
<GeekWebView <SafeAreaView style={{ flex: 1 }}>
ref={webviewRef} <GeekWebView
style={styles.container} ref={webviewRef}
uri={url} style={styles.container}
renderLoading={() => ( uri={url}
<View renderLoading={() => (
style={{ <View
height: style={{
device.height - height:
device.headerHeight - device.height -
device.androidStatusBarHeight, device.headerHeight -
justifyContent: "center", device.androidStatusBarHeight,
alignItems: "center", justifyContent: 'center',
}} alignItems: 'center',
> }}
<ActivityIndicator size="large" /> >
</View> <ActivityIndicator size="large" />
)} </View>
onTitle={onTitle} )}
onShare={handleShare} onTitle={onTitle}
onMessage={handleMessage} onShare={handleShare}
onPlayVideo={playVideo} onMessage={handleMessage}
onShareTimeline={handleShareTimeline} onPlayVideo={playVideo}
onLog={handleLog} onShareTimeline={handleShareTimeline}
/> onLog={handleLog}
/>
</SafeAreaView>
); );
} }
...@@ -132,20 +130,20 @@ GeekWebViewPage.navigationOptions = ({ navigation }) => { ...@@ -132,20 +130,20 @@ GeekWebViewPage.navigationOptions = ({ navigation }) => {
headerStyle: { headerStyle: {
...navigationOptions.headerStyle || {}, ...navigationOptions.headerStyle || {},
borderBottomColor: '#DEE2EA', borderBottomColor: '#DEE2EA',
borderBottomWidth: rpx(1) borderBottomWidth: rpx(1),
}, },
headerTitle: navigation.getParam("title"), headerTitle: navigation.getParam('title'),
headerLeft: () => { headerLeft: () => {
return ( return (
<View <View
style={{ style={{
minWidth: rpx(100), minWidth: rpx(100),
marginLeft: rpx(20), marginLeft: rpx(20),
flexDirection: "row", flexDirection: 'row',
alignItems: "center", alignItems: 'center',
}} }}
> >
<TouchableWithoutFeedback onPress={navigation.getParam("onBack")}> <TouchableWithoutFeedback onPress={navigation.getParam('onBack')}>
<Image <Image
source={back} source={back}
style={{ width: rpx(40), height: rpx(40), marginLeft: rpx(10), padding: rpx(10) }} style={{ width: rpx(40), height: rpx(40), marginLeft: rpx(10), padding: rpx(10) }}
...@@ -160,7 +158,7 @@ GeekWebViewPage.navigationOptions = ({ navigation }) => { ...@@ -160,7 +158,7 @@ GeekWebViewPage.navigationOptions = ({ navigation }) => {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
backgroundColor: colors.pageBgColor, backgroundColor: '#f5f5f5',
}, },
}); });
......
import {NativeModules, NativeEventEmitter} from 'react-native';
import { addOnlineHomeworkImageInterface } from '@/service';
const GeekWorkPicker = NativeModules.GeekWorkPicker;
const GeekPickerEventEmitter = NativeModules.GeekPickerEventEmitter;
const calendarManagerEmitter = new NativeEventEmitter(GeekPickerEventEmitter);
const noop = {
cb: (...arg: any) => {},
res: {}
}
calendarManagerEmitter.addListener('GeekWorkPicker', (res) => {
noop.res = res
noop.cb && noop.cb(res)
})
const uploadedHomeWork = async (img: string, studentId: number) => {
console.log('uploadedHomeWork', img)
const data = await addOnlineHomeworkImageInterface(img, '123')
console.log('uploadedHomeWork: ', data)
};
const showWorkPicker = async (studentId: number) => {
GeekWorkPicker.openWorkPicker()
noop.cb = async (arg) => {
// 处理图片上传
if (arg.type === 'uploadImage') {
// TODO: 上传图片地址
const path = arg.image
const res = await uploadedHomeWork(path, studentId);
GeekWorkPicker.showWorkResult(path, []);
}
// 处理数据
if (arg.type === 'uploadWork') {
// TODO: 上传数据
}
}
};
export { showWorkPicker };
import React from 'react' import React from 'react';
import { StackNavigationOptions } from 'react-navigation-stack/lib/typescript/src/vendor/types' import { StackNavigationOptions } from 'react-navigation-stack/lib/typescript/src/vendor/types';
import { NavigationCommonTabOptions } from 'react-navigation-tabs/lib/typescript/src/types' import { NavigationCommonTabOptions } from 'react-navigation-tabs/lib/typescript/src/types';
import Home from '@/pages/geek-home'
import Login from '@/pages/geek-login'
import SplashPage from '@/pages/geek-splash'
import Home from '@/pages/geek-home';
import Login from '@/pages/geek-login';
import SplashPage from '@/pages/geek-splash';
import CorrectList from '@/pages/geek-correct-list';
import GeekWebView from '@/pages/geek-webview';
type StackPageProps = { type StackPageProps = {
name: string name: string;
component: React.ReactNode, component: React.ReactNode;
navigationOptions?: StackNavigationOptions navigationOptions?: StackNavigationOptions;
} };
type TabsPageProps = { type TabsPageProps = {
component?: React.ReactNode, component?: React.ReactNode;
name: string, name: string;
navigationOptions?: NavigationCommonTabOptions, navigationOptions?: NavigationCommonTabOptions;
children: StackPageProps[] children: StackPageProps[];
} };
export type SwitchProps = { export type SwitchProps = {
tabs: TabsPageProps[], // tabs tabs?: TabsPageProps[]; // tabs
auth: StackPageProps[] | StackPageProps, // 权限页面 auth: StackPageProps[] | StackPageProps; // 权限页面
[key: string]: TabsPageProps[] | StackPageProps[] | StackPageProps [key: string]: TabsPageProps[] | StackPageProps[] | StackPageProps | any;
} };
const appConfig: SwitchProps = { const appConfig: SwitchProps = {
splash: { component: SplashPage, name: 'SplashPage' }, splash: { component: SplashPage, name: 'SplashPage' },
tabs: [
{
component: Home, name: 'THome',
navigationOptions: {
tabBarLabel: 'uu'
},
children: [
{ name: 'Home', component: Home },
]
}
],
auth: { component: Login, name: 'login' }, auth: { component: Login, name: 'login' },
} home: [
{ component: Home, name: 'home' },
{ component: CorrectList, name: 'CorrectList' },
{ component: GeekWebView, name: 'GeekWebView' },
],
};
export default appConfig export default appConfig;
\ No newline at end of file
import React from 'react' /* eslint-disable react-native/no-inline-styles */
import { Image, Text, View } from "react-native" import React from 'react';
import { device, rpx } from "geekbase" import { Image, Text, View } from 'react-native';
import backBlackImg from "@/assets/header/back.png" import { device, rpx } from 'geekbase';
import backWhiteImg from "@/assets/header/backwhite.png" import backBlackImg from '@/assets/header/back.png';
import { TouchableOpacity } from 'react-native-gesture-handler' import backWhiteImg from '@/assets/header/backwhite.png';
import { TouchableOpacity } from 'react-native-gesture-handler';
import { StackNavigationOptions } from 'react-navigation-stack/lib/typescript/src/vendor/types';
function headerBack({ canGoBack, onPress }: any, isBlack = true) {
function headerBack({ canGoBack, onPress }: any, isBlack=true) { return canGoBack ? (
return ( <TouchableOpacity onPress={onPress}>
canGoBack ? <TouchableOpacity onPress={onPress}> <View
<View style={{ style={{
width: rpx(80), height: device.headerHeight - rpx(20), width: rpx(80),
marginLeft: rpx(0), alignItems: 'center', justifyContent: 'center' height: device.headerHeight - rpx(20),
}}> marginLeft: rpx(0),
<Image source={isBlack ? backBlackImg : backWhiteImg} style={{ width: rpx(36), height: rpx(36) }} /> alignItems: 'center',
</View> justifyContent: 'center',
</TouchableOpacity> : null }}>
) <Image
source={isBlack ? backBlackImg : backWhiteImg}
style={{ width: rpx(36), height: rpx(36) }}
/>
</View>
</TouchableOpacity>
) : null;
} }
function headerBackImage(isBlack = true) { function headerBackImage(isBlack = true) {
return ( return (
<View style={{ <View
width: rpx(80), height: device.headerHeight - rpx(20), style={{
marginLeft: rpx(0), alignItems: 'center', justifyContent: 'center' width: rpx(80),
}}> height: device.headerHeight - rpx(20),
<Image source={isBlack ? backBlackImg : backWhiteImg} style={{ width: rpx(36), height: rpx(36) }} /> marginLeft: rpx(0),
</View> alignItems: 'center',
) justifyContent: 'center',
}}>
<Image
source={isBlack ? backBlackImg : backWhiteImg}
style={{ width: rpx(36), height: rpx(36) }}
/>
</View>
);
} }
const commonNavigationOptions = { const commonNavigationOptions = {
headerBackTitle: null, // 必须在源屏幕 (而不是目标屏幕) 中定义 headerBackTitle: '', // 必须在源屏幕 (而不是目标屏幕) 中定义
headerRight: <Text></Text>, headerBackTitleVisible: false,
headerTitleContainerStyle: { headerTitleContainerStyle: {
flex: 1, // 可以不写 justifyContent: 'center',
justifyContent: 'center', alignItems: 'center',
alignItems: 'center' },
}, headerTitleAllowFontScaling: false, // 避免字体受系统字体缩放影响
headerTitleAllowFontScaling: false, // 避免字体受系统字体缩放影响 };
}
const commonHeaderStyle = { const commonHeaderStyle = {
borderBottomWidth: 0, borderBottomWidth: 0,
shadowOpacity: 0, shadowOpacity: 0,
elevation: 0 elevation: 0,
} };
const commonHeaderTitleStyle = { const commonHeaderTitleStyle = {
fontSize: rpx(37), fontSize: rpx(37),
fontWeight: '500', fontWeight: '500',
alignSelf: 'center', alignSelf: 'center',
textAlign: 'center' textAlign: 'center',
} };
const navigationOptions = { const navigationOptions: StackNavigationOptions = {
...commonNavigationOptions, ...(commonNavigationOptions as any),
headerStyle: { headerStyle: {
...commonHeaderStyle, ...commonHeaderStyle,
backgroundColor: '#fff' backgroundColor: '#fff',
}, },
headerBackImage: headerBackImage(), headerBackImage: () => headerBackImage(),
headerTitleStyle: { headerTitleStyle: {
...commonHeaderTitleStyle, ...commonHeaderTitleStyle,
color: '#484C4F' color: '#484C4F',
} } as any,
} };
export { export { navigationOptions, headerBack, headerBackImage };
navigationOptions,
headerBack,
headerBackImage
}
import React from 'react';
import { createAppContainer, createSwitchNavigator } from 'react-navigation'; import { createAppContainer, createSwitchNavigator } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack'; import { createStackNavigator } from 'react-navigation-stack';
import { createBottomTabNavigator } from 'react-navigation-tabs' import { createBottomTabNavigator } from 'react-navigation-tabs';
import routerConfig from './config' import routerConfig from './config';
import { headerBack } from './constant';
// navigation // navigation
const renderStack = ( tabRoute: any ) => { const renderStack = (tabRoute: any) => {
let routes; let routes;
if (tabRoute instanceof Array) { if (tabRoute instanceof Array) {
routes = tabRoute.map(itm => { routes = tabRoute
const { navigationOptions, component } = itm || {} .map((itm) => {
return { const { navigationOptions, component } = itm || {};
[itm.name]: { screen: component, navigationOptions }, return {
} [itm.name]: { screen: component, navigationOptions },
}).reduce((pre, current) => { };
return { })
...pre, .reduce((pre, current) => {
...current return {
} ...pre,
}, {}) ...current,
};
}, {});
} else { } else {
routes = { routes = {
[tabRoute.name]: { [tabRoute.name]: {
screen: tabRoute.component, screen: tabRoute.component,
navigationOptions: tabRoute.navigationOptions navigationOptions: tabRoute.navigationOptions,
}, },
} };
} }
return createStackNavigator({ return createStackNavigator({
...routes, ...routes,
}, });
{ };
defaultNavigationOptions: ({navigation}) => {
return {
headerBackAllowFontScaling: false,
headerLeft: headerBack
}
}
})
}
//tabs //tabs
const renderTabs = (tabsConfig: any[]) => { const renderTabs = (tabsConfig: any[]) => {
const tabs = tabsConfig.map(itm => { const tabs = tabsConfig
return itm.children && itm.children.length > 0 ? { .map((itm) => {
[itm.name]: { return itm.children && itm.children.length > 0
screen: renderStack(itm.children), ? {
navigationOptions: itm.navigationOptions [itm.name]: {
} screen: renderStack(itm.children),
} : { navigationOptions: itm.navigationOptions,
[itm.name]: { },
screen: itm.component, }
navigationOptions: itm.navigationOptions : {
} [itm.name]: {
} screen: itm.component,
}).reduce((pre, current) => { navigationOptions: itm.navigationOptions,
return { },
...pre as any, };
...current })
} .reduce((pre, current) => {
}, {})
const TabNavigator = createBottomTabNavigator({
...tabs as any
},
{
defaultNavigationOptions: ({navigation}) => {
return { return {
tabBarVisible: navigation.state.index === 0, ...(pre as any),
} ...current,
} };
}) }, {});
return TabNavigator if (Object.keys(tabs).length > 0) {
} const TabNavigator = createBottomTabNavigator(
{
...(tabs as any),
},
{
defaultNavigationOptions: ({ navigation }) => {
return {
tabBarVisible: navigation.state.index === 0,
};
},
},
);
return TabNavigator;
}
return null;
};
// switch // switch
const renderSwitch = (routerConfig: any) => { const renderSwitch = (rtConfig: any) => {
const switchRoutes = Object.keys(routerConfig).map(key => { const switchRoutes = Object.keys(rtConfig)
return { .map((key) => {
[key]: { const screen =
screen: key === 'tabs' ? renderTabs(routerConfig[key]) : renderStack(routerConfig[key]) key === 'tabs' ? renderTabs(rtConfig[key]) : renderStack(rtConfig[key]);
if (screen) {
return {
[key]: {
screen:
key === 'tabs'
? renderTabs(rtConfig[key])
: renderStack(rtConfig[key]),
},
};
} }
} })
}).reduce((pre, current) => { .reduce((pre, current) => {
return { return {
...pre as any, ...(pre as any),
...current ...current,
} };
}, {}) }, {});
return createSwitchNavigator({ return createSwitchNavigator({
...switchRoutes ...(switchRoutes as any),
}) });
} };
export default createAppContainer(renderSwitch(routerConfig)); export default createAppContainer(renderSwitch(routerConfig));
\ No newline at end of file
import { httpUtil } from "geekbase" import { httpUtil, Toast } from 'geekbase';
// import {getAppConfig} from 'geekbase';
const addOnlineHomeworkImage = '/service-question/online/homework/addOnlineHomeworkImage' // 学生拍照上传 const addOnlineHomeworkImage = '/online/homework/addOnlineHomeworkImage'; // 学生拍照上传
const getOnlineHomeworkImageInfo = '/service-question/online/homework/getOnlineHomeworkImageInfo' // 根据id查询解析后的题目信息 const getOnlineHomeworkImageInfo =
const confirmOnlineHomeworkImageInfo = '/service-question/online/homework/confirmOnlineHomeworkImageInfo' // 保存学生确认后的答题信息 '/service-question/online/homework/getOnlineHomeworkImageInfo'; // 根据id查询解析后的题目信息
const confirmOnlineHomeworkImageInfo =
'/service-question/online/homework/confirmOnlineHomeworkImageInfo'; // 保存学生确认后的答题信息
const getOnlineHomeworkImages =
'/online/homework/getOnlineHomeworkImages'; // 拍题列表
export const addOnlineHomeworkImageInterface = (file: string, studentId: string) => { httpUtil.setRequestInterceptor(
const formData = new FormData() (config) => {
let fileData = { uri: file, type: 'multipart/form-data', name: '' }; console.log('===config: ', config);
formData.append('file', fileData) return {
formData.append('studentId', studentId) ...config,
timeout: 60000,
headers: {
Authorization:
'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOiIyNTk2ODQiLCJ0ZXJtaW5hbCI6InBjIiwidXVpZCI6IjAyNDlhYjFlNTkxOTRjN2JiYmZkMWY3NDM1ODRiM2U5IiwidGltZXN0YW1wIjoxNjAyMTIzNTM5ODExfQ.4mq0VQJcNZDpOycRmqPgd8van6BuJGSvr32kkw8g9X8',
},
};
},
(eror) => {},
);
httpUtil.setResponseInterceptor(null as any, null as any);
export const addOnlineHomeworkImageInterface = (
file: String,
studentId: Number,
) => {
const formData = new FormData();
const name = file.split('/')[file.split('/').length - 1];
let fileData = { uri: file, type: 'multipart/form-data', name };
formData.append('file', fileData);
formData.append('studentId', studentId);
return httpUtil.post(addOnlineHomeworkImage, formData, { return httpUtil.post(addOnlineHomeworkImage, formData, {
headers: { headers: {
"Content-Type": "multipart/form-data", 'Content-Type': 'multipart/form-data',
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOiIyNTk2ODQiLCJ0ZXJtaW5hbCI6InBjIiwidXVpZCI6IjcwNTA0MjdhZjUzZDRkYzU5MGU1ZmU3YmFhNjIxYjY4IiwidGltZXN0YW1wIjoxNjAyMDU4ODMzMDg5fQ.iB3nFIMzAGd327MZDiLdbywaOUyhoEtD2SXi0lzcUbk" },
} });
}) };
}
export const loadOnlineHomeworkImages = () => httpUtil.get(getOnlineHomeworkImages, {});
export const getOnlineHomeworkImageInfoInterface = (id: string) => { export const getOnlineHomeworkImageInfoInterface = (id: string | number) => {
return httpUtil.get(getOnlineHomeworkImageInfo, { params: { id } }) return httpUtil.get(getOnlineHomeworkImageInfo, {
} params: { id },
});
};
export const confirmOnlineHomeworkImageInfoInterface = (params: { export const confirmOnlineHomeworkImageInfoInterface = (params: {
onlineHomeworkImageId: number onlineHomeworkImageId: number;
questionId: number questionId: number;
questionType: string questionType: string;
ownerAnswer: string [] ownerAnswer: string[];
questionUrl: string questionUrl: string;
}) => { }) => {
return httpUtil.post(confirmOnlineHomeworkImageInfo, params, {}) return httpUtil.post(confirmOnlineHomeworkImageInfo, params, {});
} };
\ No newline at end of file
// import { Decimal } from "decimal.js"; // import { Decimal } from "decimal.js";
import DeviceInfo from "react-native-device-info"; import DeviceInfo from 'react-native-device-info';
import { Linking, findNodeHandle, UIManager } from "react-native"; import {Linking, findNodeHandle, UIManager} from 'react-native';
import * as WeChat from "react-native-weixin"; // import * as WeChat from 'react-native-weixin';
import { Toast } from "geekbase"; import {Toast} from 'geekbase';
import { saveBase64Image } from './fileUtil' // import http from '@/http';
import http from "@/http"; import {playWithSeekPos} from 'react-native-player';
import { playWithSeekPos } from "react-native-player";
// classin app 的下载地址 // classin app 的下载地址
const iosClassinAppUrl = const iosClassinAppUrl =
"https://apps.apple.com/cn/app/classin-%E5%9C%A8%E7%BA%BF%E4%BA%92%E5%8A%A8%E6%95%99%E5%AE%A4/id1226361488"; 'https://apps.apple.com/cn/app/classin-%E5%9C%A8%E7%BA%BF%E4%BA%92%E5%8A%A8%E6%95%99%E5%AE%A4/id1226361488';
const androidClassinAppUrl = const androidClassinAppUrl =
"https://profile-1257124244.cos.ap-chengdu.myqcloud.com/app_resource/classin_android_install_3.0.3.2.apk"; 'https://profile-1257124244.cos.ap-chengdu.myqcloud.com/app_resource/classin_android_install_3.0.3.2.apk';
const _operator = { const _operator = {
"+": "add", '+': 'add',
"-": "sub", '-': 'sub',
"*": "mul", '*': 'mul',
"/": "div" '/': 'div',
}; };
const sleep = async duration => { const sleep = async (duration) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
setTimeout(resolve, duration); setTimeout(resolve, duration);
}); });
}; };
const linkClassinApp = url => { const linkClassinApp = (url) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const systemVersion = DeviceInfo.getSystemVersion(); const systemVersion = DeviceInfo.getSystemVersion();
if (systemVersion && parseInt(systemVersion) < 6) { if (systemVersion && parseInt(systemVersion) < 6) {
reject({ reject({
message: message:
"您的手机系统版本小于安卓6.0,无法下载安装。请升级到安卓6.0以上" '您的手机系统版本小于安卓6.0,无法下载安装。请升级到安卓6.0以上',
}); });
return; return;
} }
Linking.canOpenURL(url) Linking.canOpenURL(url)
.then(supported => { .then((supported) => {
const iosDownloadUrl = iosClassinAppUrl; const iosDownloadUrl = iosClassinAppUrl;
const androidDownloadUrl = androidClassinAppUrl; const androidDownloadUrl = androidClassinAppUrl;
const downloadUrl = const downloadUrl =
DeviceInfo.os === "android" ? androidDownloadUrl : iosDownloadUrl; DeviceInfo.os === 'android' ? androidDownloadUrl : iosDownloadUrl;
if (!supported) { if (!supported) {
// 如果没有安装 就弹出下载弹窗 // 如果没有安装 就弹出下载弹窗
console.log("classin app没有安装"); console.log('classin app没有安装');
reject({ reject({
message: "classin app没有安", message: 'classin app没有安',
appUrl: downloadUrl appUrl: downloadUrl,
}); });
} else { } else {
// 跳转到 classin app // 跳转到 classin app
...@@ -55,10 +54,10 @@ const linkClassinApp = url => { ...@@ -55,10 +54,10 @@ const linkClassinApp = url => {
return Linking.openURL(url); return Linking.openURL(url);
} }
}) })
.catch(err => { .catch((err) => {
console.error("classin app 打开报错", err); console.error('classin app 打开报错', err);
reject({ reject({
message: "classin app 打开报错" message: 'classin app 打开报错',
}); });
}); });
}); });
...@@ -73,54 +72,54 @@ const getBoundingRect = (dom, cb) => { ...@@ -73,54 +72,54 @@ const getBoundingRect = (dom, cb) => {
width, width,
height, height,
pageX, pageX,
pageY pageY,
}); });
}); });
}; };
const stringParams = params => { const stringParams = (params) => {
let query = ""; let query = '';
Object.keys(params).forEach(key => { Object.keys(params).forEach((key) => {
const value = params[key]; const value = params[key];
console.log(value); console.log(value);
query = query =
query + query +
"&" + '&' +
key + key +
"=" + '=' +
(typeof value === "string" ? value : JSON.stringify(value)); (typeof value === 'string' ? value : JSON.stringify(value));
}); });
return query.length > 0 ? query.slice(1) : query; return query.length > 0 ? query.slice(1) : query;
}; };
const share = async (data, isTimeLine = false) => { // const share = async (data, isTimeLine = false) => {
try { // try {
Toast.showLoading(); // Toast.showLoading();
let isInstalled = await WeChat.isWXAppInstalled(); // let isInstalled = await WeChat.isWXAppInstalled();
if (isInstalled) { // if (isInstalled) {
let successed = false; // let successed = false;
if (!isTimeLine) { // if (!isTimeLine) {
successed = await WeChat.shareToSession(data); // successed = await WeChat.shareToSession(data);
} else { // } else {
successed = await WeChat.shareToTimeline(data); // successed = await WeChat.shareToTimeline(data);
} // }
Toast.hideLoading(); // Toast.hideLoading();
if (successed) { // if (successed) {
Toast.msg("分享成功"); // Toast.msg('分享成功');
} else { // } else {
Toast.msg("分享失败"); // Toast.msg('分享失败');
} // }
} else { // } else {
Toast.hideLoading(); // Toast.hideLoading();
Toast.warn("没有安装微信,不能分享"); // Toast.warn('没有安装微信,不能分享');
} // }
} catch (error) { // } catch (error) {
Toast.hideLoading(); // Toast.hideLoading();
Toast.msg((error || {}).message ? error.message : error); // Toast.msg((error || {}).message ? error.message : error);
} // }
}; // };
const openUrl = url => { const openUrl = (url) => {
if (Linking.canOpenURL(url)) { if (Linking.canOpenURL(url)) {
Linking.openURL(url); Linking.openURL(url);
} }
...@@ -129,54 +128,57 @@ const openUrl = url => { ...@@ -129,54 +128,57 @@ const openUrl = url => {
/** /**
* @type img | text | news * @type img | text | news
* @data img => {img: base64} , text => { description: '' } , news: { title: string, webpageUrl: url, description: string } * @data img => {img: base64} , text => { description: '' } , news: { title: string, webpageUrl: url, description: string }
* @isTimeline 是否分享到朋友圈 * @isTimeline 是否分享到朋友圈
*/ // */
const shareByWeb = ({ type = 'text', img, ...data } , isTimeline = false) => { // const shareByWeb = ({type = 'text', img, ...data}, isTimeline = false) => {
if (type === 'text' || type === 'news') { // if (type === 'text' || type === 'news') {
const shareData = { // const shareData = {
type, // type,
...data // ...data,
} // };
share({ ...shareData }, isTimeline) // share({...shareData}, isTimeline);
} else { // } else {
saveBase64Image(img, (imgPath, error ) => { // // saveBase64Image(img, (imgPath, error) => {
if (!error) { // // if (!error) {
share({ // // share(
type: 'imageFile', // // {
description: '图片分享', // // type: 'imageFile',
imageUrl: "file://" + imgPath, // // description: '图片分享',
title: '图片分享' // // imageUrl: 'file://' + imgPath,
}, isTimeline) // // title: '图片分享',
} else { // // },
Toast.warn('图片分享失败, 请重试') // // isTimeline,
} // // );
}) // // } else {
} // // Toast.warn('图片分享失败, 请重试');
} // // }
// // });
// }
// };
// 视频播放封装 // 视频播放封装
const playVideo = async (url, cb) => { const playVideo = async (url, cb) => {
const [res, error] = await http.queryVideoPlayTime(url || '') const [res, error] = await http.queryVideoPlayTime(url || '');
console.log(res, error) console.log(res, error);
const { checkValue } = res || {} const {checkValue} = res || {};
const { current, total } = checkValue || {} const {current, total} = checkValue || {};
const currentTime = total > 0 ? (current + 5 > total ? 1 : current) : 1 const currentTime = total > 0 ? (current + 5 > total ? 1 : current) : 1;
playWithSeekPos(url, currentTime, (videoRes) => { playWithSeekPos(url, currentTime, (videoRes) => {
console.log('保存视频回调', videoRes) console.log('保存视频回调', videoRes);
http.saveVideoPlayTime(url, videoRes).then((res) => { http.saveVideoPlayTime(url, videoRes).then((res) => {
console.log('保存视频播放', res) console.log('保存视频播放', res);
}) });
cb && cb(videoRes) cb && cb(videoRes);
}) });
} };
export { export {
sleep, sleep,
linkClassinApp, linkClassinApp,
getBoundingRect, getBoundingRect,
stringParams, stringParams,
share, // share,
openUrl, openUrl,
shareByWeb, // shareByWeb,
playVideo playVideo,
}; };
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@/*": ["./src/*"] "@/*": ["./src/*"]
} },
}, },
"exclude": [ "exclude": [
"node_modules", "node_modules",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment