
import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components"
import { memo, useState } from "react"
import "./index.scss"

const weightListManager = ()=>{
  
  return(
    <View className="weight-list-manager">
      <WeightList />
    </View>
  )
}

interface Params{
  refresherEnabled?: boolean,//是否开启刷新
  onSelect?: (item:any,index:number)=>void,//列表选择

}
// 码单列表
const WeightList = memo((props:Params)=>{
  // 处理刷新
  const [refreshState, setRefreshState] = useState(false);
  const handleRefresh = ()=>{
    setRefreshState(true);
    setTimeout(()=>{
      setRefreshState(false);
    },500)
  }
  const data = Array.from({length:0});

  return (
    <View className="weight-list-scroll-view">
      <ScrollView scrollY refresherEnabled={props.refresherEnabled} enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}>
        {
          data.length>0?
          data.map((item,index)=>{
            return(
              <View onClick={()=>props.onSelect&&props.onSelect(item,index)} className="weight-list-list">
                <View className="weight-list-user">
                  XL纺织
                  <Text className="weight-list-list-default">默认</Text>
                  {/* <Text className="weight-list-list-phone">1656488999</Text> */}
                </View>
                <View className="weight-list-list-bottom">
                  <View className="weight-list-list-info">
                    **省**市**区**街道****仓库
                    <Text className="weight-list-list-phone">181****9790</Text>
                  </View>
                  <Navigator url="/pages/weightListAdd/index?type=edit" hoverClass="none" className="weight-list-edit">
                    <Text className="iconfont icon-bianji"></Text>
                  </Navigator>
                </View>
              </View>
            );
          }):
          <View className="weight-list-no-data">
            <View>您末添加任何码单信息</View>
            正在使用平台默认码单信息
          </View>
        }
      </ScrollView>
      <Navigator url="/pages/weightListAdd/index?type=add" hoverClass="none" className="add-weight-list">添加新码单信息</Navigator>
    </View>
  )
})

export default weightListManager;