index.tsx 1.5 KB
Newer Older
hank committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
// import { ITempItem } from '../..'
import { ComponentClass } from 'react'
import Taro, { Component } from '@tarojs/taro'
import { View, Text, ScrollView } from '@tarojs/components'
import TempItem from '../temp_item'

import './index.scss'

type IProps = {
  templateInfo: [any]
  typeName?: string
  typeId: string
  clickItem?: () => void
}

interface PageState {}
interface PageOwnProps {}

interface HomeItem {
  props: IProps
  state: PageState
}

class HomeItem extends Component {
  goAll = () => {
    const { typeId, typeName } = this.props
    // Taro.navigateTo({ url: '/pages/home/device/my_film/index' })
    if (typeId) {
      Taro.navigateTo({
        url: `/pages/home/tempaltes/template_type_detail?typeId=${typeId}&typeName=${typeName}`
      })
      // Taro.navigateTo({ url: `/pages/home/device/my_film/index` })
    }
  }

  render() {
    const { templateInfo, typeName } = this.props
    return (
      <View className="home-item">
        <ScrollView scrollY>
          <View className="home-item-title">
            <Text className="title-name">{typeName ? typeName : ''}</Text>
            <Text className="btn-all" onClick={this.goAll}>
              查看全部
            </Text>
          </View>
          <View className="home-item-list">
            {templateInfo.map(item => {
              return <TempItem {...item} key={item.templateId} />
            })}
          </View>
        </ScrollView>
      </View>
    )
  }
}
export default HomeItem as ComponentClass<PageOwnProps, PageState>