import Taro, { Component } from '@tarojs/taro'
// import { queryIndexIcons } from '@/services/common'
// import { menus } from './icons.js'
import { connect } from '@tarojs/redux'
// import { ROLE_CODE } from '@/constants/user'
import './index.scss'

@connect(
    state => ({ ...state.project, ...state.city, ...state.user, system: state.system })
)

export default class Menus extends Component {

    static defaultProps = {
        menusList: []
    }
    componentWillMount() {
        console.log(this.props, "this.propsthis.propsthis.propsthis.propsthis.propsthis.props")
    }

    toMenuePage(item) {
        if (item.switchTab) {
            Taro.switchTab({
                url: item.url,
            })
            return
        }
        if (item.city) {
            Taro.navigateTo({
                url: item.url + this.props.curCity.id,
            })
            return
        }
        Taro.navigateTo({
            url: item.url,
        })
    }
    render() {
        const { menusList } = this.props
        return (
            <View className="mune-box" style={menusList.length == 3 ? "padding:0 8%" : ""}>
                {menusList.map((item, ginx) => (
                    <View onClick={() => this.toMenuePage(item)} className="mune-item" key={`menu- ${ginx}`}>
                        <Image className="icon" src={item.icon} ></Image>
                        <View className="mune-text"><Text>{item.name} </Text>{item.iconCode== 'refercustomers'&&<Image style="width:30rpx;height:30rpx;margin-left:4rpx" src={require('@/assets/award.png')} ></Image>}</View>
                      
                    </View>
                ))}
            </View>
        )
    }
}
