import React, { Component } from 'react'; import './index.less'; import Assets from '@src/components/Assets'; import { formatMoney } from '@src/services/Tools'; import Modal from '../Modal'; import Tabs from '../Tabs'; import { SpecialRadioGroup } from '../Radio'; import Invite from '../Invite'; import Button from '../Button'; import { Main } from '../../stores/main'; import { Order } from '../../stores/order'; import { ServiceParamMap } from '../../../Constant'; export default class extends Component { constructor(props) { super(props); this.state = { tab: '2', pay: '', select: null, auth: true }; Main.getService('vip') .then(result => { result.package = result.package.map((row, index) => { row.label = `${row.title}: ¥${formatMoney(row.price)}`; row.value = ServiceParamMap.vip[index].value; return row; }); this.setState({ service: result }); }); } select(key) { Order.speedPay({ productType: 'service', service: 'vip', param: key }).then(result => { this.setState({ order: result }); this.changePay('alipay'); }); this.setState({ select: key }); } changePay(key) { const { order } = this.state; if (!order) return; this.setState({ info: {}, pay: key }); let handler = null; switch (key) { case 'wechatpay': handler = Order.wechatQr(order.id) .then((result) => { this.setState({ info: result }); }); break; case 'alipay': default: handler = Order.alipayQr(order.id) .then((result) => { this.setState({ info: result }); }); } handler.then(() => { this.queryPay(); }); } queryPay() { const { order, show } = this.state; if (this.time) { clearTimeout(this.time); } this.time = setTimeout(() => { Order.query(order.id) .then(result => { if (result) { // 支付成功 this.setState(); } else if (show) { this.queryPay(); } else { this.setState({ select: null, pay: null, order: null, info: null }); } }); }, 1000); } render() { const { show, onClose } = this.props; const { tab } = this.state; return (
this.setState({ tab: key })} /> {this[`renderTab${tab}`]()}
); } renderTab1() { const { pay, select, service = {}, order } = this.state; return (
this.select(key)} />
} onChange={key => this.changePay(key)} />
请使用手机微信或支付宝扫码付款
{order &&
支付金额: ¥ {order.money}
}
); } renderTab2() { const { data, onReal, onPrepare } = this.props; const { showInvite } = this.state; return (
{data.bindReal && 已完成}
6个月
{data.inviteNumber > 0 ? `7天 X ${data.inviteNumber}位好友` : '7天/每位好友'}
{data.bindPrepare && 已完成}
1个月
{showInvite && }
); } }