Commit 11e46672 by 姜雷

调整支付逻辑

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