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
93073288
Commit
93073288
authored
Aug 16, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改APP进入逻辑以及返回按钮
parent
8ac2056b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
145 additions
and
28 deletions
+145
-28
AppBackButton.scss
src/components/AppBackButton/AppBackButton.scss
+9
-0
AppBackButton.tsx
src/components/AppBackButton/AppBackButton.tsx
+27
-0
useAppBackState.ts
src/hooks/useAppBackState.ts
+16
-0
useShowerController.ts
src/hooks/useShowerController.ts
+57
-0
AppLaunch.tsx
src/pages/AppLaunch/AppLaunch.tsx
+30
-4
BarCode.tsx
src/pages/BarCode/BarCode.tsx
+2
-0
Home.tsx
src/pages/Home/Home.tsx
+0
-24
Shower.tsx
src/pages/Shower/Shower.tsx
+2
-0
ShowerAppointment.tsx
src/pages/Shower/ShowerAppointment.tsx
+2
-0
No files found.
src/components/AppBackButton/AppBackButton.scss
0 → 100644
View file @
93073288
.AppBackButton
{
position
:
absolute
;
left
:
0
;
bottom
:
160px
;
width
:
140px
;
height
:
60px
;
line-height
:
60px
;
font-size
:
30px
;
}
src/components/AppBackButton/AppBackButton.tsx
0 → 100644
View file @
93073288
import
{
Button
}
from
'@tarojs/components'
;
import
Taro
from
'@tarojs/taro'
;
import
useAppBackState
from
'@/hooks/useAppBackState'
;
import
'./AppBackButton.scss'
;
const
AppBackButton
=
()
=>
{
const
isShow
=
useAppBackState
();
const
goBackAppError
=
e
=>
{
console
.
log
(
e
);
Taro
.
showModal
({
title
:
'提示'
,
content
:
'呼起APP失败,请手动回到APP'
,
});
};
return
isShow
?
(
<
Button
className=
'AppBackButton'
open
-
type=
'launchApp'
app
-
parameter=
'wechat'
onError=
{
goBackAppError
}
>
返回
</
Button
>
)
:
null
;
};
export
default
AppBackButton
;
src/hooks/useAppBackState.ts
0 → 100644
View file @
93073288
import
Taro
,
{
useEffect
,
useState
}
from
'@tarojs/taro'
;
const
useAppBackState
=
():
boolean
=>
{
const
[
state
,
setState
]
=
useState
(
false
);
useEffect
(()
=>
{
let
entity
=
Taro
.
getLaunchOptionsSync
();
console
.
log
(
entity
);
if
(
entity
.
scene
===
1069
||
entity
.
scene
===
1036
)
{
setState
(
true
);
}
},
[]);
return
state
;
};
export
default
useAppBackState
;
src/hooks/useShowerController.ts
0 → 100644
View file @
93073288
import
{
useSelector
,
useDispatch
}
from
'@tarojs/redux'
;
import
{
getShowerController
,
ShowerUseType
}
from
'@/api/shower'
;
import
{
updateShowerControlConfig
}
from
'@/store/rootReducers/shower'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
import
Taro
,
{
useEffect
,
useState
}
from
'@tarojs/taro'
;
const
useShowerController
=
()
=>
{
const
[
method
,
setState
]
=
useState
(
''
);
const
dispatch
=
useDispatch
();
const
userinfo
=
useSelector
(
(
state
:
{
userinfo
:
Customer
})
=>
state
.
userinfo
,
);
useEffect
(()
=>
{
if
(
method
)
{
Taro
.
showLoading
();
getShowerController
({
campusId
:
userinfo
.
areaId
,
customerId
:
userinfo
.
customerId
,
})
.
then
(
res
=>
{
let
data
=
res
.
data
;
dispatch
(
updateShowerControlConfig
(
res
.
data
));
let
type
=
data
.
useType
===
ShowerUseType
.
mix
?
data
.
defaultType
:
data
.
useType
;
let
url
=
''
;
if
(
type
===
ShowerUseType
.
bluetooth
)
{
url
=
'/pages/Shower/Shower'
;
}
else
{
url
=
'/pages/Shower/ShowerAppointment'
;
}
Taro
.
hideLoading
();
console
.
log
(
url
);
if
(
method
===
'redirectTo'
)
{
Taro
.
redirectTo
({
url
:
url
});
}
else
{
Taro
.
navigateTo
({
url
:
url
});
}
})
.
catch
(
err
=>
{
Taro
.
hideLoading
();
console
.
log
(
'getShowerController err:'
,
err
);
Taro
.
showToast
({
title
:
err
.
msg
||
'网络错误'
,
icon
:
'none'
,
});
});
}
},
[
method
]);
return
setState
;
};
export
default
useShowerController
;
src/pages/AppLaunch/AppLaunch.tsx
View file @
93073288
...
...
@@ -5,13 +5,36 @@ import { fetchAppLaunchCustomer } from '@/api/customer';
import
{
LogoutCode
}
from
'@/constants'
;
import
{
useDispatch
}
from
'@tarojs/redux'
;
import
{
updateUserInfo
}
from
'@/store/rootReducers/userinfo'
;
import
AppBackButton
from
'@/components/AppBackButton/AppBackButton'
;
import
useShowerController
from
'@/hooks/useShowerController'
;
function
AppLaunch
()
{
const
dispatch
=
useDispatch
();
const
setGoMethod
=
useShowerController
();
const
goNextPage
=
(
serviceId
:
string
)
=>
{
Taro
.
redirectTo
({
url
:
`/pages/Home/Home?serviceId=
${
serviceId
}
`
,
});
let
url
=
''
;
switch
(
serviceId
)
{
case
'9'
:
url
=
'/pages/WaterDispenser/WaterDispenser'
;
break
;
case
'10'
:
setGoMethod
(
'redirectTo'
);
return
;
case
'11'
:
case
'12'
:
url
=
`/pages/BarCode/BarCode?serviceId=
${
serviceId
}
`
;
break
;
default
:
console
.
log
(
'goNextPage serviceId: '
+
serviceId
);
Taro
.
showToast
({
title
:
'无法识别的服务'
,
icon
:
'none'
,
});
break
;
}
if
(
url
)
{
Taro
.
redirectTo
({
url
});
}
};
const
[
showBackButtonState
,
setShowBackButtonState
]
=
useState
(
false
);
const
[
errorMsg
,
setErrorMsg
]
=
useState
(
''
);
...
...
@@ -22,7 +45,10 @@ function AppLaunch() {
Taro
.
showLoading
();
const
{
uuId
,
serviceId
}
=
entity
;
if
(
uuId
&&
serviceId
)
{
fetchAppLaunchCustomer
(
entity
)
fetchAppLaunchCustomer
({
...
entity
,
timeStamp
:
Math
.
floor
(
new
Date
().
getTime
()
/
1000
),
})
.
then
(
res
=>
{
console
.
log
(
res
);
Taro
.
hideLoading
();
...
...
src/pages/BarCode/BarCode.tsx
View file @
93073288
...
...
@@ -17,6 +17,7 @@ import { shareHandle } from '@/common/shareMethod';
import
{
PayOrderState
}
from
'@/store/rootReducers/orderState'
;
import
WaitPayOrderComponent
from
'@/components/WaitPayOrder/WaitPayOrder'
;
import
widthWaitPayOrderComponent
from
'@/components/WaitPayOrder/WaitPayOrder'
;
import
AppBackButton
from
'@/components/AppBackButton/AppBackButton'
;
type
PageStateProps
=
{
userinfo
:
Customer
;
...
...
@@ -172,6 +173,7 @@ class BarCode extends Component {
return
(
<
View
className=
'BarCode'
>
<
AppBackButton
/>
<
WaitPayOrderComponent
/>
<
View
className=
{
payOrderState
?
'blur'
:
''
}
>
{
showBackTag
&&
(
...
...
src/pages/Home/Home.tsx
View file @
93073288
...
...
@@ -118,11 +118,6 @@ class Home extends Component {
onShareAppMessage
=
shareHandle
;
componentWillMount
()
{
const
{
serviceId
}
=
this
.
$router
.
params
;
console
.
log
(
'in componentWillMount'
,
serviceId
);
if
(
serviceId
)
{
return
this
.
redirectFromAppLaunch
(
serviceId
);
}
this
.
getInitData
();
}
...
...
@@ -130,25 +125,6 @@ class Home extends Component {
this
.
getInitData
();
}
redirectFromAppLaunch
(
serviceId
:
string
)
{
switch
(
serviceId
)
{
case
'9'
:
return
this
.
goDispenser
();
case
'10'
:
return
this
.
goShower
();
case
'11'
:
case
'12'
:
return
this
.
goBarCode
(
Number
(
serviceId
));
default
:
console
.
log
(
'redirectFromAppLaunch serviceId: '
+
serviceId
);
Taro
.
showToast
({
title
:
'无法识别的服务'
,
icon
:
'none'
,
});
break
;
}
}
getInitData
()
{
this
.
getServiceList
();
this
.
getAnn
();
...
...
src/pages/Shower/Shower.tsx
View file @
93073288
...
...
@@ -27,6 +27,7 @@ import { updateBluetoothDevice } from './actions';
import
{
ab2str
,
str2ab
}
from
'@/utils/arrayBuffer'
;
import
WaitPayOrderComponent
from
'@/components/WaitPayOrder/WaitPayOrder'
;
import
{
PayOrderState
}
from
'@/store/rootReducers/orderState'
;
import
AppBackButton
from
'@/components/AppBackButton/AppBackButton'
;
enum
BlueToothError
{
BlueToothNotOpen
=
'BlueToothNotOpen'
,
...
...
@@ -829,6 +830,7 @@ class Shower extends Component {
return
(
<
View
className=
'Shower'
>
<
AppBackButton
/>
<
WaitPayOrderComponent
/>
{
showAppoint
&&
(
<
View
className=
'showAppoint'
onClick=
{
this
.
goAppointShower
}
>
...
...
src/pages/Shower/ShowerAppointment.tsx
View file @
93073288
...
...
@@ -17,6 +17,7 @@ import AppointermentEquipment from './components/AppointermentEquipment/Appointe
import
useAppointRecordsList
from
'./hooks/useAppointRecordsList'
;
import
useCheckAppointable
from
'./hooks/useCheckAppointable'
;
import
{
ShowerState
}
from
'@/store/rootReducers/shower'
;
import
AppBackButton
from
'@/components/AppBackButton/AppBackButton'
;
function
ShowerAppointment
()
{
const
userInfo
=
useSelector
(
...
...
@@ -199,6 +200,7 @@ function ShowerAppointment() {
return
(
<
View
className=
'ShowerAppointment'
>
<
AppBackButton
/>
{
showState
==
1
&&
(
<
View
className=
'ShowerAppointment-Searchbox'
>
<
Input
...
...
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