import { $getIsMemberPower } from '@/http/apiManager.js'
import appConfig from '@/config/appConfig.js'
// 计算 应该跳转的页面
export function navigateTo (channelUserId) {
    appConfig.channelUserId = channelUserId
    $getIsMemberPower().then((res) => {
        console.log('查询是否开启会员==>', res.bizData);
		// appConfig.redPacketIsOpen = res.bizData.redPacketIsOpen
		// appConfig.redbalance = res.bizData.balance
		// appConfig.redbalance = (1000 / 100).toFixed(2) 
        if (!res.bizData.memberIsOpen) {
            // 跳转到输入金额 页面； 
			const payH5 = uni.getStorageSync('payH5') // 改变存储
			if(payH5 && (appConfig.currentPageType == 'wechatH5' || appConfig.currentPageType == 'alipayH5')){
			 const info = JSON.parse(payH5)
			 if(info.env == "scan"){
                 uni.redirectTo({ url: '/pages/payment/index?tk='+info.tk+'&price='+info.price+'&order_no='+info.order_no+'&env='+info.env });
			 }else if(info.env == 'route'){
			    // uni.showToast({title: payH5,icon:'none',duration:3000})
                 uni.redirectTo({ url: '/pages/route/index?tk='+info.tk+'&env='+info.env });
			 }else{
                 uni.redirectTo({ url: '/pages/payway/index' });
			 }
			}else{
              uni.redirectTo({ url: '/pages/payway/index' });
			}
        } else {
            appConfig.memberBaseUrl = res.bizData.memberSiteUrl
            uni.redirectTo({
                url: '/pageMember/payMember/payMember'
            })
        }
    })
}
// 计算主题色
export function calcThemeColor (key = 'color') {
    const colorObj = {
        wechatLite: {
            color: '#35d757',
            bgColor: '#52cc701a',
            imgUrl: '/static/payIcon/wechat.svg'
        },
        alipayLite: {
            color: '#108ee9',
            BgColor: '#3476fe1a',
            imgUrl: '/static/payIcon/zfb.svg'
        },
        wechatH5: {
            color: '#35d757',
            bgColor: '#52cc701a',
            imgUrl: '/static/payIcon/wechat.svg'
        },
        alipayH5: {
            color: '#108ee9',
            bgColor: '#3476fe1a',
            imgUrl: '/static/payIcon/zfb.svg'
        },
        ysfpayH5: {
            color: '#FF4433',
            bgColor: '#ff44331a',
            imgUrl: '/static/payIcon/ysf.svg'
        },
        otherH5: {
            color: '#3D5D99',
            bgColor: '#334e801a',
            imgUrl: '/static/payIcon/UnionPay.svg'
        }
    }
    return colorObj[appConfig.currentPageType][key]
}