import { Radio, RadioGroup, View } from "@tarojs/components";
import './index.less'
import { useMemo, useState } from "react";
import { Store } from "@src/app";
import { inject, observer } from "mobx-react";
import { setApp } from "@src/config";
interface Props {
    store?: Store;
    mar0?: boolean
    pay: (payData: any) => void//支付刷新小说内容
}
function ShubiBox(props?: Props) {
    let [eq, setEq] = useState(0)
    let [payData, setPayData] = useState<any>(null)
    let [ok, setOk] = useState(false)
    let data = useMemo(() => {
        let thatData = props?.store?.indexStore?.rechargeTemplate?.find(item => item.templateType === 1)
        let datas = thatData?.rechargeConfigs[0]?.rechargeConfigList
        setApp({ payData: datas[0] })
        setPayData(datas[0])
        return datas
    }, [props?.store?.indexStore?.rechargeTemplate])
    return <>
        <View className="shubi_box">
            {
                data?.map((item: {
                    color,//背景色
                    description,//整数购买文案
                    extra,//右上角描述值
                    gearType,//充值类型
                    gift,//赠送
                    obtain,//获得书币/vip每天价格
                    price,//价格
                    subscript,//右上角文案 首充|超值等
                    vipDays,//vip天数
                }, index) => {
                    return <View className={`shubi_box_k ${eq === index ? "ac" : ""}`} onClick={() => {
                        setEq(index)
                        setApp({ payData: item })
                        setPayData(item)
                    }}>
                        <View className="shubi_box_num">{item?.obtain}</View>
                        <View className="shubi_box_price">{item?.price}元</View>
                        <View className="shubi_box_give">赠{item.gift}书币</View>
                    </View>
                })
            }
        </View>
        <View className="shubi_box_btn" onClick={() => {
            setOk(true);
            props?.pay({templateIndex:eq, rechargeTemplateId: props?.store?.indexStore?.rechargeTemplate?.find(item => item.templateType === 1)?.id })
        }}>支付{payData?.price}元</View>
        {/* <View className={`shubi_box_gz ${props?.mar0 ? "mar_bom_0" : ""}`}>
            <RadioGroup onChange={(e: any) => {
                setOk(true)
            }}>
                <Radio checked={ok} value='选中' >已阅读并同意《充值规则》</Radio>
            </RadioGroup>

        </View> */}
    </>
}
export default inject('store')(observer(ShubiBox))
