Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wx-school-app
Project
Overview
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
姜雷
wx-school-app
Commits
ac3c884d
Commit
ac3c884d
authored
Aug 23, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加版本低于2.7.0的键盘输入处理
parent
21a80cb8
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
100 additions
and
2 deletions
+100
-2
useSystemInfo.ts
src/hooks/useSystemInfo.ts
+21
-0
Feedback.tsx
src/pages/Feedback/Feedback.tsx
+8
-0
index.tsx
src/pages/index/index.tsx
+2
-0
reducers.ts
src/store/reducers.ts
+2
-0
systemInfo.ts
src/store/rootReducers/systemInfo.ts
+40
-0
userinfo.ts
src/store/rootReducers/userinfo.ts
+2
-2
version.ts
src/utils/version.ts
+25
-0
No files found.
src/hooks/useSystemInfo.ts
0 → 100644
View file @
ac3c884d
import
{
useSelector
,
useDispatch
}
from
'@tarojs/redux'
;
import
Taro
,
{
useEffect
}
from
'@tarojs/taro'
;
import
{
updateSystemInfo
}
from
'@/store/rootReducers/systemInfo'
;
const
useSystemInfo
=
()
=>
{
const
systemInfo
=
useSelector
(
(
state
:
{
systemInfo
:
Taro
.
getSystemInfo
.
Promised
})
=>
state
.
systemInfo
,
);
const
dispatch
=
useDispatch
();
useEffect
(()
=>
{
if
(
!
systemInfo
.
SDKVersion
)
{
Taro
.
getSystemInfo
().
then
(
res
=>
{
dispatch
(
updateSystemInfo
(
res
));
});
}
},
[]);
return
systemInfo
;
};
export
default
useSystemInfo
;
src/pages/Feedback/Feedback.tsx
View file @
ac3c884d
...
...
@@ -16,6 +16,8 @@ import { addFeedback } from '@/api/feedback';
import
useButtonPadding
from
'@/hooks/useButtonPadding'
;
import
FeedbackItem
from
'./components/FeedbackItem/FeedbackItem'
;
import
{
formatDate
}
from
'@/utils/time'
;
import
useSystemInfo
from
'@/hooks/useSystemInfo'
;
import
{
compareVersion
}
from
'@/utils/version'
;
function
Feedback
()
{
useShareAppMessage
(
shareHandle
);
...
...
@@ -68,7 +70,10 @@ function Feedback() {
}
};
const
[
scrollTop
,
setScrollTop
]
=
useState
(
0
);
const
systemInfo
=
useSystemInfo
();
useEffect
(()
=>
{
if
(
compareVersion
(
systemInfo
.
SDKVersion
,
'2.7.0'
))
{
wx
.
onKeyboardHeightChange
(
res
=>
{
console
.
log
(
res
.
height
);
if
(
res
.
height
)
{
...
...
@@ -77,6 +82,9 @@ function Feedback() {
setShowKeyboard
(
false
);
}
});
}
else
{
console
.
log
(
'in focus'
);
}
},
[]);
useEffect
(()
=>
{
Taro
.
createSelectorQuery
()
...
...
src/pages/index/index.tsx
View file @
ac3c884d
...
...
@@ -8,6 +8,7 @@ import { connect } from '@tarojs/redux';
import
{
updateUserInfo
,
UserState
}
from
'../../store/rootReducers/userinfo'
;
import
{
appLogin
}
from
'../../api/customer'
;
import
{
shareHandle
}
from
'@/common/shareMethod'
;
import
useSystemInfo
from
'@/hooks/useSystemInfo'
;
type
PageDispatchProps
=
{
updateUserInfo
:
(
e
:
UserState
|
{
token
:
string
})
=>
void
;
...
...
@@ -97,6 +98,7 @@ class Index extends Component {
render
()
{
const
{
errorText
}
=
this
.
state
;
useSystemInfo
();
return
<
View
className=
'Index'
>
{
errorText
}
</
View
>;
}
}
...
...
src/store/reducers.ts
View file @
ac3c884d
...
...
@@ -5,6 +5,7 @@ import ShowerReducer from '@/pages/Shower/store';
import
serviceList
from
'./rootReducers/service'
;
import
orderState
from
'./rootReducers/orderState'
;
import
showerState
from
'./rootReducers/shower'
;
import
systemInfo
from
'./rootReducers/systemInfo'
;
export
default
combineReducers
({
userinfo
,
...
...
@@ -13,4 +14,5 @@ export default combineReducers({
serviceList
,
orderState
,
showerState
,
systemInfo
,
});
src/store/rootReducers/systemInfo.ts
0 → 100644
View file @
ac3c884d
import
Actions
from
'@/types/Store/Actions'
;
const
INITIAL_STATE
=
{
brand
:
''
,
model
:
''
,
pixelRatio
:
''
,
screenWidth
:
0
,
screenHeight
:
0
,
windowWidth
:
0
,
windowHeight
:
0
,
statusBarHeight
:
0
,
language
:
''
,
version
:
''
,
system
:
''
,
platform
:
''
,
fontSizeSetting
:
0
,
SDKVersion
:
''
,
};
export
const
updateSystemInfo
=
(
entity
:
Taro
.
getSystemInfo
.
Promised
,
):
Actions
=>
({
type
:
'UPDATE_SYSTEMINFO'
,
payload
:
entity
,
});
export
default
function
systemInfo
(
state
:
Taro
.
getSystemInfo
.
Promised
=
INITIAL_STATE
,
actions
:
Actions
,
):
Taro
.
getSystemInfo
.
Promised
{
switch
(
actions
.
type
)
{
case
'UPDATE_SYSTEMINFO'
:
return
{
...
state
,
...
actions
.
payload
,
};
default
:
return
state
;
}
}
src/store/rootReducers/userinfo.ts
View file @
ac3c884d
import
Action
from
'../../types/Store/Actions'
;
import
{
Customer
}
from
'../../types/Customer/Customer'
;
import
{
Customer
,
CustomerSex
}
from
'../../types/Customer/Customer'
;
export
type
UserState
=
StoreState
<
Customer
&
{
code
:
string
}
>
;
...
...
@@ -14,7 +14,7 @@ export const INITIAL_STATE = {
customerId
:
0
,
customerName
:
''
,
customerPhone
:
''
,
customerSex
:
''
,
customerSex
:
CustomerSex
.
boy
,
customerType
:
''
,
email
:
''
,
entranceDate
:
''
,
...
...
src/utils/version.ts
0 → 100644
View file @
ac3c884d
export
function
compareVersion
(
v1
:
string
,
v2
:
string
):
boolean
{
let
v1Arr
=
v1
.
split
(
'.'
);
let
v2Arr
=
v2
.
split
(
'.'
);
const
len
=
Math
.
max
(
v1
.
length
,
v2
.
length
);
while
(
v1
.
length
<
len
)
{
v1Arr
.
push
(
'0'
);
}
while
(
v2
.
length
<
len
)
{
v2Arr
.
push
(
'0'
);
}
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
const
num1
=
parseInt
(
v1
[
i
]);
const
num2
=
parseInt
(
v2
[
i
]);
if
(
num1
>
num2
)
{
return
true
;
}
else
if
(
num1
<
num2
)
{
return
false
;
}
}
return
true
;
}
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