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
4aaf14a6
Commit
4aaf14a6
authored
Jun 28, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加洗浴设备提示
parent
dcaeb0a8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
5 deletions
+95
-5
shower.ts
src/api/shower.ts
+29
-2
Shower.tsx
src/pages/Shower/Shower.tsx
+63
-3
Shower.ts
src/types/Shower/Shower.ts
+3
-0
No files found.
src/api/shower.ts
View file @
4aaf14a6
import
{
showerFetch
}
from
'./index'
;
import
{
showerFetch
,
ResponseDataEntity
}
from
'./index'
;
export
enum
OperationMode
{
beanFirst
=
1
,
aimiFirst
=
2
,
onlyAimi
=
3
,
}
type
ShowerParams
=
{
type
ShowerParams
=
{
deviceCode
:
string
;
deviceCode
:
string
;
...
@@ -8,12 +14,15 @@ type ShowerParams = {
...
@@ -8,12 +14,15 @@ type ShowerParams = {
export
type
DeviceInfoResponse
=
{
export
type
DeviceInfoResponse
=
{
code
:
string
;
code
:
string
;
isOnlyBluetooth
:
number
;
isOnlyBluetooth
:
number
;
operationMode
:
OperationMode
;
position
:
string
;
position
:
string
;
};
};
/**
/**
* 通过设备码获取设备信息
* 通过设备码获取设备信息
*/
*/
export
const
fetchShowerInfo
=
(
params
:
ShowerParams
)
=>
export
const
fetchShowerInfo
=
(
params
:
ShowerParams
,
):
Promise
<
ResponseDataEntity
<
DeviceInfoResponse
>>
=>
showerFetch
({
showerFetch
({
url
:
`/dcxy/api/shower/devices/
${
params
.
deviceCode
}
`
,
url
:
`/dcxy/api/shower/devices/
${
params
.
deviceCode
}
`
,
data
:
params
,
data
:
params
,
...
@@ -46,3 +55,21 @@ export const startShowerEquipment = (params: StartParams) =>
...
@@ -46,3 +55,21 @@ export const startShowerEquipment = (params: StartParams) =>
method
:
'POST'
,
method
:
'POST'
,
data
:
params
,
data
:
params
,
});
});
type
ControllerParams
=
{
customerId
:
number
;
campusId
:
number
;
};
type
ControllerResponse
=
{
beanAmount
:
number
;
money
:
number
;
thresholdPrompt
:
string
;
thresholdValue
:
number
;
};
export
const
getShowerController
=
(
params
:
ControllerParams
,
):
Promise
<
ResponseDataEntity
<
ControllerResponse
>>
=>
showerFetch
({
url
:
'/dcxy/api/shower/controllerConfigs'
,
data
:
params
,
});
src/pages/Shower/Shower.tsx
View file @
4aaf14a6
...
@@ -12,11 +12,12 @@ import {
...
@@ -12,11 +12,12 @@ import {
DeviceInfoResponse
,
DeviceInfoResponse
,
startShowerEquipment
,
startShowerEquipment
,
fetchUsingShowerInfo
,
fetchUsingShowerInfo
,
getShowerController
,
OperationMode
,
}
from
'@/api/shower'
;
}
from
'@/api/shower'
;
import
{
connect
,
useSelector
}
from
'@tarojs/redux'
;
import
{
connect
,
useSelector
}
from
'@tarojs/redux'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
import
{
ComponentClass
}
from
'react'
;
import
{
ComponentClass
}
from
'react'
;
import
{
ResponseDataEntity
}
from
'@/api'
;
import
{
connectSocket
}
from
'@/api/socket'
;
import
{
connectSocket
}
from
'@/api/socket'
;
import
{
SOCKET_URL
}
from
'@/constants'
;
import
{
SOCKET_URL
}
from
'@/constants'
;
import
{
BluetoothDevice
}
from
'@/types/Shower/Shower'
;
import
{
BluetoothDevice
}
from
'@/types/Shower/Shower'
;
...
@@ -331,12 +332,13 @@ class Shower extends Component {
...
@@ -331,12 +332,13 @@ class Shower extends Component {
customerId
:
userinfo
.
customerId
.
toString
(),
customerId
:
userinfo
.
customerId
.
toString
(),
campusId
:
userinfo
.
areaId
,
campusId
:
userinfo
.
areaId
,
})
})
.
then
(
(
res
:
ResponseDataEntity
<
DeviceInfoResponse
>
)
=>
{
.
then
(
res
=>
{
const
data
=
res
.
data
;
const
data
=
res
.
data
;
updateBluetoothDevice
({
updateBluetoothDevice
({
code
:
data
.
code
,
code
:
data
.
code
,
isOnlyBluetooth
:
data
.
isOnlyBluetooth
,
isOnlyBluetooth
:
data
.
isOnlyBluetooth
,
position
:
data
.
position
,
position
:
data
.
position
,
operationMode
:
data
.
operationMode
,
});
});
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
...
@@ -649,6 +651,63 @@ class Shower extends Component {
...
@@ -649,6 +651,63 @@ class Shower extends Component {
});
});
}
}
checkUserMonry
()
{
const
{
userinfo
}
=
this
.
props
;
return
getShowerController
({
customerId
:
userinfo
.
customerId
,
campusId
:
userinfo
.
areaId
,
})
.
then
(
res
=>
{
console
.
log
(
res
);
const
{
bluetoothDevice
:
{
operationMode
},
}
=
this
.
props
;
const
{
thresholdValue
,
thresholdPrompt
,
money
,
beanAmount
}
=
res
.
data
;
if
(
thresholdValue
)
{
if
(
operationMode
===
OperationMode
.
onlyAimi
&&
money
<
thresholdValue
)
{
return
this
.
userWarnningHandle
(
thresholdPrompt
,
money
,
beanAmount
);
}
if
(
(
operationMode
===
OperationMode
.
aimiFirst
||
operationMode
===
OperationMode
.
beanFirst
)
&&
money
+
beanAmount
<
thresholdValue
)
{
return
this
.
userWarnningHandle
(
thresholdPrompt
,
money
,
beanAmount
);
}
return
Promise
.
resolve
();
}
return
Promise
.
resolve
();
})
.
catch
(
console
.
error
);
}
userWarnningHandle
(
thresholdPrompt
,
money
,
beanAmount
)
{
Taro
.
hideLoading
();
console
.
log
(
'in userWarnningHandle'
);
let
arr
=
[
money
,
beanAmount
];
let
i
=
-
1
;
return
Taro
.
showModal
({
title
:
'提示'
,
content
:
thresholdPrompt
.
replace
(
/
(\{
.*
?\})
/g
,
()
=>
{
i
++
;
return
arr
[
i
];
}),
}).
then
(
res
=>
{
if
(
res
.
confirm
)
{
Taro
.
showLoading
({
title
:
'开启中'
,
mask
:
true
,
});
return
Promise
.
resolve
();
}
else
{
return
Promise
.
reject
();
}
});
}
startUseShower
(
reConnect
:
boolean
)
{
startUseShower
(
reConnect
:
boolean
)
{
if
(
!
reConnect
)
{
if
(
!
reConnect
)
{
Taro
.
showLoading
({
Taro
.
showLoading
({
...
@@ -660,7 +719,8 @@ class Shower extends Component {
...
@@ -660,7 +719,8 @@ class Shower extends Component {
if
(
!
sockedDone
)
{
if
(
!
sockedDone
)
{
this
.
connectDeviceSocket
();
this
.
connectDeviceSocket
();
}
}
this
.
startDevicesDiscovery
()
this
.
checkUserMonry
()
.
then
(()
=>
this
.
startDevicesDiscovery
())
.
then
((
deviceId
:
string
)
=>
this
.
createConnection
(
deviceId
))
.
then
((
deviceId
:
string
)
=>
this
.
createConnection
(
deviceId
))
.
then
(
this
.
getDeviceServices
)
.
then
(
this
.
getDeviceServices
)
.
then
(
res
=>
{
.
then
(
res
=>
{
...
...
src/types/Shower/Shower.ts
View file @
4aaf14a6
import
{
OperationMode
}
from
'@/api/shower'
;
export
type
BluetoothDevice
=
{
export
type
BluetoothDevice
=
{
code
:
string
;
code
:
string
;
isOnlyBluetooth
:
number
;
isOnlyBluetooth
:
number
;
operationMode
:
OperationMode
;
position
:
string
;
position
:
string
;
};
};
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