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
45ac19a1
authored
Aug 12, 2019
by
lirandong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 模板列表
parent
5815bb4a
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
56 deletions
+89
-56
project.config.json
+6
-2
src/api/client.ts
+1
-1
src/pages/home/tempaltes/index.less
+15
-1
src/pages/home/tempaltes/index.tsx
+34
-13
src/pages/home/tempaltes/temp_item.tsx
+0
-39
src/pages/home/tempaltes/temp_item/temp_item.less
+5
-0
src/pages/home/tempaltes/temp_item/temp_item.tsx
+28
-0
No files found.
project.config.json
View file @
45ac19a1
{
"miniprogramRoot"
:
"./dist
"
,
"miniprogramRoot"
:
"dist/
"
,
"projectname"
:
"Vmatrix-client-taro"
,
"description"
:
""
,
"appid"
:
"touristappid"
,
...
...
@@ -9,5 +9,8 @@
"postcss"
:
false
,
"minified"
:
false
},
"compileType"
:
"miniprogram"
"compileType"
:
"miniprogram"
,
"simulatorType"
:
"wechat"
,
"simulatorPluginLibVersion"
:
{},
"condition"
:
{}
}
\ No newline at end of file
src/api/client.ts
View file @
45ac19a1
...
...
@@ -8,7 +8,7 @@ interface IRequest {
config
?:
AxiosRequestConfig
}
export
class
ApiClient
{
protected
request
({
url
,
config
,
method
=
'POST'
,
data
=
{}
}:
IRequest
):
AxiosPromise
<
any
>
{
protected
request
({
url
,
config
,
method
=
'POST'
,
data
=
{}
}:
IRequest
):
any
{
return
axios
({
url
,
data
,
...
...
src/pages/home/tempaltes/index.less
View file @
45ac19a1
...
...
@@ -14,13 +14,27 @@
}
.search {
height: 100%;
padding: 0;
height: 100%;
padding-left: 10;
color: #969799;
background-color: #f7f8fa;
}
.scroll-view-wrapper {
flex: 1;
height: 100;
}
.scroll-view {
height: 100%;
// display: flex;
// flex-wrap: wrap;
// flex-direction: row;
padding-left: 10;
padding-right: 10;
}
.list-wrapper {
flex: 1;
}
src/pages/home/tempaltes/index.tsx
View file @
45ac19a1
import
{
ComponentClass
}
from
'react'
import
TempItem
from
'./temp_item/temp_item'
import
Taro
,
{
Component
,
Config
}
from
'@tarojs/taro'
import
{
View
,
Text
,
Input
,
ScrollView
}
from
'@tarojs/components'
import
{
View
,
Text
,
Input
,
ScrollView
,
Image
}
from
'@tarojs/components'
import
'./index.less'
import
api
from
'../../../api'
...
...
@@ -10,8 +11,16 @@ type PageDispatchProps = {}
type
PageOwnProps
=
{}
export
interface
ITempItem
{
templateId
:
string
templateUrl
:
string
templateName
:
string
}
type
PageState
=
{
name
:
string
dataList
:
ITempItem
[]
page
:
number
count
:
number
}
type
IProps
=
PageStateProps
&
PageDispatchProps
&
PageOwnProps
...
...
@@ -28,33 +37,45 @@ class Tempaltes extends Component {
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
name
:
'小红'
page
:
1
,
count
:
0
,
dataList
:
[]
}
}
async
componentDidMount
()
{
console
.
log
(
'componentDidMount'
)
async
componentWillMount
()
{
try
{
const
res
=
await
api
.
common
.
getTempList
(
1
)
console
.
log
({
res
})
const
{
list
,
count
}
=
await
api
.
common
.
getTempList
(
this
.
state
.
page
)
this
.
setState
({
count
,
dataList
:
list
})
}
catch
(
error
)
{
console
.
log
({
error
})
}
}
shouldComponentUpdate
(
_nextProps
,
nextState
)
{
const
{
dataList
}
=
nextState
const
{
dataList
:
Dl
}
=
this
.
state
return
Dl
!==
dataList
}
render
()
{
console
.
log
(
'componentDidMount'
)
const
{
dataList
}
=
this
.
state
// console.warn({ dataList })
return
(
<
View
className=
"tempaltes"
>
<
View
className=
"search-bar"
>
<
Input
className=
"search"
placeholder=
"请输入搜索关键词"
/>
</
View
>
<
ScrollView
>
<
Text
>
111111111111111
</
Text
>
<
View
className=
"scroll-view-wrapper"
>
<
ScrollView
className=
"scroll-view"
>
{
dataList
.
map
(
item
=>
(
<
TempItem
{
...
item
}
key=
{
item
.
templateId
}
/>
))
}
</
ScrollView
>
{
/* <View className="list-wrapper">
<Text>111111111111111</Text>
</View> */
}
</
View
>
</
View
>
)
}
...
...
src/pages/home/tempaltes/temp_item.tsx
deleted
100644 → 0
View file @
5815bb4a
import
{
ComponentClass
}
from
'react'
import
Taro
,
{
Component
}
from
'@tarojs/taro'
import
{
View
,
Text
}
from
'@tarojs/components'
import
'./index.less'
type
PageStateProps
=
{}
type
PageDispatchProps
=
{}
type
PageOwnProps
=
{}
type
PageState
=
{
name
:
string
}
type
IProps
=
PageStateProps
&
PageDispatchProps
&
PageOwnProps
interface
Item
{
props
:
IProps
state
:
PageState
}
class
Item
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
name
:
'小红'
}
}
render
()
{
return
(
<
View
className=
"item"
>
<
Text
>
hello world
</
Text
>
</
View
>
)
}
}
export
default
Item
as
ComponentClass
<
PageOwnProps
,
PageState
>
src/pages/home/tempaltes/temp_item/temp_item.less
0 → 100644
View file @
45ac19a1
.temp-item {
// self
width: 50%;
// background-color: black;
}
src/pages/home/tempaltes/temp_item/temp_item.tsx
0 → 100644
View file @
45ac19a1
import
{
ComponentClass
}
from
'react'
import
Taro
,
{
Component
}
from
'@tarojs/taro'
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
'./temp_item.less'
import
{
ITempItem
}
from
'..'
type
IProps
=
ITempItem
interface
PageState
{}
interface
PageOwnProps
{}
interface
TempItem
{
props
:
IProps
state
:
PageState
}
class
TempItem
extends
Component
{
render
()
{
const
{
templateName
,
templateUrl
:
url
}
=
this
.
props
return
(
<
View
className=
"temp-item"
>
<
Image
src=
{
url
}
/>
<
Text
>
{
templateName
}
</
Text
>
</
View
>
)
}
}
export
default
TempItem
as
ComponentClass
<
PageOwnProps
,
PageState
>
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