Commit 11e46672 by 姜雷

调整支付逻辑

parent e0526383
......@@ -64,6 +64,8 @@ class Index extends Component {
this.loginHandle().then(() => {
const { userinfo } = this.props;
let queryArr = Object.keys(this.$router.params);
console.log(this.$router.params);
let scene: string = queryArr.length > 0 ? queryArr[0] : '';
console.log('scene:', scene);
......@@ -138,13 +140,13 @@ class Index extends Component {
})
.then(res => {
console.log(res);
const { deviceInfoResponse, prepayConfigs } = res.data;
const { deviceInfoResponse, prepayConfigs } = res;
if (deviceInfoResponse.isUsed) {
console.log('设备使用中');
return;
}
updateDeviceData(deviceInfoResponse);
updatePayData(prepayConfigs);
deviceInfoResponse && updateDeviceData(deviceInfoResponse);
prepayConfigs && updatePayData(prepayConfigs);
Taro.navigateTo({
url: '/pages/pay/pay',
});
......
......@@ -10,7 +10,7 @@ import AES from 'crypto-js/aes';
import Utf8 from 'crypto-js/enc-utf8';
import ECBmode from 'crypto-js/mode-ecb';
import PaddingPkcs7 from 'crypto-js/pad-pkcs7';
import { paySuccess } from '../../api/Order/paySuccess';
// import { paySuccess } from '../../api/Order/paySuccess';
type PageStateProps = {
device: Device;
......@@ -62,13 +62,13 @@ class Pay extends Component {
getPayOrder({
equipmentNum: device.code,
equipmentPos: device.position,
payType: '',
serviceId: 0,
payType: '2',
serviceId: device.serviceId,
smaproCustomerId: customerId,
smaproPrepayConfigId: payId,
})
.then(res => {
const { payStr, outTradeNo } = res;
const { payStr } = res;
const key = customerId.toString().padEnd(16, '0');
const payData = JSON.parse(
AES.decrypt(payStr, Utf8.parse(key), {
......@@ -85,11 +85,21 @@ class Pay extends Component {
paySign: payData.msg.paySign,
}).then(res => {
console.log(res);
paySuccess({ orderId: outTradeNo });
Taro.showLoading({
title: '设备连接中',
// paySuccess({ orderId: outTradeNo });
// Taro.showLoading({
// title: '设备连接中',
// mask: true,
// });
Taro.showToast({
title: '支付成功!',
icon: 'success',
mask: true,
});
setTimeout(() => {
Taro.navigateTo({
url: '/pages/index/index?', // 需要问号不然回到首页可以取到业务参数
});
}, 2000);
});
})
.catch(err => {
......@@ -115,15 +125,11 @@ class Pay extends Component {
<View className='Pay-info'>
<View className='Pay-info-item'>
<Text>服务类型</Text>
<Text>
{prepayConfig && prepayConfig.length
? prepayConfig[0].serviceName
: ''}
</Text>
<Text>{device.serviceName ? device.serviceName : ''}</Text>
</View>
<View className='Pay-info-item'>
<Text>设备编号</Text>
<Text>{device.code}</Text>
<Text>{device.code ? device.code : ''}</Text>
</View>
<View className='Pay-info-item'>
<Text>设备位置</Text>
......@@ -153,7 +159,9 @@ class Pay extends Component {
温馨提示:如本次预付款未全部使用,系统将在使用结束后半小时内自动退还剩余金额,请留意查收!
</View>
<View className='Pay-money'>
{prepayConfig.map(payConfig => (
{prepayConfig &&
prepayConfig.length &&
prepayConfig.map(payConfig => (
<View
key={payConfig.id}
className={`Pay-money-item ${
......
......@@ -4,7 +4,7 @@ import { PrepayConfig } from '../../types/Order/Order';
export const INITIAL_STATE = [];
export const updatePayData = (entity: PrepayConfig[]): Action => ({
type: 'UPDATE_DEVICE_DATA',
type: 'UPDATE_PAY_DATA',
payload: entity,
});
......@@ -13,11 +13,8 @@ export default function prepayConfig(
actions: Action,
): PrepayConfig[] {
switch (actions.type) {
case 'UPDATE_DEVICE_DATA':
return {
...state,
...actions.payload,
};
case 'UPDATE_PAY_DATA':
return [...state, ...actions.payload];
default:
return state;
}
......
......@@ -12,4 +12,6 @@ export type Device = {
position: string;
positionId: string;
rates: Rate[];
serviceId: number;
serviceName: string;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment