Commit 45ac19a1 by lirandong

优化 模板列表

parent 5815bb4a
{ {
"miniprogramRoot": "./dist", "miniprogramRoot": "dist/",
"projectname": "Vmatrix-client-taro", "projectname": "Vmatrix-client-taro",
"description": "", "description": "",
"appid": "touristappid", "appid": "touristappid",
...@@ -9,5 +9,8 @@ ...@@ -9,5 +9,8 @@
"postcss": false, "postcss": false,
"minified": false "minified": false
}, },
"compileType": "miniprogram" "compileType": "miniprogram",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {}
} }
\ No newline at end of file
...@@ -8,7 +8,7 @@ interface IRequest { ...@@ -8,7 +8,7 @@ interface IRequest {
config?: AxiosRequestConfig config?: AxiosRequestConfig
} }
export class ApiClient { export class ApiClient {
protected request({ url, config, method = 'POST', data = {} }: IRequest): AxiosPromise<any> { protected request({ url, config, method = 'POST', data = {} }: IRequest): any {
return axios({ return axios({
url, url,
data, data,
......
...@@ -14,13 +14,27 @@ ...@@ -14,13 +14,27 @@
} }
.search { .search {
height: 100%;
padding: 0; padding: 0;
height: 100%;
padding-left: 10; padding-left: 10;
color: #969799; color: #969799;
background-color: #f7f8fa; 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 { .list-wrapper {
flex: 1; flex: 1;
} }
import { ComponentClass } from 'react' import { ComponentClass } from 'react'
import TempItem from './temp_item/temp_item'
import Taro, { Component, Config } from '@tarojs/taro' 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 './index.less'
import api from '../../../api' import api from '../../../api'
...@@ -10,8 +11,16 @@ type PageDispatchProps = {} ...@@ -10,8 +11,16 @@ type PageDispatchProps = {}
type PageOwnProps = {} type PageOwnProps = {}
export interface ITempItem {
templateId: string
templateUrl: string
templateName: string
}
type PageState = { type PageState = {
name: string dataList: ITempItem[]
page: number
count: number
} }
type IProps = PageStateProps & PageDispatchProps & PageOwnProps type IProps = PageStateProps & PageDispatchProps & PageOwnProps
...@@ -28,33 +37,45 @@ class Tempaltes extends Component { ...@@ -28,33 +37,45 @@ class Tempaltes extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
name: '小红' page: 1,
count: 0,
dataList: []
} }
} }
async componentDidMount() { async componentWillMount() {
console.log('componentDidMount')
try { try {
const res = await api.common.getTempList(1) const { list, count } = await api.common.getTempList(this.state.page)
console.log({ res }) this.setState({
count,
dataList: list
})
} catch (error) { } catch (error) {
console.log({ error }) console.log({ error })
} }
} }
shouldComponentUpdate(_nextProps, nextState) {
const { dataList } = nextState
const { dataList: Dl } = this.state
return Dl !== dataList
}
render() { render() {
console.log('componentDidMount') const { dataList } = this.state
// console.warn({ dataList })
return ( return (
<View className="tempaltes"> <View className="tempaltes">
<View className="search-bar"> <View className="search-bar">
<Input className="search" placeholder="请输入搜索关键词" /> <Input className="search" placeholder="请输入搜索关键词" />
</View> </View>
<ScrollView> <View className="scroll-view-wrapper">
<Text>111111111111111</Text> <ScrollView className="scroll-view">
{dataList.map(item => (
<TempItem {...item} key={item.templateId} />
))}
</ScrollView> </ScrollView>
{/* <View className="list-wrapper"> </View>
<Text>111111111111111</Text>
</View> */}
</View> </View>
) )
} }
......
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>
.temp-item {
// self
width: 50%;
// background-color: black;
}
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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment