index.jsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import Taro, { Component } from '@tarojs/taro'
  2. import { View, Image } from '@tarojs/components'
  3. import { arrToObj } from '@utils'
  4. import './index.scss'
  5. export default class List extends Component {
  6. constructor (props) {
  7. super(props)
  8. this.state = {
  9. curList: [],
  10. }
  11. }
  12. componentWillMount () {
  13. this.props.onRef(this)
  14. }
  15. getData = (curList) => {
  16. this.setState({
  17. curList
  18. })
  19. }
  20. viewHandle (cObj) {
  21. Taro.api.other.apichannelsclick({id: cObj.id}).then((res) => {
  22. wx.openChannelsActivity({
  23. finderUserName: 'sphlZcWrHXeeW4s',
  24. feedId: cObj.feed_id,
  25. })
  26. }).catch(() => {
  27. wx.openChannelsActivity({
  28. finderUserName: 'sphlZcWrHXeeW4s',
  29. feedId: cObj.feed_id,
  30. })
  31. })
  32. }
  33. render () {
  34. const { curList } = this.state
  35. const curItems = curList.map((item, index) => {
  36. return (
  37. <View className="lhl-item col-1" key={index} onClick={this.viewHandle.bind(this, item)}>
  38. <View className="lhl-img">
  39. <Image src={item.cover} className="img" />
  40. </View>
  41. <View className="lhl-info">
  42. <View className="lhl-p1s">{item.title}</View>
  43. <View className="lhl-p3">{item.create_at}</View>
  44. </View>
  45. </View>
  46. )
  47. })
  48. return (
  49. <View className="l-house-list">
  50. {curItems}
  51. </View>
  52. )
  53. }
  54. }