Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
visualcloud
/
Vmatrix-client-taro
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
940b1464
authored
Aug 20, 2019
by
lirandong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 异步获取数据方法
parent
63e1dcf2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
84 deletions
+77
-84
src/actions/asyncCounter.ts
+38
-0
src/actions/counter.ts
+4
-24
src/constants/counter.ts
+0
-2
src/pages/home/device/device_bind/index.tsx
+11
-12
src/pages/home/device/device_list/index.tsx
+7
-12
src/pages/home/device/film_list/index.tsx
+7
-12
src/pages/home/tempaltes/index.tsx
+10
-22
No files found.
src/actions/asyncCounter.ts
0 → 100644
View file @
940b1464
import
api
from
'@/api/index'
import
{
setTempList
,
setDeviceList
,
setFilmData
}
from
'./counter'
/** 获取 模板市场 数据列表 */
export
function
getTempList
(
page
:
number
)
{
return
async
dsipatch
=>
{
try
{
const
{
list
,
count
}
=
await
api
.
common
.
getTempList
(
page
)
dsipatch
(
setTempList
(
list
,
count
))
}
catch
(
error
)
{
console
.
error
(
error
)
}
}
}
/** 获取我的视片列表 */
export
function
getDeviceList
(
page
:
number
)
{
return
async
dispatch
=>
{
try
{
const
{
list
,
count
}
=
await
api
.
common
.
getMyFilmsList
(
page
)
dispatch
(
setDeviceList
(
list
,
count
))
}
catch
(
error
)
{
console
.
error
(
error
)
}
}
}
/** 获取我的设备数据 */
export
function
getFilmList
(
page
:
number
)
{
return
async
dispatch
=>
{
try
{
const
{
list
,
count
}
=
await
api
.
common
.
getMyDeviceList
(
page
)
dispatch
(
setFilmData
(
list
,
count
))
}
catch
(
error
)
{
console
.
error
(
error
)
}
}
}
src/actions/counter.ts
View file @
940b1464
import
{
ADD
,
MINUS
,
ADD_TEMP_LIST
,
ADD_DEVICE_LIST
,
ADD_FILM_LIST
}
from
'../constants/counter'
export
const
add
=
()
=>
{
return
{
type
:
ADD
}
}
export
const
minus
=
()
=>
{
return
{
type
:
MINUS
}
}
// 异步的action
export
function
asyncAdd
()
{
return
dispatch
=>
{
setTimeout
(()
=>
{
dispatch
(
add
())
},
2000
)
}
}
import
{
ADD_TEMP_LIST
,
ADD_DEVICE_LIST
,
ADD_FILM_LIST
}
from
'../constants/counter'
/** 修改模板市场数据 */
export
function
change
TempList
(
list
:
any
[],
count
:
number
)
{
export
function
set
TempList
(
list
:
any
[],
count
:
number
)
{
return
{
list
,
count
,
...
...
@@ -30,7 +10,7 @@ export function changeTempList(list: any[], count: number) {
}
/** 修改我的视片数据 */
export
function
change
DeviceList
(
list
:
any
[],
count
:
number
)
{
export
function
set
DeviceList
(
list
:
any
[],
count
:
number
)
{
return
{
list
,
count
,
...
...
@@ -39,7 +19,7 @@ export function changeDeviceList(list: any[], count: number) {
}
/** 修改我的设备数据 */
export
function
change
FilmData
(
list
:
any
[],
count
:
number
)
{
export
function
set
FilmData
(
list
:
any
[],
count
:
number
)
{
return
{
list
,
count
,
...
...
src/constants/counter.ts
View file @
940b1464
export
const
ADD
=
'ADD'
export
const
MINUS
=
'MINUS'
export
const
ADD_TEMP_LIST
=
'ADD_TEMP_LIST'
export
const
ADD_FILM_LIST
=
'ADD_FILM_LIST'
export
const
ADD_DEVICE_LIST
=
'ADD_DEVICE_LIST'
src/pages/home/device/device_bind/index.tsx
View file @
940b1464
import
api
from
'@/api/index'
import
{
ComponentClass
}
from
'react'
import
{
connect
}
from
'@tarojs/redux'
import
{
showMyToast
}
from
'@/common/utils'
import
DeviceItem
from
'@/conpoments/device_item'
import
{
getFilmList
}
from
'@/actions/asyncCounter'
import
Taro
,
{
Component
,
Config
}
from
'@tarojs/taro'
import
{
View
,
Text
,
ScrollView
,
Button
,
Checkbox
}
from
'@tarojs/components'
import
'./index.scss'
import
{
showMyToast
}
from
'@/common/utils'
import
{
changeFilmData
}
from
'@/actions/counter'
type
PageStateProps
=
{
list
:
any
[]
...
...
@@ -14,7 +14,7 @@ type PageStateProps = {
}
type
PageDispatchProps
=
{
changeFilmData
:
(
list
:
any
[],
conut
:
number
)
=>
void
getFilmListData
:
(
page
:
number
)
=>
void
}
type
PageOwnProps
=
{}
...
...
@@ -38,8 +38,8 @@ interface DeviceSelect {
return
{
list
,
count
}
},
dispatch
=>
({
changeFilmData
(
list
:
any
[],
count
:
number
)
{
dispatch
(
changeFilmData
(
list
,
count
))
getFilmListData
(
page
:
number
)
{
dispatch
(
getFilmList
(
page
))
}
})
)
...
...
@@ -60,14 +60,13 @@ class DeviceSelect extends Component {
this
.
changeAllCheck
=
this
.
changeAllCheck
.
bind
(
this
)
}
async
componentWillMount
()
{
componentWillMount
()
{
this
.
getData
()
}
getData
()
{
const
{
page
}
=
this
.
state
try
{
const
{
list
,
count
}
=
await
api
.
common
.
getMyDeviceList
(
page
)
this
.
props
.
changeFilmData
(
list
,
count
)
}
catch
(
error
)
{
console
.
error
(
error
)
}
this
.
props
.
getFilmListData
(
page
)
}
changeItem
({
equipmentId
})
{
...
...
src/pages/home/device/device_list/index.tsx
View file @
940b1464
import
api
from
'@/api/index'
import
{
ComponentClass
}
from
'react'
import
{
AtSwipeAction
}
from
'taro-ui'
import
{
showMyToast
}
from
'@/common/utils'
import
Taro
,
{
Component
}
from
'@tarojs/taro'
import
DeviceItem
from
'@/conpoments/device_item'
import
{
showMyToast
}
from
'@/common/utils
'
import
{
getFilmList
}
from
'@/actions/asyncCounter
'
import
{
View
,
Text
,
ScrollView
}
from
'@tarojs/components'
import
'./index.scss'
import
{
connect
}
from
'@tarojs/redux'
import
{
changeFilmData
}
from
'@/actions/counter'
export
interface
IDeviceItem
{
filmId
:
any
...
...
@@ -32,7 +32,7 @@ type PageStateProps = {
}
type
PageDispatchProps
=
{
changeFilmData
:
(
list
:
any
[],
count
:
number
)
=>
void
getFilmListData
:
(
page
:
number
)
=>
void
}
type
PageOwnProps
=
{}
...
...
@@ -58,8 +58,8 @@ interface MyDevice {
return
{
list
,
count
}
},
dispacth
=>
({
changeFilmData
(
list
:
any
[],
count
:
number
)
{
dispacth
(
changeFilmData
(
list
,
count
))
getFilmListData
(
page
:
number
)
{
dispacth
(
getFilmList
(
page
))
}
})
)
...
...
@@ -84,13 +84,8 @@ class MyDevice extends Component {
async
getDate
()
{
const
{
page
}
=
this
.
state
try
{
const
{
list
,
count
}
=
await
api
.
common
.
getMyDeviceList
(
page
)
this
.
cancelModal
()
this
.
props
.
changeFilmData
(
list
,
count
)
}
catch
(
error
)
{
console
.
error
(
error
)
}
this
.
cancelModal
()
this
.
props
.
getFilmListData
(
page
)
}
selectAddDevice
()
{
...
...
src/pages/home/device/film_list/index.tsx
View file @
940b1464
...
...
@@ -4,8 +4,8 @@ import { AtSwipeAction } from 'taro-ui'
import
{
connect
}
from
'@tarojs/redux'
import
{
showMyToast
}
from
'@/common/utils'
import
Taro
,
{
Component
}
from
'@tarojs/taro'
import
{
changeDeviceList
}
from
'@/actions/counter'
import
{
View
,
ScrollView
}
from
'@tarojs/components'
import
{
getDeviceList
}
from
'@/actions/asyncCounter'
import
FilmListItem
from
'@/conpoments/film_list_item'
import
'./index.scss'
...
...
@@ -16,7 +16,7 @@ type PageStateProps = {
}
type
PageDispatchProps
=
{
changeDeviceList
:
(
list
:
any
,
count
:
number
)
=>
void
getDeviceListData
:
(
page
:
number
)
=>
void
}
type
PageOwnProps
=
{}
...
...
@@ -45,13 +45,13 @@ interface Films {
return
{
list
,
count
}
},
dispacth
=>
({
changeDeviceList
(
list
:
any
,
count
:
number
)
{
dispacth
(
changeDeviceList
(
list
,
count
))
getDeviceListData
(
page
:
number
)
{
dispacth
(
getDeviceList
(
page
))
}
})
)
class
Films
extends
Component
{
constructor
(
props
)
{
constructor
(
props
:
any
)
{
super
(
props
)
this
.
state
=
{
page
:
1
}
}
...
...
@@ -61,13 +61,8 @@ class Films extends Component {
}
async
getData
()
{
try
{
const
{
page
}
=
this
.
state
const
{
count
,
list
}
=
await
api
.
common
.
getMyFilmsList
(
page
)
this
.
props
.
changeDeviceList
(
list
,
count
)
}
catch
(
error
)
{
console
.
error
(
error
)
}
const
{
page
}
=
this
.
state
this
.
props
.
getDeviceListData
(
page
)
}
async
handleItem
({
filmId
}:
IMilmListItme
)
{
...
...
src/pages/home/tempaltes/index.tsx
View file @
940b1464
import
api
from
'@/api/index'
import
token
from
'@/common/token'
import
{
ComponentClass
}
from
'react'
import
{
connect
}
from
'@tarojs/redux'
import
{
changeTempList
}
from
'@/actions/c
ounter'
import
{
getTempList
}
from
'@/actions/asyncC
ounter'
import
Taro
,
{
Component
,
Config
}
from
'@tarojs/taro'
import
TempItem
from
'./conpoments/temp_item/temp_item'
import
{
View
,
Input
,
ScrollView
}
from
'@tarojs/components'
...
...
@@ -15,7 +13,7 @@ type PageStateProps = {
}
type
PageDispatchProps
=
{
changeTempList
:
(
list
:
any
[],
count
:
number
)
=>
void
getTempListData
:
(
page
:
number
)
=>
void
}
type
PageOwnProps
=
{}
...
...
@@ -37,15 +35,14 @@ interface Tempaltes {
return
{
list
,
count
}
},
dispatch
=>
({
changeTempList
(
list
,
count
)
{
dispatch
(
changeTempList
(
list
,
count
))
getTempListData
(
page
:
number
)
{
dispatch
(
getTempList
(
page
))
}
})
)
class
Tempaltes
extends
Component
{
config
:
Config
=
{
navigationBarTitleText
:
''
,
// navigationStyle: 'custom'
navigationStyle
:
process
.
env
.
TARO_ENV
===
'rn'
?
'custom'
:
'default'
}
constructor
(
props
)
{
...
...
@@ -56,21 +53,12 @@ class Tempaltes extends Component {
}
async
componentWillMount
()
{
try
{
// console.log('componentWillMount', )
// Taro.getStorage({ key: 'tokne' })
// .then(res => {
// console.log({ res })
// })
// .catch(error => {
// console.log({ error })
// })
// console.log('token.getToken()', token.getToken())
const
{
list
,
count
}
=
await
api
.
common
.
getTempList
(
this
.
state
.
page
)
this
.
props
.
changeTempList
(
list
,
count
)
}
catch
(
error
)
{
console
.
log
({
error
})
}
this
.
getData
()
}
getData
()
{
const
{
page
}
=
this
.
state
this
.
props
.
getTempListData
(
page
)
}
shouldComponentUpdate
(
nextProps
:
IProps
)
{
...
...
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