|
|
@@ -26,7 +26,8 @@ export default class PaymentListV2 extends Component {
|
|
|
options: [],
|
|
|
selectIndex: 0,
|
|
|
selectOptions: {},
|
|
|
- isloading: true
|
|
|
+ isloading: true,
|
|
|
+ delayTimes: 1738080000000
|
|
|
};
|
|
|
}
|
|
|
|
|
|
@@ -55,49 +56,81 @@ export default class PaymentListV2 extends Component {
|
|
|
apiCharge.getPaymentTypeOptions({
|
|
|
chargeBoxId: this.props.chargeBoxId
|
|
|
}).then(res => {
|
|
|
- if (res.data) {
|
|
|
- let index = 0;
|
|
|
+ if (utils.isNotEmpty(res.data)) {
|
|
|
if (this.props.payType && this.props.payType.code) {
|
|
|
- for (let i = 0; i < res.data.length; i++) {
|
|
|
- let type = res.data[i];
|
|
|
- if (type.code == this.props.payType.code) {
|
|
|
- index = i;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- let hasDef = false;
|
|
|
- for (let i = 0; i < res.data.length; i++) {
|
|
|
- let type = res.data[i];
|
|
|
- if (type.code == "fleet_group_wallet" || type.code == "fleet_individual_wallet") {
|
|
|
- index = i;
|
|
|
- type.def = true;
|
|
|
- hasDef = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!hasDef) {
|
|
|
+ this.setState({
|
|
|
+ options: res.data,
|
|
|
+ isloading: false
|
|
|
+ }, () => {
|
|
|
for (let i = 0; i < res.data.length; i++) {
|
|
|
let type = res.data[i];
|
|
|
- if (type.def) {
|
|
|
- index = i;
|
|
|
+ if (type.code == this.props.payType.code) {
|
|
|
+ this.changeMethod(i);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ let time = new Date().getTime();
|
|
|
+ if (time > this.state.delayTimes) {
|
|
|
+ this.setDataToChargEco(res.data);
|
|
|
+ } else {
|
|
|
+ this.setDataToDefault(res.data);
|
|
|
}
|
|
|
}
|
|
|
- this.setState({
|
|
|
- options: res.data,
|
|
|
- isloading: false
|
|
|
- }, () => {
|
|
|
- this.changeMethod(index);
|
|
|
- });
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ setDataToDefault(list) {
|
|
|
+ let index = 0;
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
+ let type = list[i];
|
|
|
+ if (type.def) {
|
|
|
+ index = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.setState({
|
|
|
+ options: list,
|
|
|
+ isloading: false
|
|
|
+ }, () => {
|
|
|
+ this.changeMethod(index);
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ setDataToChargEco(list) {
|
|
|
+ let index = 0;
|
|
|
+ let hasDef = false;
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
+ let type = list[i];
|
|
|
+ if (type.code == "fleet_group_wallet" || type.code == "fleet_individual_wallet") {
|
|
|
+ index = i;
|
|
|
+ type.def = true;
|
|
|
+ hasDef = true;
|
|
|
+ } else {
|
|
|
+ type.def = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!hasDef) {
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
+ let type = list[i];
|
|
|
+ if (type.def) {
|
|
|
+ index = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.setState({
|
|
|
+ options: list,
|
|
|
+ isloading: false
|
|
|
+ }, () => {
|
|
|
+ this.changeMethod(index);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
showDialog(visible) {
|
|
|
if (this.state.isSelect) {
|
|
|
this.setState({
|