Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GeekTeacherWork
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huanglu
GeekTeacherWork
Commits
68ac68b2
Commit
68ac68b2
authored
Nov 24, 2020
by
huanglu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 在线作业
parent
0093a090
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
872 additions
and
671 deletions
+872
-671
.eslintrc.js
.eslintrc.js
+5
-0
.prettierrc.js
.prettierrc.js
+2
-2
babel.config.js
babel.config.js
+10
-9
GeekWorkPicker.m
ios/GeekTeacherWork/GeekPicture/GeekWorkPicker.m
+2
-5
Podfile
ios/Podfile
+1
-0
Podfile.lock
ios/Podfile.lock
+31
-18
package.json
package.json
+10
-11
App.tsx
src/App.tsx
+28
-22
index.js
src/components/webview/index.js
+19
-20
index.ts
src/config/index.ts
+42
-42
index.ts
src/hooks/index.ts
+24
-75
index.ts
src/models/index.ts
+6
-4
index.ts
src/navigate/index.ts
+30
-26
index.tsx
src/pages/geek-correct-list/index.tsx
+125
-0
model.ts
src/pages/geek-correct-list/model.ts
+44
-0
bg.png
src/pages/geek-home/assets/bg.png
+0
-0
index.ts
src/pages/geek-home/assets/index.ts
+6
-0
index.tsx
src/pages/geek-home/index.tsx
+77
-24
index.tsx
src/pages/geek-login/index.tsx
+10
-11
index.tsx
src/pages/geek-splash/index.tsx
+1
-1
index.js
src/pages/geek-webview/index.js
+64
-66
index.ts
src/rn-module/index.ts
+0
-0
index.ts
src/rn-module/work-correct/index.ts
+0
-42
config.ts
src/router/config.ts
+28
-34
constant.tsx
src/router/constant.tsx
+71
-61
index.tsx
src/router/index.tsx
+85
-76
index.ts
src/service/index.ts
+52
-25
index.js
src/utils/index.js
+98
-96
tsconfig.json
tsconfig.json
+1
-1
yarn.lock
yarn.lock
+0
-0
No files found.
.eslintrc.js
View file @
68ac68b2
module
.
exports
=
{
root
:
true
,
extends
:
'@react-native-community'
,
rules
:
{
'react-hooks/exhaustive-deps'
:
0
,
'react-native/no-inline-styles'
:
0
,
'prettier/prettier'
:
0
,
},
};
.prettierrc.js
View file @
68ac68b2
module
.
exports
=
{
bracketSpacing
:
fals
e
,
bracketSpacing
:
tru
e
,
jsxBracketSameLine
:
true
,
singleQuote
:
true
,
trailingComma
:
'all'
,
trailingComma
:
'all'
};
babel.config.js
View file @
68ac68b2
...
...
@@ -2,15 +2,16 @@ module.exports = {
presets
:
[
'module:metro-react-native-babel-preset'
],
plugins
:
[
[
"babel-plugin-root-import"
,
'babel-plugin-root-import'
,
{
"paths"
:
[
paths
:
[
{
"rootPathSuffix"
:
"./src/"
,
"rootPathPrefix"
:
"@/"
}
]
}
]
]
rootPathSuffix
:
'./src/'
,
rootPathPrefix
:
'@/'
,
},
],
},
],
[
'import'
,
{
libraryName
:
'@ant-design/react-native'
}],
// 与 Web 平台的区别是不需要设置 style
],
};
ios/GeekTeacherWork/GeekPicture/GeekWorkPicker.m
View file @
68ac68b2
...
...
@@ -25,7 +25,7 @@
RCT_EXPORT_MODULE
();
RCT_EXPORT_METHOD
(
openWorkPicker
)
{
[
self
showPicker
];
//
[self showPicker];
}
...
...
@@ -52,12 +52,9 @@ RCT_EXPORT_METHOD(showWorkResult:(NSString *)imageUrl
}
-
(
void
)
showPicker
{
-
(
void
)
showPicker
:
(
NSString
*
)
imageUrl
{
self
.
picker
=
[[
GeekCameraVC
alloc
]
init
];
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
];
self
.
picker
.
imageBlock
=
^
(
UIImage
*
_Nonnull
image
)
{
NSString
*
imgPath
=
[
GeekUtil
saveImageTosandBox
:
image
];
...
...
ios/Podfile
View file @
68ac68b2
...
...
@@ -38,6 +38,7 @@ target 'GeekTeacherWork' do
pod
"Masonry"
pod
"SVProgressHUD"
pod
"LCActionSheet"
pod
'SDWebImage'
target
'GeekTeacherWorkTests'
do
inherit!
:search_paths
...
...
ios/Podfile.lock
View file @
68ac68b2
...
...
@@ -202,12 +202,14 @@ PODS:
- React-cxxreact (= 0.61.5)
- React-jsi (= 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-native-version-number (0.3.6):
- React
- react-native-viewpager (3.3.1):
- React
- react-native-webview (10.10.2):
- React-Core
- React-RCTActionSheet (0.61.5):
- React-Core/RCTActionSheetHeaders (= 0.61.5)
- React-RCTAnimation (0.61.5):
...
...
@@ -247,20 +249,22 @@ PODS:
- React
- rn-fetch-blob (0.12.0):
- React-Core
- RNCAsyncStorage (1.12.
0
):
- React
- RNCAsyncStorage (1.12.
1
):
- React
-Core
- RNCMaskedView (0.1.10):
- React
- RNFastImage (8.3.2):
- React
- RNDeviceInfo (7.0.2):
- React-Core
- RNFastImage (8.3.4):
- React-Core
- SDWebImage (~> 5.8)
- SDWebImageWebPCoder (~> 0.6.1)
- RNGestureHandler (1.8.0):
- React
- RNReanimated (1.13.1):
- React
- RNScreens (2.1
1
.0):
- React
- RNScreens (2.1
4
.0):
- React
-Core
- SDWebImage (5.9.0):
- SDWebImage/Core (= 5.9.0)
- SDWebImage/Core (5.9.0)
...
...
@@ -292,9 +296,10 @@ DEPENDENCIES:
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- 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-version-number (from `../node_modules/react-native-version-number`)
- "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-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
- React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`)
...
...
@@ -310,10 +315,12 @@ DEPENDENCIES:
- rn-fetch-blob (from `../node_modules/rn-fetch-blob`)
- "RNCAsyncStorage (from `../node_modules/@react-native-community/async-storage`)"
- "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`)
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNReanimated (from `../node_modules/react-native-reanimated`)
- RNScreens (from `../node_modules/react-native-screens`)
- SDWebImage
- SVProgressHUD
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
- YYModel
...
...
@@ -363,12 +370,14 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsiexecutor"
React-jsinspector:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
react-native-image-picker:
:path: "../node_modules/react-native-image-picker"
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:
:path: "../node_modules/@react-native-community/viewpager"
react-native-webview:
:path: "../node_modules/react-native-webview"
React-RCTActionSheet:
:path: "../node_modules/react-native/Libraries/ActionSheetIOS"
React-RCTAnimation:
...
...
@@ -397,6 +406,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@react-native-community/async-storage"
RNCMaskedView:
:path: "../node_modules/@react-native-community/masked-view"
RNDeviceInfo:
:path: "../node_modules/react-native-device-info"
RNFastImage:
:path: "../node_modules/react-native-fast-image"
RNGestureHandler:
...
...
@@ -430,9 +441,10 @@ SPEC CHECKSUMS:
React-jsi: cb2cd74d7ccf4cffb071a46833613edc79cdf8f7
React-jsiexecutor: d5525f9ed5f782fdbacb64b9b01a43a9323d2386
React-jsinspector: fa0ecc501688c3c4c34f28834a76302233e29dc0
react-native-
safe-area-context: 79fea126c6830c85f65947c223a5e3058a666937
react-native-
version-number: b415bbec6a13f2df62bf978e85bc0d699462f37f
react-native-
image-picker: c6d75c4ab2cf46f9289f341242b219cb3c1180d3
react-native-
safe-area-context: b6e0e284002381d2ff29fa4fff42b4d8282e3c94
react-native-viewpager: f730c1d175a2c1ae789464855d4a2c14247d3109
react-native-webview: 0aa2cde4ee7e3e1c5fffdf64dbce9c709aa18155
React-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76
React-RCTAnimation: 791a87558389c80908ed06cc5dfc5e7920dfa360
React-RCTBlob: d89293cc0236d9cb0933d85e430b0bbe81ad1d72
...
...
@@ -445,12 +457,13 @@ SPEC CHECKSUMS:
ReactCommon: 198c7c8d3591f975e5431bec1b0b3b581aa1c5dd
ReactNativeART: 78edc68dd4a1e675338cd0cd113319cf3a65f2ab
rn-fetch-blob: f065bb7ab7fb48dd002629f8bdcb0336602d3cba
RNCAsyncStorage:
2a692bcb9b69b76a2f1a95f33db057129700af64
RNCAsyncStorage:
b03032fdbdb725bea0bd9e5ec5a7272865ae7398
RNCMaskedView: 5a8ec07677aa885546a0d98da336457e2bea557f
RNFastImage: e19ba191922e7dab9d932a4d59d62d76660aa222
RNDeviceInfo: e1d82a27d0c1ea6278e3b141784dc38e51fc90f4
RNFastImage: d4870d58f5936111c56218dbd7fcfc18e65b58ff
RNGestureHandler: 7a5833d0f788dbd107fbb913e09aa0c1ff333c39
RNReanimated: dd8c286ab5dd4ba36d3a7fef8bff7e08711b5476
RNScreens:
0e91da98ab26d5d04c7b59a9b6bd694124caf88c
RNScreens:
2e278a90eb15092ed261d4f2271e3fc9b60d08d4
SDWebImage: 62ae4a18473520c67b79e9724c31a63599cc9423
SDWebImageWebPCoder: d0dac55073088d24b2ac1b191a71a8f8d0adac21
SSZipArchive: 62d4947b08730e4cda640473b0066d209ff033c9
...
...
@@ -458,6 +471,6 @@ SPEC CHECKSUMS:
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b
YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30
PODFILE CHECKSUM:
8b8a582a803563a2f2d3eaff4db0254084a15277
PODFILE CHECKSUM:
aee9cbf12b10829e7ccb4373a4dd99bc0d5a3710
COCOAPODS: 1.9.1
package.json
View file @
68ac68b2
...
...
@@ -16,31 +16,29 @@
"build-android"
:
"cd android && ./gradlew assembleRelease"
},
"dependencies"
:
{
"
@
geek/request
"
:
"^1.0.0
"
,
"
@
ant-design/react-native
"
:
"^4.0.5
"
,
"
@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/viewpager
"
:
"^3.3.0"
,
"
geekbase
"
:
"
https://dev.jiuaoedu.com/sunzheng/geekbase.git#v2.1.4
"
,
"
geekbase
"
:
"
^2.0.2
"
,
"
react
"
:
"16.9.0"
,
"
react-native
"
:
"0.61.5"
,
"
react-native-code-push
"
:
"
https://dev.jiuaoedu.com/sunzheng/react-native-code-push.git
"
,
"
react-native-
extra-dimensions-android
"
:
"^1.2.5
"
,
"
react-native-fast-image
"
:
"^8.3.
2
"
,
"
react-native-
device-info
"
:
"^7.0.2
"
,
"
react-native-fast-image
"
:
"^8.3.
4
"
,
"
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-refresh-list-view
"
:
"^1.0.12"
,
"
react-native-root-siblings
"
:
"^4.0.6"
,
"
react-native-safe-area-context
"
:
"^3.1.7"
,
"
react-native-screens
"
:
"^2.10.1"
,
"
react-native-
scrollable-tab-view
"
:
"^1.0
.0"
,
"
react-native-
version-number
"
:
"^0.3.6
"
,
"
react-native-
tbswebview
"
:
"
https://dev.jiuaoedu.com/sunzheng/react-native-tbswebview.git#v1.1
.0
"
,
"
react-native-
webview
"
:
"^10.10.2
"
,
"
react-navigation
"
:
"^4.4.0"
,
"
react-navigation-stack
"
:
"^2.8.2"
,
"
react-navigation-tabs
"
:
"^2.9.0"
,
"
react-redux
"
:
"^7.2.1"
,
"
rn-fetch-blob
"
:
"
https://dev.jiuaoedu.com/sunzheng/rn-fetch-blob.git
"
"
rn-fetch-blob
"
:
"^0.12.0"
},
"devDependencies"
:
{
"
@babel/core
"
:
"^7.11.6"
,
...
...
@@ -51,6 +49,7 @@
"
@types/react-native
"
:
"^0.63.18"
,
"
@types/react-test-renderer
"
:
"^16.9.3"
,
"
babel-jest
"
:
"^26.3.0"
,
"
babel-plugin-import
"
:
"^1.13.1"
,
"
babel-plugin-root-import
"
:
"^6.5.0"
,
"
eslint
"
:
"^7.9.0"
,
"
metro-react-native-babel-preset
"
:
"^0.63.0"
,
...
...
src/App.tsx
View file @
68ac68b2
import
React
,
{
useEffect
}
from
'react'
;
import
{
AppState
,
AppStateStatus
}
from
'react-native'
import
AppContainer
from
'./router'
import
{
GeekAppModals
,
store
,
appModel
,
Toast
,
navigationService
}
from
'geekbase'
import
{
StoreProvider
,
createStore
}
from
'easy-peasy'
import
{
AppState
,
AppStateStatus
}
from
'react-native'
;
import
AppContainer
from
'./router'
;
import
models
from
'@/models'
;
import
{
GeekAppModals
,
store
,
Toast
,
navigationService
}
from
'geekbase'
;
import
{
StoreProvider
,
createStore
}
from
'easy-peasy'
;
import
{
Provider
}
from
'@ant-design/react-native'
;
store
.
store
=
createStore
({
...
appModel
})
...
models
,
})
;
export
default
function
App
()
{
useEffect
(()
=>
{
console
.
log
(
'--app进入'
)
console
.
log
(
'App'
,
'注册微信'
)
AppState
.
addEventListener
(
'change'
,
handleAppStateChange
)
console
.
log
(
'--app进入'
)
;
console
.
log
(
'App'
,
'注册微信'
)
;
AppState
.
addEventListener
(
'change'
,
handleAppStateChange
)
;
return
()
=>
{
AppState
.
removeEventListener
(
'change'
,
handleAppStateChange
)
}
},
[])
AppState
.
removeEventListener
(
'change'
,
handleAppStateChange
)
;
}
;
},
[])
;
const
handleAppStateChange
=
(
appState
:
AppStateStatus
)
=>
{
console
.
log
(
'当前app状态'
,
appState
)
const
handleAppStateChange
=
(
appState
:
AppStateStatus
)
=>
{
console
.
log
(
'当前app状态'
,
appState
)
;
if
(
appState
===
'background'
)
{
Toast
.
hideLoading
()
Toast
.
hideLoading
()
;
}
}
}
;
return
(
<
StoreProvider
store=
{
store
.
store
}
>
<
AppContainer
ref=
{
navigatorRef
=>
{
navigationService
.
setTopLevelNavigator
(
navigatorRef
)
}
}
/>
<
GeekAppModals
/>
</
StoreProvider
>
<
Provider
>
<
StoreProvider
store=
{
store
.
store
}
>
<
AppContainer
ref=
{
(
navigatorRef
)
=>
{
navigationService
.
setTopLevelNavigator
(
navigatorRef
);
}
}
/>
<
GeekAppModals
/>
</
StoreProvider
>
</
Provider
>
);
}
src/components/webview/index.js
View file @
68ac68b2
/* eslint-disable react/prop-types */
import
React
,
{
useEffect
,
useState
,
useImperativeHandle
,
useRef
}
from
"react"
;
import
{
View
}
from
"react-native"
;
import
WebView
from
"react-native-webview"
;
import
{
X5WebView
}
from
"react-native-tbswebview"
;
import
{
device
}
from
"geekbase"
;
import
React
,
{
useEffect
,
useState
,
useImperativeHandle
,
useRef
}
from
'react'
;
import
{
View
}
from
'react-native'
;
import
WebView
from
'react-native-webview'
;
import
{
X5WebView
}
from
'react-native-tbswebview'
;
import
{
device
}
from
'geekbase'
;
/**
* 极客webview
...
...
@@ -23,7 +22,7 @@ export const GeekWebView = React.forwardRef((props, ref) => {
onTitle
,
renderLoading
,
onPlayVideo
,
onLog
onLog
,
}
=
props
;
const
[
url
,
setUrl
]
=
useState
(
uri
);
const
webViewRef
=
useRef
(
null
);
...
...
@@ -32,25 +31,25 @@ export const GeekWebView = React.forwardRef((props, ref) => {
const
handleMessage
=
(
event
)
=>
{
const
data
=
device
.
os
===
"ios"
?
JSON
.
parse
(
event
.
nativeEvent
.
data
)
:
JSON
.
parse
(
event
.
data
);
if
(
data
.
type
===
"share"
)
{
device
.
os
===
'ios'
?
JSON
.
parse
(
event
.
nativeEvent
.
data
)
:
JSON
.
parse
(
event
.
data
);
if
(
data
.
type
===
'share'
)
{
onShare
&&
onShare
(
data
.
data
);
return
;
}
if
(
data
.
type
===
"shareTimeline"
)
{
if
(
data
.
type
===
'shareTimeline'
)
{
onShareTimeline
&&
onShareTimeline
(
data
.
data
);
return
;
}
if
(
data
.
type
===
"title"
)
{
if
(
data
.
type
===
'title'
)
{
onTitle
&&
onTitle
(
data
.
data
);
return
;
}
if
(
data
.
type
===
'video'
)
{
console
.
log
(
'play'
,
data
)
onPlayVideo
&&
onPlayVideo
(
data
.
data
)
console
.
log
(
'play'
,
data
)
;
onPlayVideo
&&
onPlayVideo
(
data
.
data
)
;
}
if
(
data
.
type
===
'log'
)
{
onLog
&&
onLog
(
data
.
data
)
onLog
&&
onLog
(
data
.
data
)
;
}
onMessage
(
data
);
};
...
...
@@ -62,7 +61,7 @@ export const GeekWebView = React.forwardRef((props, ref) => {
[
uri
,
useToken
]
);
const
excuteJSMethod
=
({
method
=
""
,
data
=
""
})
=>
{
const
excuteJSMethod
=
({
method
=
''
,
data
=
''
})
=>
{
const
params
=
JSON
.
stringify
({
method
,
data
});
if
(
webViewRef
.
current
)
{
webViewRef
.
current
.
injectJavaScript
(
`window.$geek_excuteJS('
${
params
}
')`
);
...
...
@@ -100,8 +99,8 @@ export const GeekWebView = React.forwardRef((props, ref) => {
}));
return
(
<
View
style
=
{{
flex
:
1
,
width
:
"100%"
,
backgroundColor
:
"red"
,
...
style
}}
>
{
device
.
os
===
"ios"
&&
(
<
View
style
=
{{
flex
:
1
,
width
:
'100%'
,
backgroundColor
:
'red'
,
...
style
}}
>
{
device
.
os
===
'ios'
&&
(
<
WebView
showsHorizontalScrollIndicator
=
{
false
}
showsVerticalScrollIndicator
=
{
false
}
...
...
@@ -110,7 +109,7 @@ export const GeekWebView = React.forwardRef((props, ref) => {
style
=
{{
flex
:
1
}}
source
=
{{
uri
:
url
}}
onMessage
=
{
handleMessage
}
originWhitelist
=
{[
"*"
]}
originWhitelist
=
{[
'*'
]}
useWebKit
=
{
true
}
startInLoadingState
=
{
true
}
renderLoading
=
{
renderLoading
}
...
...
@@ -121,7 +120,7 @@ export const GeekWebView = React.forwardRef((props, ref) => {
}}
/
>
)}
{
device
.
os
===
"android"
&&
(
{
device
.
os
===
'android'
&&
(
<>
<
X5WebView
ref
=
{
webViewRef
}
...
...
@@ -139,7 +138,7 @@ export const GeekWebView = React.forwardRef((props, ref) => {
}}
style
=
{{
flex
:
1
}}
onMessage
=
{(
data
)
=>
{
console
.
log
(
'onMessage : '
,
data
)
console
.
log
(
'onMessage : '
,
data
)
;
const
nativeData
=
JSON
.
parse
(
data
);
handleMessage
(
nativeData
);
}}
...
...
src/config/index.ts
View file @
68ac68b2
const
Config
=
{
// appConfigUrl: 'https://profile-1257124244.cos.ap-chengdu.myqcloud.com/app_resource/geek_math_app_config.json',
appConfigUrl
:
'jj'
,
//填写配置文件路径
AppConfig
:
{
weChatCode
:
''
,
universalLink
:
''
,
timeout
:
15000
,
// 生产
baseUrl
:
__DEV__
?
'http://192.168.32.37:3000'
:
'https://geek.jkwljy.com'
,
stopServer
:
{
stop
:
false
,
description
:
'暂时停服'
},
appVersion
:
{
// 最新的系统版本【不是热更新版本!!!,而是上架应用商店的APP最新版本】
ios
:
{
versionNumber
:
"1.0"
,
versionDescription
:
"测试ios"
,
isMandatory
:
false
,
appStoreUrl
:
"111"
// ios下载路径
},
android
:
{
versionNumber
:
"1.0"
,
versionDescription
:
"测试android"
,
isMandatory
:
false
,
apkUrl
:
"111"
// Android下载路径
}
},
codePush
:
{
open
:
true
,
isRelease
:
true
,
ios
:
{
releaseKey
:
"IPIj65rPV5R4EIYYioZGNtazsufY4ksvOXqog"
,
stagingKey
:
"c5XU3KTuISEnHAtAA0IRx3e4ejV14ksvOXqog"
},
android
:
{
releaseKey
:
"UWQrx8vNd4uWeE4EgGH42HTTXNRM4ksvOXqog"
,
stagingKey
:
"T22PvpZAdiwpmzNw27qxIVqLPEHS4ksvOXqog"
}
},
}
}
// appConfigUrl: 'https://profile-1257124244.cos.ap-chengdu.myqcloud.com/app_resource/geek_math_app_config.json',
appConfigUrl
:
'jj'
,
//填写配置文件路径
AppConfig
:
{
weChatCode
:
''
,
universalLink
:
''
,
timeout
:
15000
,
// 生产
baseUrl
:
__DEV__
?
'http://192.168.44.93:8400'
:
'https://geek.jkwljy.com'
,
stopServer
:
{
stop
:
false
,
description
:
'暂时停服'
,
},
appVersion
:
{
// 最新的系统版本【不是热更新版本!!!,而是上架应用商店的APP最新版本】
ios
:
{
versionNumber
:
'1.0'
,
versionDescription
:
'测试ios'
,
isMandatory
:
false
,
appStoreUrl
:
'111'
,
// ios下载路径
},
android
:
{
versionNumber
:
'1.0'
,
versionDescription
:
'测试android'
,
isMandatory
:
false
,
apkUrl
:
'111'
,
// Android下载路径
},
},
codePush
:
{
open
:
true
,
isRelease
:
true
,
ios
:
{
releaseKey
:
'IPIj65rPV5R4EIYYioZGNtazsufY4ksvOXqog'
,
stagingKey
:
'c5XU3KTuISEnHAtAA0IRx3e4ejV14ksvOXqog'
,
},
android
:
{
releaseKey
:
'UWQrx8vNd4uWeE4EgGH42HTTXNRM4ksvOXqog'
,
stagingKey
:
'T22PvpZAdiwpmzNw27qxIVqLPEHS4ksvOXqog'
,
},
},
},
};
export
default
Config
\ No newline at end of file
export
default
Config
;
src/hooks/index.ts
View file @
68ac68b2
import
{
useEffect
,
useState
,
useLayoutEffect
}
from
'react'
;
import
{
NavigationStackProp
}
from
'react-navigation-stack'
;
import
{
StatusBar
}
from
'react-native'
;
import
{
device
}
from
'geekbase'
;
import
{
StackNavigationOptions
}
from
'react-navigation-stack/lib/typescript/src/vendor/types'
;
import
{
navigationOptions
}
from
'@/router/constant'
;
import
{
useEffect
}
from
'react'
;
import
{
NavigationStackProp
}
from
'react-navigation-stack'
;
import
{
StackNavigationOptions
}
from
'react-navigation-stack/lib/typescript/src/vendor/types'
;
import
{
createTypedHooks
}
from
'easy-peasy'
;
import
StoreModels
from
'@/models'
import
StoreModels
from
'@/models'
;
import
{
navigationOptions
}
from
'@/router/constant'
;
import
{
NavigationScreenProp
}
from
'react-navigation'
;
// 路由进入时hook
export
const
useStackFocus
=
(
navigation
:
NavigationStackProp
<
{
name
:
string
}
>
,
navigation
:
NavigationStackProp
<
{
name
:
string
}
>
,
cb
:
Function
,
)
=>
{
function
handleFocus
()
{
...
...
@@ -39,77 +38,27 @@ export const useStackBlur = (
},
[]);
};
export
function
useFocusBlur
(
navigation
:
NavigationStackProp
)
{
const
[
isFocus
,
setIsFocus
]
=
useState
(
false
);
const
[
isBlur
,
setIsBlur
]
=
useState
(
false
);
// 第二个参数如果为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
]);
}
type
StackConfigParam
<
S
,
P
>
=
(
args
:
{
navigation
:
NavigationScreenProp
<
S
,
P
>
;
})
=>
StackNavigationOptions
;
export
const
withStackScreen
=
(
Wrapp
:
React
.
ReactNode
,
config
:
StackNavigationOptions
,
config
:
StackNavigationOptions
|
StackConfigParam
<
any
,
any
>
,
)
=>
{
(
Wrapp
as
any
).
navigationOptions
=
{
...
navigationOptions
,
...
config
,
};
(
Wrapp
as
any
).
navigationOptions
=
typeof
config
===
'function'
?
(
args
:
any
)
=>
({
...(
config
(
args
)
||
{}),
...
navigationOptions
})
:
{
...
navigationOptions
,
...
config
,
};
return
Wrapp
;
};
export
const
{
useStoreActions
,
useStoreState
,
useStoreDispatch
,
useStore
}
=
createTypedHooks
<
typeof
StoreModels
>
()
export
const
{
useStoreActions
,
useStoreState
,
useStoreDispatch
,
useStore
,
}
=
createTypedHooks
<
typeof
StoreModels
>
();
src/models/index.ts
View file @
68ac68b2
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
)
\ No newline at end of file
export
default
{
...
appModel
,
correctModels
,
};
src/navigate/index.ts
View file @
68ac68b2
import
React
from
'react'
import
{
navigationService
,
getAppConfig
}
from
'geekbase'
import
cache
from
'@/cache'
import
{
navigationService
,
getAppConfig
}
from
'geekbase'
;
import
cache
from
'@/cache'
;
export
default
{
/**
* 去webview页面
* @param {uri, useToken, initTitle, onMessage } props
*/
navigateGeekWebViewPage
(
props
:
{
uri
:
string
,
useToken
:
boolean
,
initTitle
:
string
,
onMessage
:
Function
uri
:
string
;
useToken
?:
boolean
;
initTitle
?:
string
;
onMessage
?:
Function
;
})
{
const
{
uri
,
useToken
,
...
others
}
=
props
let
url
=
uri
const
{
uri
,
useToken
,
...
others
}
=
props
;
let
url
=
uri
;
if
(
useToken
)
{
cache
.
getToken
().
then
((
token
:
string
)
=>
{
if
(
url
.
indexOf
(
"?"
)
!==
-
1
)
{
if
(
url
[
uri
.
length
-
1
]
===
"&"
)
{
if
(
url
.
indexOf
(
'?'
)
!==
-
1
)
{
if
(
url
[
uri
.
length
-
1
]
===
'&'
)
{
url
=
`
${
url
}
token=
${
token
}
`
;
}
else
{
url
=
`
${
url
}
&token=
${
token
}
`
;
...
...
@@ -27,25 +25,32 @@ export default {
}
else
{
url
=
`
${
url
}
?token=
${
token
}
`
;
}
navigationService
.
navigate
(
'GeekWebViewPage'
,
{
uri
:
/^https
?
:
\/\/
/g
.
test
(
url
)
?
url
:
`
${
getAppConfig
().
baseUrl
}${
url
}
`
,
...
others
})
navigationService
.
navigate
(
'GeekWebView'
,
{
uri
:
/^https
?
:
\/\/
/g
.
test
(
url
)
?
url
:
`
${
getAppConfig
().
baseUrl
}${
url
}
`
,
...
others
,
});
});
}
else
{
navigationService
.
navigate
(
'GeekWebViewPage'
,
{
uri
:
/^https
?
:
\/\/
/g
.
test
(
url
)
?
url
:
`
${
getAppConfig
().
baseUrl
}${
url
}
`
,
...
others
})
navigationService
.
navigate
(
'GeekWebView'
,
{
uri
:
/^https
?
:
\/\/
/g
.
test
(
url
)
?
url
:
`
${
getAppConfig
().
baseUrl
}${
url
}
`
,
...
others
,
});
}
},
navigateAbout
:
()
=>
{
navigationService
.
navigate
(
'About'
)
navigationService
.
navigate
(
'About'
)
;
},
navigateAuth
:
()
=>
{
navigationService
.
navigate
(
'auth'
)
navigationService
.
navigate
(
'auth'
);
},
navigateCorrectList
:
()
=>
{
navigationService
.
navigate
(
'CorrectList'
);
},
}
\ No newline at end of file
};
src/pages/geek-correct-list/index.tsx
0 → 100644
View file @
68ac68b2
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
;
src/pages/geek-correct-list/model.ts
0 → 100644
View file @
68ac68b2
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
);
}
}),
};
src/pages/geek-home/assets/bg.png
0 → 100755
View file @
68ac68b2
494 KB
src/pages/geek-home/assets/index.ts
0 → 100644
View file @
68ac68b2
import
bgImg
from
'./bg.png'
export
{
bgImg
}
\ No newline at end of file
src/pages/geek-home/index.tsx
View file @
68ac68b2
import
React
,
{
useEffect
,
useState
}
from
'react'
import
{
View
,
Text
}
from
"react-native"
;
import
{
TouchableHighlight
}
from
'react-native-gesture-handler'
;
/* eslint-disable react-native/no-inline-styles */
import
React
,
{
useCallback
,
useEffect
}
from
'react'
;
import
{
View
,
ImageBackground
,
StyleSheet
,
Text
,
TouchableHighlight
,
}
from
'react-native'
;
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
=
()
=>
{
}
return
(
<
View
style=
{
{
flex
:
1
}
}
>
<
TouchableHighlight
onPress=
{
()
=>
{
showWorkPicker
(
123
)
}
}
>
<
View
>
<
Text
style=
{
{
height
:
60
,
backgroundColor
:
'blue'
}
}
>
tap ll
</
Text
>
<
Text
style=
{
{
height
:
60
,
backgroundColor
:
'blue'
}
}
>
tap ll
</
Text
>
</
View
>
</
TouchableHighlight
>
const
toCorrect
=
useCallback
(()
=>
{
navigate
.
navigateCorrectList
();
},
[]);
return
(
<
ImageBackground
source=
{
bgImg
}
style=
{
styles
.
bgStyle
}
>
<
SafeAreaView
style=
{
{
flex
:
1
}
}
>
<
View
style=
{
styles
.
functionalArea
}
>
<
TouchableHighlight
onPress=
{
()
=>
{
toCorrect
();
}
}
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
>
)
}
</
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
,
{
headerTitle
:
'kkkkkkk'
})
\ No newline at end of file
header
:
()
=>
null
,
});
src/pages/geek-login/index.tsx
View file @
68ac68b2
import
React
from
'react'
import
{
View
,
Text
}
from
'react-native'
import
{
TouchableOpacity
}
from
'react-native-gesture-handler'
import
navigate
from
'@/navigate'
import
React
from
'react'
;
import
{
View
,
Text
}
from
'react-native'
;
import
{
TouchableOpacity
}
from
'react-native-gesture-handler'
;
import
{
navigationService
}
from
'geekbase'
;
export
default
()
=>
{
return
(
<
View
>
<
Text
>
this is login page
</
Text
>
<
TouchableOpacity
onPress=
{
()
=>
{
navigate
.
navigateAbout
()
}
}
>
<
TouchableOpacity
onPress=
{
()
=>
{
navigationService
.
navigate
(
'home'
);
}
}
>
<
Text
>
home
</
Text
>
</
TouchableOpacity
>
</
View
>
)
}
\ No newline at end of file
);
};
src/pages/geek-splash/index.tsx
View file @
68ac68b2
...
...
@@ -18,7 +18,7 @@ function SplashPage(props: any) {
useEffect
(()
=>
{
if
(
!
appConfigFinish
)
return
navigationService
.
navigate
(
'
TH
ome'
)
navigationService
.
navigate
(
'
h
ome'
)
},
[
appConfigFinish
])
...
...
src/pages/geek-webview/index.js
View file @
68ac68b2
/* eslint-disable react/prop-types */
import
React
,
{
useEffect
,
useRef
,
useState
}
from
"react"
;
import
React
,
{
useEffect
,
useRef
,
useState
}
from
'react'
;
import
{
View
,
StyleSheet
,
...
...
@@ -7,23 +6,20 @@ import {
TouchableWithoutFeedback
,
Image
,
ActivityIndicator
,
}
from
"react-native"
;
import
{
device
,
rpx
}
from
"geekbase"
;
import
{
useFocusBlur
,
useStatusBar
,
navigationOptions
}
from
"@/appbase"
;
import
{
colors
}
from
"@/assets"
;
import
{
back
}
from
"./assets"
;
import
{
GeekWebView
}
from
"@/components"
;
import
{
shareByWeb
}
from
"@/utils"
;
import
*
as
utils
from
'@/utils'
SafeAreaView
,
}
from
'react-native'
;
import
{
device
,
rpx
,
useFocusBlur
,
useStatusBar
}
from
'geekbase'
;
import
{
back
}
from
'./assets'
;
import
{
GeekWebView
}
from
'@/components'
;
import
{
navigationOptions
}
from
'@/router/constant'
;
function
GeekWebViewPage
(
props
)
{
const
uri
=
props
.
navigation
.
getParam
(
"uri"
);
const
useToken
=
props
.
navigation
.
getParam
(
"useToken"
);
const
onMessage
=
props
.
navigation
.
getParam
(
"onMessage"
);
const
uri
=
props
.
navigation
.
getParam
(
'uri'
);
const
onMessage
=
props
.
navigation
.
getParam
(
'onMessage'
);
const
webviewRef
=
useRef
();
const
[
url
,
setUrl
]
=
useState
(
uri
);
const
[
url
]
=
useState
(
uri
);
const
{
isFocus
}
=
useFocusBlur
(
props
.
navigation
);
useStatusBar
(
isFocus
,
true
,
"black"
);
useStatusBar
(
isFocus
,
true
,
'black'
);
// 返回逻辑
...
...
@@ -41,88 +37,90 @@ function GeekWebViewPage(props) {
};
const
onTitle
=
(
title
)
=>
{
const
initTitle
=
props
.
navigation
.
getParam
(
"initTitle"
);
const
initTitle
=
props
.
navigation
.
getParam
(
'initTitle'
);
props
.
navigation
.
setParams
({
title
:
title
||
initTitle
});
};
const
handleMessage
=
(
event
)
=>
{
if
(
onMessage
)
{
onMessage
(
event
)
onMessage
(
event
)
;
}
};
// 分享逻辑
const
handleShare
=
(
data
)
=>
{
shareByWeb
(
data
);
//
shareByWeb(data);
};
// 分享朋友圈
const
handleShareTimeline
=
(
data
)
=>
{
console
.
log
(
"onShareTimeline"
);
shareByWeb
(
data
,
true
);
console
.
log
(
'onShareTimeline'
);
//
shareByWeb(data, true);
};
// 播放视频
// eslint-disable-next-line no-shadow
const
playVideo
=
({
url
})
=>
{
utils
.
playVideo
(
url
,
(
result
)
=>
{
setTimeout
(()
=>
{
webviewRef
.
current
&&
webviewRef
.
current
.
excuteJSMethod
({
method
:
'uploadPlayInfo'
,
data
:
result
})
},
500
);
})
}
//
utils.playVideo(url, (result) => {
//
setTimeout(() => {
//
webviewRef.current && webviewRef.current.excuteJSMethod({
//
method: 'uploadPlayInfo',
// data: result,
// });
//
}, 500);
// });
}
;
// h5 的log日志
const
handleLog
=
(
args
)
=>
{
if
(
__DEV__
)
{
console
.
log
(
'H5 LOG: '
,
args
)
console
.
log
(
'H5 LOG: '
,
args
)
;
}
}
}
;
useEffect
(()
=>
{
const
backEffect
=
()
=>
{
onBack
();
return
true
;
}
if
(
device
.
os
===
"android"
)
{
}
;
if
(
device
.
os
===
'android'
)
{
// 针对安卓的实体返回键 true 返回无效;false 正常返回
BackHandler
.
addEventListener
(
"hardwareBackPress"
,
backEffect
);
BackHandler
.
addEventListener
(
'hardwareBackPress'
,
backEffect
);
}
props
.
navigation
.
setParams
({
onBack
,
onClose
});
return
()
=>
{
BackHandler
.
removeEventListener
(
"hardwareBackPress"
,
backEffect
);
BackHandler
.
removeEventListener
(
'hardwareBackPress'
,
backEffect
);
};
},
[]);
return
(
<
GeekWebView
ref
=
{
webviewRef
}
style
=
{
styles
.
container
}
uri
=
{
url
}
renderLoading
=
{()
=>
(
<
View
style
=
{{
height
:
device
.
height
-
device
.
headerHeight
-
device
.
androidStatusBarHeight
,
justifyContent
:
"center"
,
alignItems
:
"center"
,
}}
>
<
ActivityIndicator
size
=
"large"
/>
<
/View
>
)}
onTitle
=
{
onTitle
}
onShare
=
{
handleShare
}
onMessage
=
{
handleMessage
}
onPlayVideo
=
{
playVideo
}
onShareTimeline
=
{
handleShareTimeline
}
onLog
=
{
handleLog
}
/
>
<
SafeAreaView
style
=
{{
flex
:
1
}}
>
<
GeekWebView
ref
=
{
webviewRef
}
style
=
{
styles
.
container
}
uri
=
{
url
}
renderLoading
=
{()
=>
(
<
View
style
=
{{
height
:
device
.
height
-
device
.
headerHeight
-
device
.
androidStatusBarHeight
,
justifyContent
:
'center'
,
alignItems
:
'center'
,
}}
>
<
ActivityIndicator
size
=
"large"
/>
<
/View
>
)}
onTitle
=
{
onTitle
}
onShare
=
{
handleShare
}
onMessage
=
{
handleMessage
}
onPlayVideo
=
{
playVideo
}
onShareTimeline
=
{
handleShareTimeline
}
onLog
=
{
handleLog
}
/
>
<
/SafeAreaView
>
);
}
...
...
@@ -132,20 +130,20 @@ GeekWebViewPage.navigationOptions = ({ navigation }) => {
headerStyle
:
{
...
navigationOptions
.
headerStyle
||
{},
borderBottomColor
:
'#DEE2EA'
,
borderBottomWidth
:
rpx
(
1
)
borderBottomWidth
:
rpx
(
1
)
,
},
headerTitle
:
navigation
.
getParam
(
"title"
),
headerTitle
:
navigation
.
getParam
(
'title'
),
headerLeft
:
()
=>
{
return
(
<
View
style
=
{{
minWidth
:
rpx
(
100
),
marginLeft
:
rpx
(
20
),
flexDirection
:
"row"
,
alignItems
:
"center"
,
flexDirection
:
'row'
,
alignItems
:
'center'
,
}}
>
<
TouchableWithoutFeedback
onPress
=
{
navigation
.
getParam
(
"onBack"
)}
>
<
TouchableWithoutFeedback
onPress
=
{
navigation
.
getParam
(
'onBack'
)}
>
<
Image
source
=
{
back
}
style
=
{{
width
:
rpx
(
40
),
height
:
rpx
(
40
),
marginLeft
:
rpx
(
10
),
padding
:
rpx
(
10
)
}}
...
...
@@ -160,7 +158,7 @@ GeekWebViewPage.navigationOptions = ({ navigation }) => {
const
styles
=
StyleSheet
.
create
({
container
:
{
flex
:
1
,
backgroundColor
:
colors
.
pageBgColor
,
backgroundColor
:
'#f5f5f5'
,
},
});
...
...
src/rn-module/index.ts
deleted
100644 → 0
View file @
0093a090
src/rn-module/work-correct/index.ts
deleted
100644 → 0
View file @
0093a090
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
};
src/router/config.ts
View file @
68ac68b2
import
React
from
'react'
import
{
StackNavigationOptions
}
from
'react-navigation-stack/lib/typescript/src/vendor/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
React
from
'react'
;
import
{
StackNavigationOptions
}
from
'react-navigation-stack/lib/typescript/src/vendor/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
CorrectList
from
'@/pages/geek-correct-list'
;
import
GeekWebView
from
'@/pages/geek-webview'
;
type
StackPageProps
=
{
name
:
string
component
:
React
.
ReactNode
,
navigationOptions
?:
StackNavigationOptions
}
name
:
string
;
component
:
React
.
ReactNode
;
navigationOptions
?:
StackNavigationOptions
;
}
;
type
TabsPageProps
=
{
component
?:
React
.
ReactNode
,
name
:
string
,
navigationOptions
?:
NavigationCommonTabOptions
,
children
:
StackPageProps
[]
}
component
?:
React
.
ReactNode
;
name
:
string
;
navigationOptions
?:
NavigationCommonTabOptions
;
children
:
StackPageProps
[]
;
}
;
export
type
SwitchProps
=
{
tabs
:
TabsPageProps
[],
// tabs
auth
:
StackPageProps
[]
|
StackPageProps
,
// 权限页面
[
key
:
string
]:
TabsPageProps
[]
|
StackPageProps
[]
|
StackPageProps
}
tabs
?:
TabsPageProps
[];
// tabs
auth
:
StackPageProps
[]
|
StackPageProps
;
// 权限页面
[
key
:
string
]:
TabsPageProps
[]
|
StackPageProps
[]
|
StackPageProps
|
any
;
}
;
const
appConfig
:
SwitchProps
=
{
splash
:
{
component
:
SplashPage
,
name
:
'SplashPage'
},
tabs
:
[
{
component
:
Home
,
name
:
'THome'
,
navigationOptions
:
{
tabBarLabel
:
'uu'
},
children
:
[
{
name
:
'Home'
,
component
:
Home
},
]
}
],
auth
:
{
component
:
Login
,
name
:
'login'
},
}
home
:
[
{
component
:
Home
,
name
:
'home'
},
{
component
:
CorrectList
,
name
:
'CorrectList'
},
{
component
:
GeekWebView
,
name
:
'GeekWebView'
},
],
};
export
default
appConfig
\ No newline at end of file
export
default
appConfig
;
src/router/constant.tsx
View file @
68ac68b2
import
React
from
'react'
import
{
Image
,
Text
,
View
}
from
"react-native"
import
{
device
,
rpx
}
from
"geekbase"
import
backBlackImg
from
"@/assets/header/back.png"
import
backWhiteImg
from
"@/assets/header/backwhite.png"
import
{
TouchableOpacity
}
from
'react-native-gesture-handler'
/* eslint-disable react-native/no-inline-styles */
import
React
from
'react'
;
import
{
Image
,
Text
,
View
}
from
'react-native'
;
import
{
device
,
rpx
}
from
'geekbase'
;
import
backBlackImg
from
'@/assets/header/back.png'
;
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
)
{
return
(
canGoBack
?
<
TouchableOpacity
onPress=
{
onPress
}
>
<
View
style=
{
{
width
:
rpx
(
80
),
height
:
device
.
headerHeight
-
rpx
(
20
),
marginLeft
:
rpx
(
0
),
alignItems
:
'center'
,
justifyContent
:
'center'
}
}
>
<
Image
source=
{
isBlack
?
backBlackImg
:
backWhiteImg
}
style=
{
{
width
:
rpx
(
36
),
height
:
rpx
(
36
)
}
}
/>
</
View
>
</
TouchableOpacity
>
:
null
)
function
headerBack
({
canGoBack
,
onPress
}:
any
,
isBlack
=
true
)
{
return
canGoBack
?
(
<
TouchableOpacity
onPress=
{
onPress
}
>
<
View
style=
{
{
width
:
rpx
(
80
),
height
:
device
.
headerHeight
-
rpx
(
20
),
marginLeft
:
rpx
(
0
),
alignItems
:
'center'
,
justifyContent
:
'center'
,
}
}
>
<
Image
source=
{
isBlack
?
backBlackImg
:
backWhiteImg
}
style=
{
{
width
:
rpx
(
36
),
height
:
rpx
(
36
)
}
}
/>
</
View
>
</
TouchableOpacity
>
)
:
null
;
}
function
headerBackImage
(
isBlack
=
true
)
{
return
(
<
View
style=
{
{
width
:
rpx
(
80
),
height
:
device
.
headerHeight
-
rpx
(
20
),
marginLeft
:
rpx
(
0
),
alignItems
:
'center'
,
justifyContent
:
'center'
}
}
>
<
Image
source=
{
isBlack
?
backBlackImg
:
backWhiteImg
}
style=
{
{
width
:
rpx
(
36
),
height
:
rpx
(
36
)
}
}
/>
</
View
>
)
return
(
<
View
style=
{
{
width
:
rpx
(
80
),
height
:
device
.
headerHeight
-
rpx
(
20
),
marginLeft
:
rpx
(
0
),
alignItems
:
'center'
,
justifyContent
:
'center'
,
}
}
>
<
Image
source=
{
isBlack
?
backBlackImg
:
backWhiteImg
}
style=
{
{
width
:
rpx
(
36
),
height
:
rpx
(
36
)
}
}
/>
</
View
>
);
}
const
commonNavigationOptions
=
{
headerBackTitle
:
null
,
// 必须在源屏幕 (而不是目标屏幕) 中定义
headerRight
:
<
Text
></
Text
>,
headerTitleContainerStyle
:
{
flex
:
1
,
// 可以不写
justifyContent
:
'center'
,
alignItems
:
'center'
},
headerTitleAllowFontScaling
:
false
,
// 避免字体受系统字体缩放影响
}
headerBackTitle
:
''
,
// 必须在源屏幕 (而不是目标屏幕) 中定义
headerBackTitleVisible
:
false
,
headerTitleContainerStyle
:
{
justifyContent
:
'center'
,
alignItems
:
'center'
,
},
headerTitleAllowFontScaling
:
false
,
// 避免字体受系统字体缩放影响
};
const
commonHeaderStyle
=
{
borderBottomWidth
:
0
,
shadowOpacity
:
0
,
elevation
:
0
}
borderBottomWidth
:
0
,
shadowOpacity
:
0
,
elevation
:
0
,
}
;
const
commonHeaderTitleStyle
=
{
fontSize
:
rpx
(
37
),
fontWeight
:
'500'
,
alignSelf
:
'center'
,
textAlign
:
'center'
}
fontSize
:
rpx
(
37
),
fontWeight
:
'500'
,
alignSelf
:
'center'
,
textAlign
:
'center'
,
}
;
const
navigationOptions
=
{
...
commonNavigationOptions
,
headerStyle
:
{
...
commonHeaderStyle
,
backgroundColor
:
'#fff'
},
headerBackImage
:
headerBackImage
(),
headerTitleStyle
:
{
...
commonHeaderTitleStyle
,
color
:
'#484C4F'
}
}
const
navigationOptions
:
StackNavigationOptions
=
{
...(
commonNavigationOptions
as
any
)
,
headerStyle
:
{
...
commonHeaderStyle
,
backgroundColor
:
'#fff'
,
},
headerBackImage
:
()
=>
headerBackImage
(),
headerTitleStyle
:
{
...
commonHeaderTitleStyle
,
color
:
'#484C4F'
,
}
as
any
,
}
;
export
{
navigationOptions
,
headerBack
,
headerBackImage
}
export
{
navigationOptions
,
headerBack
,
headerBackImage
};
src/router/index.tsx
View file @
68ac68b2
import
React
from
'react'
;
import
{
createAppContainer
,
createSwitchNavigator
}
from
'react-navigation'
;
import
{
createStackNavigator
}
from
'react-navigation-stack'
;
import
{
createBottomTabNavigator
}
from
'react-navigation-tabs'
import
routerConfig
from
'./config'
import
{
headerBack
}
from
'./constant'
;
import
{
createBottomTabNavigator
}
from
'react-navigation-tabs'
;
import
routerConfig
from
'./config'
;
// navigation
const
renderStack
=
(
tabRoute
:
any
)
=>
{
const
renderStack
=
(
tabRoute
:
any
)
=>
{
let
routes
;
if
(
tabRoute
instanceof
Array
)
{
routes
=
tabRoute
.
map
(
itm
=>
{
const
{
navigationOptions
,
component
}
=
itm
||
{}
return
{
[
itm
.
name
]:
{
screen
:
component
,
navigationOptions
},
}
}).
reduce
((
pre
,
current
)
=>
{
return
{
...
pre
,
...
current
}
},
{})
routes
=
tabRoute
.
map
((
itm
)
=>
{
const
{
navigationOptions
,
component
}
=
itm
||
{};
return
{
[
itm
.
name
]:
{
screen
:
component
,
navigationOptions
},
};
})
.
reduce
((
pre
,
current
)
=>
{
return
{
...
pre
,
...
current
,
};
},
{});
}
else
{
routes
=
{
[
tabRoute
.
name
]:
{
screen
:
tabRoute
.
component
,
navigationOptions
:
tabRoute
.
navigationOptions
[
tabRoute
.
name
]:
{
screen
:
tabRoute
.
component
,
navigationOptions
:
tabRoute
.
navigationOptions
,
},
}
}
;
}
return
createStackNavigator
({
...
routes
,
},
{
defaultNavigationOptions
:
({
navigation
})
=>
{
return
{
headerBackAllowFontScaling
:
false
,
headerLeft
:
headerBack
}
}
})
}
});
};
//tabs
const
renderTabs
=
(
tabsConfig
:
any
[])
=>
{
const
tabs
=
tabsConfig
.
map
(
itm
=>
{
return
itm
.
children
&&
itm
.
children
.
length
>
0
?
{
[
itm
.
name
]:
{
screen
:
renderStack
(
itm
.
children
),
navigationOptions
:
itm
.
navigationOptions
}
}
:
{
[
itm
.
name
]:
{
screen
:
itm
.
component
,
navigationOptions
:
itm
.
navigationOptions
}
}
}).
reduce
((
pre
,
current
)
=>
{
return
{
...
pre
as
any
,
...
current
}
},
{})
const
TabNavigator
=
createBottomTabNavigator
({
...
tabs
as
any
},
{
defaultNavigationOptions
:
({
navigation
})
=>
{
const
tabs
=
tabsConfig
.
map
((
itm
)
=>
{
return
itm
.
children
&&
itm
.
children
.
length
>
0
?
{
[
itm
.
name
]:
{
screen
:
renderStack
(
itm
.
children
),
navigationOptions
:
itm
.
navigationOptions
,
},
}
:
{
[
itm
.
name
]:
{
screen
:
itm
.
component
,
navigationOptions
:
itm
.
navigationOptions
,
},
};
})
.
reduce
((
pre
,
current
)
=>
{
return
{
tabBarVisible
:
navigation
.
state
.
index
===
0
,
}
}
})
return
TabNavigator
}
...(
pre
as
any
),
...
current
,
};
},
{});
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
const
renderSwitch
=
(
routerConfig
:
any
)
=>
{
const
switchRoutes
=
Object
.
keys
(
routerConfig
).
map
(
key
=>
{
return
{
[
key
]:
{
screen
:
key
===
'tabs'
?
renderTabs
(
routerConfig
[
key
])
:
renderStack
(
routerConfig
[
key
])
const
renderSwitch
=
(
rtConfig
:
any
)
=>
{
const
switchRoutes
=
Object
.
keys
(
rtConfig
)
.
map
((
key
)
=>
{
const
screen
=
key
===
'tabs'
?
renderTabs
(
rtConfig
[
key
])
:
renderStack
(
rtConfig
[
key
]);
if
(
screen
)
{
return
{
[
key
]:
{
screen
:
key
===
'tabs'
?
renderTabs
(
rtConfig
[
key
])
:
renderStack
(
rtConfig
[
key
]),
},
};
}
}
})
.
reduce
((
pre
,
current
)
=>
{
return
{
...
pre
as
any
,
...
current
}
},
{})
}
)
.
reduce
((
pre
,
current
)
=>
{
return
{
...(
pre
as
any
)
,
...
current
,
};
},
{});
return
createSwitchNavigator
({
...
switchRoutes
})
}
...
(
switchRoutes
as
any
),
})
;
}
;
export
default
createAppContainer
(
renderSwitch
(
routerConfig
));
\ No newline at end of file
export
default
createAppContainer
(
renderSwitch
(
routerConfig
));
src/service/index.ts
View file @
68ac68b2
import
{
httpUtil
}
from
"geekbase"
import
{
httpUtil
,
Toast
}
from
'geekbase'
;
// import {getAppConfig} from 'geekbase';
const
addOnlineHomeworkImage
=
'/service-question/online/homework/addOnlineHomeworkImage'
// 学生拍照上传
const
getOnlineHomeworkImageInfo
=
'/service-question/online/homework/getOnlineHomeworkImageInfo'
// 根据id查询解析后的题目信息
const
confirmOnlineHomeworkImageInfo
=
'/service-question/online/homework/confirmOnlineHomeworkImageInfo'
// 保存学生确认后的答题信息
const
addOnlineHomeworkImage
=
'/online/homework/addOnlineHomeworkImage'
;
// 学生拍照上传
const
getOnlineHomeworkImageInfo
=
'/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
)
=>
{
const
formData
=
new
FormData
()
let
fileData
=
{
uri
:
file
,
type
:
'multipart/form-data'
,
name
:
''
};
formData
.
append
(
'file'
,
fileData
)
formData
.
append
(
'studentId'
,
studentId
)
httpUtil
.
setRequestInterceptor
(
(
config
)
=>
{
console
.
log
(
'===config: '
,
config
);
return
{
...
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
,
{
headers
:
{
"Content-Type"
:
"multipart/form-data"
,
"Authorization"
:
"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOiIyNTk2ODQiLCJ0ZXJtaW5hbCI6InBjIiwidXVpZCI6IjcwNTA0MjdhZjUzZDRkYzU5MGU1ZmU3YmFhNjIxYjY4IiwidGltZXN0YW1wIjoxNjAyMDU4ODMzMDg5fQ.iB3nFIMzAGd327MZDiLdbywaOUyhoEtD2SXi0lzcUbk"
}
})
}
'Content-Type'
:
'multipart/form-data'
,
},
});
};
export
const
loadOnlineHomeworkImages
=
()
=>
httpUtil
.
get
(
getOnlineHomeworkImages
,
{});
export
const
getOnlineHomeworkImageInfoInterface
=
(
id
:
string
)
=>
{
return
httpUtil
.
get
(
getOnlineHomeworkImageInfo
,
{
params
:
{
id
}
})
}
export
const
getOnlineHomeworkImageInfoInterface
=
(
id
:
string
|
number
)
=>
{
return
httpUtil
.
get
(
getOnlineHomeworkImageInfo
,
{
params
:
{
id
},
});
};
export
const
confirmOnlineHomeworkImageInfoInterface
=
(
params
:
{
onlineHomeworkImageId
:
number
questionId
:
number
questionType
:
string
ownerAnswer
:
string
[]
questionUrl
:
string
onlineHomeworkImageId
:
number
;
questionId
:
number
;
questionType
:
string
;
ownerAnswer
:
string
[];
questionUrl
:
string
;
})
=>
{
return
httpUtil
.
post
(
confirmOnlineHomeworkImageInfo
,
params
,
{})
}
\ No newline at end of file
return
httpUtil
.
post
(
confirmOnlineHomeworkImageInfo
,
params
,
{});
};
src/utils/index.js
View file @
68ac68b2
// import { Decimal } from "decimal.js";
import
DeviceInfo
from
"react-native-device-info"
;
import
{
Linking
,
findNodeHandle
,
UIManager
}
from
"react-native"
;
import
*
as
WeChat
from
"react-native-weixin"
;
import
{
Toast
}
from
"geekbase"
;
import
{
saveBase64Image
}
from
'./fileUtil'
import
http
from
"@/http"
;
import
{
playWithSeekPos
}
from
"react-native-player"
;
import
DeviceInfo
from
'react-native-device-info'
;
import
{
Linking
,
findNodeHandle
,
UIManager
}
from
'react-native'
;
// import * as WeChat from 'react-native-weixin';
import
{
Toast
}
from
'geekbase'
;
// import http from '@/http';
import
{
playWithSeekPos
}
from
'react-native-player'
;
// classin app 的下载地址
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
=
"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
=
{
"+"
:
"add"
,
"-"
:
"sub"
,
"*"
:
"mul"
,
"/"
:
"div"
'+'
:
'add'
,
'-'
:
'sub'
,
'*'
:
'mul'
,
'/'
:
'div'
,
};
const
sleep
=
async
duration
=>
{
const
sleep
=
async
(
duration
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(
resolve
,
duration
);
});
};
const
linkClassinApp
=
url
=>
{
const
linkClassinApp
=
(
url
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
systemVersion
=
DeviceInfo
.
getSystemVersion
();
if
(
systemVersion
&&
parseInt
(
systemVersion
)
<
6
)
{
reject
({
message
:
"您的手机系统版本小于安卓6.0,无法下载安装。请升级到安卓6.0以上"
'您的手机系统版本小于安卓6.0,无法下载安装。请升级到安卓6.0以上'
,
});
return
;
}
Linking
.
canOpenURL
(
url
)
.
then
(
supported
=>
{
.
then
(
(
supported
)
=>
{
const
iosDownloadUrl
=
iosClassinAppUrl
;
const
androidDownloadUrl
=
androidClassinAppUrl
;
const
downloadUrl
=
DeviceInfo
.
os
===
"android"
?
androidDownloadUrl
:
iosDownloadUrl
;
DeviceInfo
.
os
===
'android'
?
androidDownloadUrl
:
iosDownloadUrl
;
if
(
!
supported
)
{
// 如果没有安装 就弹出下载弹窗
console
.
log
(
"classin app没有安装"
);
console
.
log
(
'classin app没有安装'
);
reject
({
message
:
"classin app没有安"
,
appUrl
:
downloadUrl
message
:
'classin app没有安'
,
appUrl
:
downloadUrl
,
});
}
else
{
// 跳转到 classin app
...
...
@@ -55,10 +54,10 @@ const linkClassinApp = url => {
return
Linking
.
openURL
(
url
);
}
})
.
catch
(
err
=>
{
console
.
error
(
"classin app 打开报错"
,
err
);
.
catch
(
(
err
)
=>
{
console
.
error
(
'classin app 打开报错'
,
err
);
reject
({
message
:
"classin app 打开报错"
message
:
'classin app 打开报错'
,
});
});
});
...
...
@@ -73,54 +72,54 @@ const getBoundingRect = (dom, cb) => {
width
,
height
,
pageX
,
pageY
pageY
,
});
});
};
const
stringParams
=
params
=>
{
let
query
=
""
;
Object
.
keys
(
params
).
forEach
(
key
=>
{
const
stringParams
=
(
params
)
=>
{
let
query
=
''
;
Object
.
keys
(
params
).
forEach
(
(
key
)
=>
{
const
value
=
params
[
key
];
console
.
log
(
value
);
query
=
query
+
"&"
+
'&'
+
key
+
"="
+
(
typeof
value
===
"string"
?
value
:
JSON
.
stringify
(
value
));
'='
+
(
typeof
value
===
'string'
?
value
:
JSON
.
stringify
(
value
));
});
return
query
.
length
>
0
?
query
.
slice
(
1
)
:
query
;
};
const
share
=
async
(
data
,
isTimeLine
=
false
)
=>
{
try
{
Toast
.
showLoading
();
let
isInstalled
=
await
WeChat
.
isWXAppInstalled
();
if
(
isInstalled
)
{
let
successed
=
false
;
if
(
!
isTimeLine
)
{
successed
=
await
WeChat
.
shareToSession
(
data
);
}
else
{
successed
=
await
WeChat
.
shareToTimeline
(
data
);
}
Toast
.
hideLoading
();
if
(
successed
)
{
Toast
.
msg
(
"分享成功"
);
}
else
{
Toast
.
msg
(
"分享失败"
);
}
}
else
{
Toast
.
hideLoading
();
Toast
.
warn
(
"没有安装微信,不能分享"
);
}
}
catch
(
error
)
{
Toast
.
hideLoading
();
Toast
.
msg
((
error
||
{}).
message
?
error
.
message
:
error
);
}
};
// const share =
async (data, isTimeLine = false) => {
//
try {
//
Toast.showLoading();
//
let isInstalled = await WeChat.isWXAppInstalled();
//
if (isInstalled) {
//
let successed = false;
//
if (!isTimeLine) {
//
successed = await WeChat.shareToSession(data);
//
} else {
//
successed = await WeChat.shareToTimeline(data);
//
}
//
Toast.hideLoading();
//
if (successed) {
// Toast.msg('分享成功'
);
//
} else {
// Toast.msg('分享失败'
);
//
}
//
} else {
//
Toast.hideLoading();
// Toast.warn('没有安装微信,不能分享'
);
//
}
//
} catch (error) {
//
Toast.hideLoading();
//
Toast.msg((error || {}).message ? error.message : error);
//
}
//
};
const
openUrl
=
url
=>
{
const
openUrl
=
(
url
)
=>
{
if
(
Linking
.
canOpenURL
(
url
))
{
Linking
.
openURL
(
url
);
}
...
...
@@ -129,54 +128,57 @@ const openUrl = url => {
/**
* @type img | text | news
* @data img => {img: base64} , text => { description: '' } , news: { title: string, webpageUrl: url, description: string }
* @isTimeline 是否分享到朋友圈
*/
const
shareByWeb
=
({
type
=
'text'
,
img
,
...
data
}
,
isTimeline
=
false
)
=>
{
if
(
type
===
'text'
||
type
===
'news'
)
{
const
shareData
=
{
type
,
...
data
}
share
({
...
shareData
},
isTimeline
)
}
else
{
saveBase64Image
(
img
,
(
imgPath
,
error
)
=>
{
if
(
!
error
)
{
share
({
type
:
'imageFile'
,
description
:
'图片分享'
,
imageUrl
:
"file://"
+
imgPath
,
title
:
'图片分享'
},
isTimeline
)
}
else
{
Toast
.
warn
(
'图片分享失败, 请重试'
)
}
})
}
}
* @isTimeline 是否分享到朋友圈
// */
// const shareByWeb = ({type = 'text', img, ...data}, isTimeline = false) => {
// if (type === 'text' || type === 'news') {
// const shareData = {
// type,
// ...data,
// };
// share({...shareData}, isTimeline);
// } else {
// // saveBase64Image(img, (imgPath, error) => {
// // if (!error) {
// // share(
// // {
// // type: 'imageFile',
// // description: '图片分享',
// // imageUrl: 'file://' + imgPath,
// // title: '图片分享',
// // },
// // isTimeline,
// // );
// // } else {
// // Toast.warn('图片分享失败, 请重试');
// // }
// // });
// }
// };
// 视频播放封装
const
playVideo
=
async
(
url
,
cb
)
=>
{
const
[
res
,
error
]
=
await
http
.
queryVideoPlayTime
(
url
||
''
)
console
.
log
(
res
,
error
)
const
{
checkValue
}
=
res
||
{}
const
{
current
,
total
}
=
checkValue
||
{}
const
currentTime
=
total
>
0
?
(
current
+
5
>
total
?
1
:
current
)
:
1
const
[
res
,
error
]
=
await
http
.
queryVideoPlayTime
(
url
||
''
)
;
console
.
log
(
res
,
error
)
;
const
{
checkValue
}
=
res
||
{};
const
{
current
,
total
}
=
checkValue
||
{};
const
currentTime
=
total
>
0
?
(
current
+
5
>
total
?
1
:
current
)
:
1
;
playWithSeekPos
(
url
,
currentTime
,
(
videoRes
)
=>
{
console
.
log
(
'保存视频回调'
,
videoRes
)
console
.
log
(
'保存视频回调'
,
videoRes
)
;
http
.
saveVideoPlayTime
(
url
,
videoRes
).
then
((
res
)
=>
{
console
.
log
(
'保存视频播放'
,
res
)
})
cb
&&
cb
(
videoRes
)
})
}
console
.
log
(
'保存视频播放'
,
res
)
;
})
;
cb
&&
cb
(
videoRes
)
;
})
;
}
;
export
{
sleep
,
linkClassinApp
,
getBoundingRect
,
stringParams
,
share
,
//
share,
openUrl
,
shareByWeb
,
playVideo
//
shareByWeb,
playVideo
,
};
tsconfig.json
View file @
68ac68b2
...
...
@@ -13,7 +13,7 @@
"baseUrl"
:
"."
,
"paths"
:
{
"@/*"
:
[
"./src/*"
]
}
}
,
},
"exclude"
:
[
"node_modules"
,
...
...
yarn.lock
View file @
68ac68b2
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment