import Taro, { Component } from '@tarojs/taro' import { View, Input, Picker, ScrollView, Button } from '@tarojs/components' import { Loading } from '@components' import { connect } from '@tarojs/redux' import * as actions from '@actions/template' import TemplateList from './templatelist' import { getWindowHeight } from '@utils/style' import './template.scss' @connect(state => state.home, { ...actions, }) class Template extends Component { config = { navigationBarTitleText: '模板管理' } state = { loaded: false, loading: false, lastItemId: 0, hasMore: true, selectorChecked: { id: 0, key: "按模板名称", value: 'title' }, selector: [ { id: 0, key: "按模板名称", value: 'title' }, { id: 1, key: "按标签", value: 'tags' },], keyword: "", dataList: [], } componentDidMount() { this.getData() } // 列表数据 getData = () => { this.setState({ loading: true }) let payload = { field: this.state.selectorChecked.value, keyword: this.state.keyword, } this.props.getList(payload).then((data) => { this.setState({ loading: false, dataList: data.items, }) }).catch(() => { this.setState({ loading: false }) }) } // 删除模板 deleteTemplate = (value) => { let payload = { id: value.id, } this.props.deleteTemplate(payload).then((data) => { this.setState({ loading: false, }) Taro.showToast({ title: "操作成功", icon: 'none' }) this.getData() }).catch(() => { this.setState({ loading: false }) }) } onChange = e => { this.setState({ selectorChecked: this.state.selector[e.detail.value], }) } onInput = e => { this.setState({ keyword: e.detail.value }) } render() { // if (!this.state.loaded) { // return // } const { } = this.props return ( {this.state.selectorChecked.key} ▼ { this.page = 1 this.getData() }} >搜索 { this.deleteTemplate(e) }} /> ) } } export default Template