Commit 50fa246e by 姜雷

修改订单逻辑

parent 64a695e5
...@@ -22,9 +22,8 @@ class Response { ...@@ -22,9 +22,8 @@ class Response {
} }
export const fetchAnn = (data: Parmas) => export const fetchAnn = (data: Parmas) =>
schoolMainFetch({ schoolMainFetch({
url: `/dcxy/app/homepage/campus/${data.campusId}/publishedSections/${ url: '/dcxy/wechat/homepage/campus/publishedSections',
data.customerId data: data,
}`,
}).then((res: ResponseDataEntity<Response>) => { }).then((res: ResponseDataEntity<Response>) => {
const data = res.data; const data = res.data;
return data.sections.find(item => item.styleType == 'ANNOUNCEMENT'); return data.sections.find(item => item.styleType == 'ANNOUNCEMENT');
...@@ -64,7 +63,6 @@ export const fetchAllAnn = ( ...@@ -64,7 +63,6 @@ export const fetchAllAnn = (
data: AllParmas, data: AllParmas,
): Promise<ResponseDataEntity<AllResponse>> => ): Promise<ResponseDataEntity<AllResponse>> =>
schoolMainFetch({ schoolMainFetch({
url: `/dcxy/app/homepage/campus/${data.campusId}/publishedItems/${ url: '/dcxy/wechat/homepage/campus/publishedItems',
data.sectionId data: data,
}`,
}); });
import { customerFetch, ResponseDataEntity } from '.'; import { customerFetch } from '.';
import { LoginInfoVo } from './baseClass';
export class LoginParams { export class LoginParams {
/** 登陆标识 */ /** 登陆标识 */
...@@ -18,7 +17,7 @@ export const appLogin = (data: LoginParams) => ...@@ -18,7 +17,7 @@ export const appLogin = (data: LoginParams) =>
export const appLogout = () => export const appLogout = () =>
customerFetch({ customerFetch({
url: '/app/customer/login/out', url: '/dcxy/wechat/applet/login/out',
}); });
export class PwdParams { export class PwdParams {
...@@ -33,6 +32,7 @@ export const changePwdByCellphone = (data: PwdParams) => ...@@ -33,6 +32,7 @@ export const changePwdByCellphone = (data: PwdParams) =>
customerFetch({ customerFetch({
url: '/app/customer/forget/pwd', url: '/app/customer/forget/pwd',
method: 'POST', method: 'POST',
data: data,
}); });
type RegisiterPramas = {}; type RegisiterPramas = {};
...@@ -59,7 +59,7 @@ type perfectionCustomerParams = { ...@@ -59,7 +59,7 @@ type perfectionCustomerParams = {
export const perfectionUserInfo = (entity: perfectionCustomerParams) => export const perfectionUserInfo = (entity: perfectionCustomerParams) =>
customerFetch({ customerFetch({
url: '/app/customer/perfection/customer', url: '/dcxy/wechat/applet/perfection/customer',
method: 'POST', method: 'POST',
data: entity, data: entity,
}); });
import { ConsumeOrderResponse, ConsumeOrder } from './baseClass'; import { customerFetch } from './index';
import { customerFetch, ResponseDataEntity } from './index';
export class Params { export class Params {
/** 会员id */ /** 会员id */
......
...@@ -4,4 +4,5 @@ export const OLD_BASE_SERVER_URL = 'https://ex-dev-selfbase.168cad.top'; ...@@ -4,4 +4,5 @@ export const OLD_BASE_SERVER_URL = 'https://ex-dev-selfbase.168cad.top';
export const BASE_SERVER_URL = 'https://ex-dev-dcxy-base-app.168cad.top'; export const BASE_SERVER_URL = 'https://ex-dev-dcxy-base-app.168cad.top';
export const CUSTOMER_SERVER_URL = export const CUSTOMER_SERVER_URL =
'https://ex-dev-dcxy-customer-app.168cad.top'; 'https://ex-dev-dcxy-customer-app.168cad.top';
export const SCHOOL_MAIN_URL = 'http://internal-dev-school-main.168cad.top'; export const SCHOOL_MAIN_URL = 'https://internal-dev-school-main.168cad.top';
export const ANN_LINK_URL = 'https://internal-dev-school-homepage.168cad.top/';
import { Component } from '@tarojs/taro'; import { Component } from '@tarojs/taro';
import { ComponentClass } from 'react'; import { ComponentClass } from 'react';
import { View, ScrollView, Image, Text } from '@tarojs/components'; import { View, ScrollView, Image, Text, WebView } from '@tarojs/components';
import AnnIcon from '../../images/icon/ann_tongzhi_icon@2x.png'; import AnnIcon from '../../images/icon/ann_tongzhi_icon@2x.png';
import { fetchAllAnn, AnnItem } from '../../api/announcement'; import { fetchAllAnn, AnnItem } from '../../api/announcement';
...@@ -8,6 +8,7 @@ import { connect } from '@tarojs/redux'; ...@@ -8,6 +8,7 @@ import { connect } from '@tarojs/redux';
import { UserState } from '../../store/rootReducers/userinfo'; import { UserState } from '../../store/rootReducers/userinfo';
import './Announcement.scss'; import './Announcement.scss';
import { ANN_LINK_URL } from '../../constants';
type PageStateProps = { type PageStateProps = {
userinfo: UserState; userinfo: UserState;
...@@ -17,6 +18,7 @@ type PageState = { ...@@ -17,6 +18,7 @@ type PageState = {
pageNum: number; pageNum: number;
pageSize: number; pageSize: number;
list: AnnItem[]; list: AnnItem[];
linkUrl: string;
}; };
interface Announcement { interface Announcement {
...@@ -34,6 +36,7 @@ class Announcement extends Component { ...@@ -34,6 +36,7 @@ class Announcement extends Component {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
list: [], list: [],
linkUrl: '',
}; };
} }
componentWillMount() { componentWillMount() {
...@@ -51,63 +54,24 @@ class Announcement extends Component { ...@@ -51,63 +54,24 @@ class Announcement extends Component {
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
this.setState({
pageNum: 1,
pageSize: 10,
pages: 1,
total: 2,
list: [
{
id: 301070,
title: 'ASFDSGSD大苏打',
multiImageType: 'SINGLE',
source: '关机开不开地方',
linkUrls: ['sqwerqwerqwefsf'],
linkType: 'DEFAULT',
jumpUrl: '',
urlParameters: {},
sort: 1,
enabled: true,
loadAd: false,
mandatoryPrompt: false,
effectTime: 1529431320000,
expirationTime: 1530129600000,
createTime: '2018-06-01 10:41:11',
updateTime: '2019-01-25 09:43:17',
},
{
id: 301073,
title: '啊实打实的阿斯顿',
multiImageType: 'SINGLE',
source: '个撒大',
linkUrls: ['sqwerqwerqwefsf'],
linkType: 'DEFAULT',
jumpUrl: '',
urlParameters: {},
sort: 2,
enabled: true,
loadAd: false,
mandatoryPrompt: false,
createTime: '2018-06-12 10:52:15',
updateTime: '2019-01-25 09:47:39',
},
],
});
}); });
} }
geAnnDetail(id: number) { geAnnDetail(id: number, title: string) {
console.log(id); console.log(id);
this.setState({
linkUrl: `${ANN_LINK_URL}/Content/${id}?title=${title}`,
});
} }
render() { render() {
const { list } = this.state; const { list, linkUrl } = this.state;
return ( return (
<ScrollView className='Announcement' scroll-y> <ScrollView className='Announcement' scroll-y>
{linkUrl && <WebView src={linkUrl} />}
{list.map(annItem => ( {list.map(annItem => (
<View <View
key={annItem.id} key={annItem.id}
className='Announcement-item' className='Announcement-item'
onClick={() => this.geAnnDetail(annItem.id)} onClick={() => this.geAnnDetail(annItem.id, annItem.title)}>
>
<Image <Image
className='Announcement-item-img' className='Announcement-item-img'
src={annItem.linkUrls[0]} src={annItem.linkUrls[0]}
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
padding: 0 32px; padding: 0 32px;
z-index: 2; z-index: 100;
background-color: rgba(255, 255, 255, 0.5); background-color: rgba(255, 255, 255, 0.5);
} }
.blur { .blur {
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
height: 436px; height: 436px;
} }
.BarCodeImg { .BarCodeImg {
position: relative;
z-index: 1;
flex: 1; flex: 1;
margin: 26px 52px 46px; margin: 26px 52px 46px;
background-color: #fff; background-color: #fff;
......
...@@ -17,7 +17,11 @@ import { ...@@ -17,7 +17,11 @@ import {
import OrderInfo from '../Order/components/OrderInfo/OrderInfo'; import OrderInfo from '../Order/components/OrderInfo/OrderInfo';
import OrderTitle from '../Order/components/OrderTitle/OrderTitle'; import OrderTitle from '../Order/components/OrderTitle/OrderTitle';
import OrderPayway from '../Order/components/OrderPayway/OrderPayway'; import OrderPayway from '../Order/components/OrderPayway/OrderPayway';
import { ConsumeOrder, PaymentAndActiveInfo } from '../../api/baseClass'; import {
ConsumeOrder,
PaymentAndActiveInfo,
CustomerBeanAccountVo,
} from '../../api/baseClass';
type PageStateProps = { type PageStateProps = {
userinfo: UserState; userinfo: UserState;
...@@ -26,6 +30,7 @@ type PageOwnProps = {}; ...@@ -26,6 +30,7 @@ type PageOwnProps = {};
type PageState = { type PageState = {
showPayOrder: boolean; showPayOrder: boolean;
showBig: boolean; showBig: boolean;
accounts: CustomerBeanAccountVo[];
orderInfo: ConsumeOrder; orderInfo: ConsumeOrder;
payInfos: { payInfos: {
paymentAndActiveInfos: PaymentAndActiveInfo[]; paymentAndActiveInfos: PaymentAndActiveInfo[];
...@@ -59,6 +64,7 @@ class BarCode extends Component { ...@@ -59,6 +64,7 @@ class BarCode extends Component {
this.state = { this.state = {
showPayOrder: false, showPayOrder: false,
showBig: false, showBig: false,
accounts: [],
orderInfo: { orderInfo: {
actualMoney: undefined, actualMoney: undefined,
areaId: undefined, areaId: undefined,
...@@ -115,12 +121,13 @@ class BarCode extends Component { ...@@ -115,12 +121,13 @@ class BarCode extends Component {
if (res.data.length) { if (res.data.length) {
this.fetchOrder(res.data[0].id); this.fetchOrder(res.data[0].id);
this.setState({ showPayOrder: true }); this.setState({ showPayOrder: true });
} else {
this.drawBarCode(false);
} }
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
}); });
wxbarcode.barcode('BarCode', userinfo.idBar, 646, 188);
} }
fetchOrder(id: number) { fetchOrder(id: number) {
...@@ -134,23 +141,6 @@ class BarCode extends Component { ...@@ -134,23 +141,6 @@ class BarCode extends Component {
orderInfo: orderInfo, orderInfo: orderInfo,
payInfos: payInfos, payInfos: payInfos,
}); });
fetchDeductionInfo({
orderId: orderInfo.id,
payType: '',
paymentConfId: payInfos.paymentConfId,
})
.then(res => {
this.setState({
deductionInfos: res.data,
});
})
.catch(err => {
console.log(err);
Taro.showToast({
title: '获取抵扣信息失败',
icon: 'none',
});
});
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
...@@ -158,9 +148,15 @@ class BarCode extends Component { ...@@ -158,9 +148,15 @@ class BarCode extends Component {
} }
payDoneHandle() { payDoneHandle() {
this.setState({ const { showBig } = this.state;
this.setState(
{
showPayOrder: false, showPayOrder: false,
}); },
() => {
this.drawBarCode(showBig);
},
);
} }
drawBarCode(showBig: boolean) { drawBarCode(showBig: boolean) {
const { userinfo } = this.props; const { userinfo } = this.props;
...@@ -181,13 +177,7 @@ class BarCode extends Component { ...@@ -181,13 +177,7 @@ class BarCode extends Component {
render() { render() {
const { userinfo } = this.props; const { userinfo } = this.props;
const { const { showPayOrder, showBig, orderInfo, payInfos, accounts } = this.state;
showPayOrder,
showBig,
orderInfo,
payInfos,
deductionInfos,
} = this.state;
return ( return (
<View className='BarCode'> <View className='BarCode'>
{showPayOrder && ( {showPayOrder && (
...@@ -195,11 +185,11 @@ class BarCode extends Component { ...@@ -195,11 +185,11 @@ class BarCode extends Component {
<OrderTitle price={orderInfo.payableMoney} /> <OrderTitle price={orderInfo.payableMoney} />
<OrderInfo orderInfo={orderInfo} /> <OrderInfo orderInfo={orderInfo} />
<OrderPayway <OrderPayway
payDoneCallback={this.payDoneHandle} onPayDoneCallback={this.payDoneHandle}
userinfo={userinfo} userinfo={userinfo}
orderId={orderInfo.id} accounts={accounts}
orderInfo={orderInfo}
payInfos={payInfos} payInfos={payInfos}
deductionInfos={deductionInfos}
/> />
</View> </View>
)} )}
...@@ -207,8 +197,7 @@ class BarCode extends Component { ...@@ -207,8 +197,7 @@ class BarCode extends Component {
<View <View
className={`BarCodeBox ${showPayOrder ? 'blur' : ''} ${ className={`BarCodeBox ${showPayOrder ? 'blur' : ''} ${
showBig ? 'BarCodeBoxBig' : '' showBig ? 'BarCodeBoxBig' : ''
}`} }`}>
>
{showBig ? ( {showBig ? (
<Image className='bg' src={BarCodeBoxBigBg} /> <Image className='bg' src={BarCodeBoxBigBg} />
) : ( ) : (
...@@ -218,7 +207,9 @@ class BarCode extends Component { ...@@ -218,7 +207,9 @@ class BarCode extends Component {
<Image className='BarCodeBox-refresh' src={RefreshIcon} /> <Image className='BarCodeBox-refresh' src={RefreshIcon} />
)} )}
<View className={`BarCodeImg ${showBig ? 'BarCodeImgBig' : ''}`}> <View className={`BarCodeImg ${showBig ? 'BarCodeImgBig' : ''}`}>
{showPayOrder ? null : (
<Canvas className='BarCodeCav' canvasId='BarCode' /> <Canvas className='BarCodeCav' canvasId='BarCode' />
)}
</View> </View>
<View className='toggleBtn' onClick={this.toggleBigBarCode}> <View className='toggleBtn' onClick={this.toggleBigBarCode}>
{showBig ? '缩小' : '放大'} {showBig ? '缩小' : '放大'}
......
...@@ -95,51 +95,51 @@ class Home extends Component { ...@@ -95,51 +95,51 @@ class Home extends Component {
} }
}) })
.catch(err => { .catch(err => {
this.setState({ // this.setState({
annItem: { // annItem: {
id: 896, // id: 896,
styleType: 'ANNOUNCEMENT', // styleType: 'ANNOUNCEMENT',
name: '公告1', // name: '公告1',
titleTypeRemark: '无', // titleTypeRemark: '无',
titleType: 'NONE', // titleType: 'NONE',
titleContent: '', // titleContent: '',
sort: 3, // sort: 3,
updateTime: 1528770103000, // updateTime: 1528770103000,
itemsCount: 10, // itemsCount: 10,
items: [ // items: [
{ // {
id: 301070, // id: 301070,
title: 'ASFDSGSD大苏打', // title: 'ASFDSGSD大苏打',
multiImageType: 'SINGLE', // multiImageType: 'SINGLE',
source: '关机开不开地方', // source: '关机开不开地方',
linkUrls: ['sqwerqwerqwefsf'], // linkUrls: ['sqwerqwerqwefsf'],
linkType: 'DEFAULT', // linkType: 'DEFAULT',
jumpUrl: '', // jumpUrl: '',
urlParameters: {}, // urlParameters: {},
sort: 1, // sort: 1,
loadAd: false, // loadAd: false,
mandatoryPrompt: false, // mandatoryPrompt: false,
createTime: '2018-06-01 10:41:11', // createTime: '2018-06-01 10:41:11',
updateTime: '2019-01-25 09:43:17', // updateTime: '2019-01-25 09:43:17',
}, // },
{ // {
id: 301073, // id: 301073,
title: '啊实打实的阿斯顿', // title: '啊实打实的阿斯顿',
multiImageType: 'SINGLE', // multiImageType: 'SINGLE',
source: '个撒大', // source: '个撒大',
linkUrls: ['sqwerqwerqwefsf'], // linkUrls: ['sqwerqwerqwefsf'],
linkType: 'DEFAULT', // linkType: 'DEFAULT',
jumpUrl: '', // jumpUrl: '',
urlParameters: {}, // urlParameters: {},
sort: 2, // sort: 2,
loadAd: false, // loadAd: false,
mandatoryPrompt: false, // mandatoryPrompt: false,
createTime: '2018-06-12 10:52:15', // createTime: '2018-06-12 10:52:15',
updateTime: '2019-01-25 09:47:39', // updateTime: '2019-01-25 09:47:39',
}, // },
], // ],
}, // },
}); // });
console.error(err); console.error(err);
}); });
} }
......
import { ComponentClass } from 'react'; import { ComponentClass } from 'react';
import Taro, { Component, Config } from '@tarojs/taro'; import Taro, { Component, Config } from '@tarojs/taro';
import { View, Button, Text, Input, Navigator } from '@tarojs/components'; import { View, Button, Input, Navigator } from '@tarojs/components';
import './Login.scss'; import './Login.scss';
import { appLogin } from '../../api/customer'; import { appLogin } from '../../api/customer';
......
...@@ -27,6 +27,9 @@ page { ...@@ -27,6 +27,9 @@ page {
justify-content: space-between; justify-content: space-between;
font-size: 28px; font-size: 28px;
color: #333; color: #333;
.deduction {
color: #ff1010;
}
} }
.OrderDetail-line { .OrderDetail-line {
margin: 10px auto; margin: 10px auto;
......
import { ComponentClass } from 'react'; import { ComponentClass } from 'react';
import Taro, { Component, Config } from '@tarojs/taro'; import Taro, { Component, Config } from '@tarojs/taro';
import { View, Text, Image } from '@tarojs/components'; import { View, Text } from '@tarojs/components';
import OrderTitle from '../components/OrderTitle/OrderTitle'; import OrderTitle from '../components/OrderTitle/OrderTitle';
import OrderInfo from '../components/OrderInfo/OrderInfo'; import OrderInfo from '../components/OrderInfo/OrderInfo';
import comLogo from '../../../images/order/pay_logo_icon@2x.png';
import './OrderDetail.scss'; import './OrderDetail.scss';
import { fetchOrderDetail, fetchOrderDetailAndPay } from '../../../api/order'; import { fetchOrderDetailAndPay } from '../../../api/order';
import { PayType, getPayType } from '../../../utils/payType'; import { PayType, getPayType } from '../../../utils/payType';
type pageProps = {}; type pageProps = {};
type PageState = { type PageState = {
actualMoney: 0; actualMoney: number;
areaId: 0; areaId: number;
areaName: string; areaName: string;
consumeType: string; consumeType: string;
createAt: string; createAt: string;
customerCellphone: string; customerCellphone: string;
customerId: 0; customerId: number;
customerName: string; customerName: string;
deductionBean: 0; deductionBean: number;
deductionMoney: 0; deductionMoney: number;
equipmentNum: string; equipmentNum: string;
equipmentPosition: string; equipmentPosition: string;
id: 0; id: number;
operateId: 0; operateId: number;
operateName: string; operateName: string;
operationMode: string; operationMode: string;
orderName: string; orderName: string;
...@@ -33,10 +32,10 @@ type PageState = { ...@@ -33,10 +32,10 @@ type PageState = {
orderState: string; orderState: string;
outTradeNo: string; outTradeNo: string;
payType: PayType; payType: PayType;
payableMoney: 0; payableMoney: number;
serviceId: 0; serviceId: number;
serviceName: string; serviceName: string;
thirdDiscountMoney: 0; thirdDiscountMoney: number;
thirdTradeNumber: string; thirdTradeNumber: string;
updateDate: string; updateDate: string;
}; };
...@@ -96,6 +95,9 @@ class OrderDetail extends Component { ...@@ -96,6 +95,9 @@ class OrderDetail extends Component {
id: id, id: id,
}) })
.then(res => { .then(res => {
this.setState({
...res.data,
});
console.log(res); console.log(res);
}) })
.catch(err => { .catch(err => {
...@@ -122,12 +124,14 @@ class OrderDetail extends Component { ...@@ -122,12 +124,14 @@ class OrderDetail extends Component {
<View className='OrderDetail'> <View className='OrderDetail'>
<OrderTitle price={payableMoney} /> <OrderTitle price={payableMoney} />
<OrderInfo <OrderInfo
serviceName={serviceName} orderInfo={{
createAt={createAt} serviceName,
orderNumber={orderNumber} createAt,
areaName={areaName} orderNumber,
equipmentNum={equipmentNum} areaName,
equipmentPosition={equipmentPosition} equipmentNum,
equipmentPosition,
}}
/> />
<View className='OrderDetail-line' /> <View className='OrderDetail-line' />
<View className='OrderDetail-payinfo'> <View className='OrderDetail-payinfo'>
...@@ -137,13 +141,13 @@ class OrderDetail extends Component { ...@@ -137,13 +141,13 @@ class OrderDetail extends Component {
{deductionBean ? ( {deductionBean ? (
<View className='OrderDetail-payinfo'> <View className='OrderDetail-payinfo'>
<Text>通用豆抵扣</Text> <Text>通用豆抵扣</Text>
<Text>{deductionBean.toFixed(2)}</Text> <Text className='deduction'>{deductionBean.toFixed(2)}</Text>
</View> </View>
) : null} ) : null}
{deductionMoney ? ( {deductionMoney ? (
<View className='OrderDetail-payinfo'> <View className='OrderDetail-payinfo'>
<Text>艾米抵扣</Text> <Text>艾米抵扣</Text>
<Text>{deductionMoney.toFixed(2)}</Text> <Text className='deduction'>{deductionMoney.toFixed(2)}</Text>
</View> </View>
) : null} ) : null}
......
...@@ -30,17 +30,6 @@ type PageState = { ...@@ -30,17 +30,6 @@ type PageState = {
paymentAndActiveInfos: PaymentAndActiveInfo[]; paymentAndActiveInfos: PaymentAndActiveInfo[];
paymentConfId: number; paymentConfId: number;
}; };
deductionInfos: {
amiAccount: number;
beanAccount: number;
deductionMoney: number;
deductionType: string;
orderMoney: number;
payMoney: number;
payType: string;
remainAccount: number;
titlePerfix: string;
};
}; };
interface OrderPay { interface OrderPay {
...@@ -91,17 +80,6 @@ class OrderPay extends Component { ...@@ -91,17 +80,6 @@ class OrderPay extends Component {
paymentAndActiveInfos: [], paymentAndActiveInfos: [],
paymentConfId: 0, paymentConfId: 0,
}, },
deductionInfos: {
amiAccount: 0,
beanAccount: 0,
deductionMoney: 0,
deductionType: '',
orderMoney: 0,
payMoney: 0,
payType: '',
remainAccount: 0,
titlePerfix: '',
},
}; };
} }
...@@ -123,23 +101,6 @@ class OrderPay extends Component { ...@@ -123,23 +101,6 @@ class OrderPay extends Component {
orderInfo: orderInfo, orderInfo: orderInfo,
payInfos: payInfos, payInfos: payInfos,
}); });
fetchDeductionInfo({
orderId: orderInfo.id,
payType: '',
paymentConfId: payInfos.paymentConfId,
})
.then(res => {
this.setState({
deductionInfos: res.data,
});
})
.catch(err => {
console.log(err);
Taro.showToast({
title: '获取抵扣信息失败',
icon: 'none',
});
});
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
...@@ -152,18 +113,18 @@ class OrderPay extends Component { ...@@ -152,18 +113,18 @@ class OrderPay extends Component {
render() { render() {
const { userinfo } = this.props; const { userinfo } = this.props;
const { orderInfo, payInfos, deductionInfos } = this.state; const { orderInfo, payInfos, accounts } = this.state;
return ( return (
<View className='OrderPay topBr'> <View className='OrderPay topBr'>
<OrderTitle price={orderInfo.payableMoney} /> <OrderTitle price={orderInfo.payableMoney} />
<OrderInfo orderInfo={orderInfo} /> <OrderInfo orderInfo={orderInfo} />
<View className='OrderPay-line' /> <View className='OrderPay-line' />
<OrderPayway <OrderPayway
payDoneCallback={this.payDoneHandle} onPayDoneCallback={this.payDoneHandle}
userinfo={userinfo} userinfo={userinfo}
orderId={orderInfo.id} orderInfo={orderInfo}
accounts={accounts}
payInfos={payInfos} payInfos={payInfos}
deductionInfos={deductionInfos}
/> />
</View> </View>
); );
......
...@@ -19,6 +19,20 @@ interface OrderInfo { ...@@ -19,6 +19,20 @@ interface OrderInfo {
props: PageProps; props: PageProps;
} }
class OrderInfo extends Component { class OrderInfo extends Component {
static defaultProps = {
orderInfo: {
serviceName: '',
createAt: '',
orderNumber: '',
areaName: '',
equipmentNum: '',
equipmentPosition: '',
},
};
constructor(props) {
super(props);
}
render() { render() {
const { const {
orderInfo: { orderInfo: {
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
background-color: #ffd506; background-color: #ffd506;
} }
} }
.OrderPay-payway.disabled {
color: #666;
}
.OrderPay-payinfo { .OrderPay-payinfo {
display: flex; display: flex;
height: 60px; height: 60px;
......
...@@ -2,8 +2,12 @@ import Taro, { Component } from '@tarojs/taro'; ...@@ -2,8 +2,12 @@ import Taro, { Component } from '@tarojs/taro';
import { ComponentClass } from 'react'; import { ComponentClass } from 'react';
import { Button, View, Image, Text } from '@tarojs/components'; import { Button, View, Image, Text } from '@tarojs/components';
import { UserState } from '../../../../store/rootReducers/userinfo'; import { UserState } from '../../../../store/rootReducers/userinfo';
import { PaymentAndActiveInfo } from '../../../../api/baseClass'; import {
import { confirmPay } from '../../../../api/order'; PaymentAndActiveInfo,
CustomerBeanAccountVo,
ConsumeOrder,
} from '../../../../api/baseClass';
import { confirmPay, fetchDeductionInfo } from '../../../../api/order';
import payWayWxLogo from '../../../../images/order/pay_wechat_icon@2x.png'; import payWayWxLogo from '../../../../images/order/pay_wechat_icon@2x.png';
import payWayAimiLogo from '../../../../images/order/pay_aimi_icon@2x.png'; import payWayAimiLogo from '../../../../images/order/pay_aimi_icon@2x.png';
...@@ -18,24 +22,14 @@ import PaddingPkcs7 from 'crypto-js/pad-pkcs7'; ...@@ -18,24 +22,14 @@ import PaddingPkcs7 from 'crypto-js/pad-pkcs7';
import { getPayType } from '../../../../utils/payType'; import { getPayType } from '../../../../utils/payType';
type PageOwnProps = { type PageOwnProps = {
payDoneCallback: () => void; onPayDoneCallback: () => void;
userinfo: UserState; userinfo: UserState;
orderId: number; orderInfo: ConsumeOrder;
accounts: CustomerBeanAccountVo[];
payInfos: { payInfos: {
paymentAndActiveInfos: PaymentAndActiveInfo[]; paymentAndActiveInfos: PaymentAndActiveInfo[];
paymentConfId: number; paymentConfId: number;
}; };
deductionInfos: {
amiAccount: number;
beanAccount: number;
deductionMoney: number;
deductionType: string;
orderMoney: number;
payMoney: number;
payType: string;
remainAccount: number;
titlePerfix: string;
};
}; };
type PageState = { type PageState = {
prePay: boolean; prePay: boolean;
...@@ -48,6 +42,18 @@ type PageState = { ...@@ -48,6 +42,18 @@ type PageState = {
payType: string; payType: string;
payVersion: string; payVersion: string;
}; };
accountsInfo: null | {};
deductionInfos: null | {
amiAccount: number;
beanAccount: number;
deductionMoney: number;
deductionType: string;
orderMoney: number;
payMoney: number;
payType: string;
remainAccount: number;
titlePerfix: string;
};
}; };
interface OrderPayway { interface OrderPayway {
...@@ -55,26 +61,73 @@ interface OrderPayway { ...@@ -55,26 +61,73 @@ interface OrderPayway {
state: PageState; state: PageState;
} }
class OrderPayway extends Component { class OrderPayway extends Component {
constructor(props) { static defaultProps = {
accounts: [],
payInfos: {
paymentAndActiveInfos: [],
paymentConfId: 0,
},
orderInfo: {
payableMoney: 0,
},
};
constructor(props: PageOwnProps) {
super(props); super(props);
this.state = { this.state = {
prePay: true, prePay: true,
payWay: null, payWay: null,
accountsInfo: null,
deductionInfos: null,
};
}
componentWillReceiveProps(props) {
if (props.accounts.length !== 0 && this.props.accounts.length === 0) {
let amiAccount = props.accounts.find(item => item.serviceId === '0');
let comAccount = props.accounts.find(item => item.serviceId === '1');
let beanAccount = props.accounts.find(
item => item.serviceId !== '0' && item.serviceId !== '1',
);
let accountsInfo = {
'6': amiAccount ? amiAccount.money : 0,
'8': comAccount ? comAccount.money : 0,
'7': beanAccount ? beanAccount.money : 0,
}; };
this.setState({
accountsInfo: accountsInfo,
});
}
} }
changePayWay(payWay: PaymentAndActiveInfo) { changePayWay(payWay: PaymentAndActiveInfo, useWay?: boolean) {
if (useWay) return;
this.setState({ this.setState({
payWay: payWay, payWay: payWay,
}); });
} }
changePayState() { changePayState() {
const { orderInfo, payInfos } = this.props;
const { payWay } = this.state; const { payWay } = this.state;
if (payWay) { if (payWay) {
fetchDeductionInfo({
orderId: orderInfo.id,
payType: payWay.payType,
paymentConfId: payInfos.paymentConfId,
})
.then(res => {
this.setState({ this.setState({
deductionInfos: res.data,
prePay: false, prePay: false,
}); });
})
.catch(err => {
console.log(err);
Taro.showToast({
title: '获取抵扣信息失败',
icon: 'none',
});
});
} else { } else {
Taro.showToast({ Taro.showToast({
title: '请选择支付方式', title: '请选择支付方式',
...@@ -86,13 +139,13 @@ class OrderPayway extends Component { ...@@ -86,13 +139,13 @@ class OrderPayway extends Component {
callNativePay() { callNativePay() {
const { const {
userinfo: { customerId }, userinfo: { customerId },
orderId, orderInfo: { id },
payInfos, payInfos,
payDoneCallback, onPayDoneCallback,
} = this.props; } = this.props;
const { payWay } = this.state; const { payWay } = this.state;
confirmPay({ confirmPay({
orderId: orderId, orderId: id,
payType: payWay.payType, payType: payWay.payType,
[payWay.activeId ? 'activeId' : 'notUse']: payWay.activeId, [payWay.activeId ? 'activeId' : 'notUse']: payWay.activeId,
returnUrl: '', returnUrl: '',
...@@ -100,28 +153,26 @@ class OrderPayway extends Component { ...@@ -100,28 +153,26 @@ class OrderPayway extends Component {
paymentConfId: payInfos.paymentConfId, paymentConfId: payInfos.paymentConfId,
}) })
.then(res => { .then(res => {
console.log(res);
const { payStr } = res; const { payStr } = res;
if (payStr) { if (payStr) {
const key = customerId.toString().padEnd(16, '0'); const key = customerId.toString().padEnd(16, '0');
console.log(key);
const payData = JSON.parse( const payData = JSON.parse(
AES.decrypt(payStr, Utf8.parse(key), { AES.decrypt(payStr, Utf8.parse(key), {
mode: ECBmode, mode: ECBmode,
padding: PaddingPkcs7, padding: PaddingPkcs7,
}).toString(Utf8) }).toString(Utf8),
); );
console.log(payData); console.log(payData);
Taro.requestPayment({ Taro.requestPayment({
timeStamp: payData.msg.timestamp.toString(), timeStamp: payData.msg.timeStamp.toString(),
nonceStr: payData.msg.noncestr, nonceStr: payData.msg.nonceStr,
package: payData.msg.package, package: payData.msg.package,
signType: 'MD5', signType: payData.msg.signType,
paySign: payData.msg.sign, paySign: payData.msg.paySign,
success(res) { success(res) {
console.log(res); console.log(res);
payDoneCallback(); onPayDoneCallback();
}, },
fail(res) { fail(res) {
Taro.showToast({ Taro.showToast({
...@@ -131,7 +182,7 @@ class OrderPayway extends Component { ...@@ -131,7 +182,7 @@ class OrderPayway extends Component {
}, },
}); });
} else { } else {
payDoneCallback(); onPayDoneCallback();
} }
}) })
.catch(err => { .catch(err => {
...@@ -144,74 +195,139 @@ class OrderPayway extends Component { ...@@ -144,74 +195,139 @@ class OrderPayway extends Component {
}); });
} }
render() { render() {
const { prePay, payWay } = this.state; const { prePay, payWay, accountsInfo, deductionInfos } = this.state;
const { const {
payInfos: { paymentAndActiveInfos }, payInfos: { paymentAndActiveInfos },
deductionInfos, orderInfo,
} = this.props; } = this.props;
const payInfoList = paymentAndActiveInfos.filter( const payInfoList = paymentAndActiveInfos.filter(
item => item =>
item.payType === '2' || item.payType === '2' ||
item.payType === '6' || item.payType === '6' ||
item.payType === '7' || item.payType === '7' ||
item.payType === '8' item.payType === '8',
); );
const payInfo = prePay const payInfo = prePay
? null ? null
: payInfoList.find(item => item.payType === payWay.payType); : payInfoList.find(item => item.payType === payWay.payType);
const useAmi = accountsInfo && accountsInfo['6'] >= orderInfo.payableMoney;
const useCom = accountsInfo && accountsInfo['8'] >= orderInfo.payableMoney;
const useBean = accountsInfo && accountsInfo['7'] >= orderInfo.payableMoney;
return ( return (
<View className='OrderPayway'> <View className='OrderPayway'>
{prePay ? ( {prePay ? (
payInfoList.length ? ( payInfoList.length ? (
payInfoList.map((payway, index) => ( payInfoList.map((payway, index) =>
payway.payType === '2' ? (
<View <View
key={index} key={index}
className='OrderPay-payway' className='OrderPay-payway'
onClick={() => this.changePayWay(payway)} onClick={() => this.changePayWay(payway)}>
>
{payway.payType === '2' ? (
<Image className='OrderPay-icon' src={payWayWxLogo} /> <Image className='OrderPay-icon' src={payWayWxLogo} />
) : payway.payType === '6' ? (
<Image className='OrderPay-icon' src={payWayAimiLogo} />
) : payway.payType === '7' ? (
<Image className='OrderPay-icon' src={payWayHairLogo} />
) : payway.payType === '8' ? (
<Image className='OrderPay-icon' src={payWayComLogo} />
) : null}
{payway.payType === '2' ? (
<Text className='OrderPay-text'> <Text className='OrderPay-text'>
{getPayType(payway.payType)} {getPayType(payway.payType)}
</Text> </Text>
<View
className={`OrderPay-check ${
payWay && payWay.payType === payway.payType
? 'checked'
: ''
}`}
/>
</View>
) : payway.payType === '6' ? ( ) : payway.payType === '6' ? (
<View
key={index}
className={`OrderPay-payway ${useAmi ? '' : 'disabled'}`}
onClick={() => this.changePayWay(payway, !useAmi)}>
<Image className='OrderPay-icon' src={payWayAimiLogo} />
<Text className='OrderPay-text'> <Text className='OrderPay-text'>
{getPayType(payway.payType)}(余额: {getPayType(payway.payType)}(余额:
{deductionInfos.amiAccount.toFixed(2)}) {accountsInfo &&
accountsInfo['6'] &&
accountsInfo['6'].toFixed(2)}
)
</Text> </Text>
) : ( <View
className={`OrderPay-check ${
payWay && payWay.payType === payway.payType
? 'checked'
: ''
}`}
/>
</View>
) : payway.payType === '7' ? (
<View
key={index}
className={`OrderPay-payway ${useBean ? '' : 'disabled'}`}
onClick={() => this.changePayWay(payway, !useBean)}>
<Image className='OrderPay-icon' src={payWayHairLogo} />
<Text className='OrderPay-text'> <Text className='OrderPay-text'>
{getPayType(payway.payType)}(余额: {getPayType(payway.payType)}(余额:
{deductionInfos.beanAccount {accountsInfo && accountsInfo['7']
? deductionInfos.beanAccount.toFixed(2) ? accountsInfo['7'].toFixed(2)
: '0.00'} : '0.00'}
) )
</Text> </Text>
)}
<View <View
className={`OrderPay-check ${ className={`OrderPay-check ${
payWay && payWay.payType === payway.payType ? 'checked' : '' payWay && payWay.payType === payway.payType
? 'checked'
: ''
}`} }`}
/> />
</View> </View>
)) ) : payway.payType === '8' ? (
<View
key={index}
className={`OrderPay-payway ${useCom ? '' : 'disabled'}`}
onClick={() => this.changePayWay(payway, !useCom)}>
<Image className='OrderPay-icon' src={payWayComLogo} />
<Text className='OrderPay-text'>
{getPayType(payway.payType)}(余额:
{accountsInfo && accountsInfo['8']
? accountsInfo['8'].toFixed(2)
: '0.00'}
)
</Text>
<View
className={`OrderPay-check ${
payWay && payWay.payType === payway.payType
? 'checked'
: ''
}`}
/>
</View>
) : null,
)
) : null ) : null
) : ( ) : (
<View> <View>
{payWay && payWay.payType === '2' ? (
<View className='OrderPay-payinfo'> <View className='OrderPay-payinfo'>
<Text>订单金额</Text> <Text>订单金额</Text>
<Text>{deductionInfos.payMoney}</Text> <Text>{deductionInfos && deductionInfos.payMoney}</Text>
</View>
) : payWay && payWay.payType === '6' ? (
<View className='OrderPay-payinfo'>
<Text>艾米余额</Text>
<Text>
{deductionInfos && deductionInfos.amiAccount.toFixed(2)}
</Text>
</View>
) : payWay && (payWay.payType === '7' || payWay.payType === '8') ? (
<View className='OrderPay-payinfo'>
<Text>
{deductionInfos && deductionInfos.titlePerfix}豆余额
</Text>
<Text>
{deductionInfos && deductionInfos.beanAccount.toFixed(2)}
</Text>
</View> </View>
{deductionInfos.deductionType === '1' ? ( ) : null}
{deductionInfos && deductionInfos.deductionType === '1' ? (
<View> <View>
<View className='OrderPay-payinfo'> <View className='OrderPay-payinfo'>
<Text> <Text>
...@@ -228,7 +344,7 @@ class OrderPayway extends Component { ...@@ -228,7 +344,7 @@ class OrderPayway extends Component {
%,不满0.01元,累计算1分 %,不满0.01元,累计算1分
</View> </View>
</View> </View>
) : deductionInfos.deductionType === '2' ? ( ) : deductionInfos && deductionInfos.deductionType === '2' ? (
<View> <View>
<View className='OrderPay-payinfo'> <View className='OrderPay-payinfo'>
<Text> <Text>
...@@ -245,7 +361,7 @@ class OrderPayway extends Component { ...@@ -245,7 +361,7 @@ class OrderPayway extends Component {
%,不满0.01元,累计算1分 %,不满0.01元,累计算1分
</View> </View>
</View> </View>
) : deductionInfos.deductionType === '3' ? ( ) : deductionInfos && deductionInfos.deductionType === '3' ? (
<View className='OrderPay-payinfo'> <View className='OrderPay-payinfo'>
<Text> <Text>
艾米抵扣金额(余额:{deductionInfos.amiAccount.toFixed(2)} 艾米抵扣金额(余额:{deductionInfos.amiAccount.toFixed(2)}
...@@ -253,18 +369,52 @@ class OrderPayway extends Component { ...@@ -253,18 +369,52 @@ class OrderPayway extends Component {
<Text>{deductionInfos.deductionMoney.toFixed(2)}</Text> <Text>{deductionInfos.deductionMoney.toFixed(2)}</Text>
</View> </View>
) : null} ) : null}
{payWay && payWay.payType === '2' ? (
<View className='OrderPay-payinfo'>
<Text>订单支付</Text>
<Text>{deductionInfos && deductionInfos.payMoney}</Text>
</View>
) : payWay && payWay.payType === '6' ? (
<View>
<View className='OrderPay-payinfo'>
<Text>艾米支付余额</Text>
<Text>
-{deductionInfos && deductionInfos.payMoney.toFixed(2)}
</Text>
</View>
<View className='OrderPay-payinfo'> <View className='OrderPay-payinfo'>
<Text>{payInfo ? payInfo.payTypeName : ''}金额</Text> <Text>艾米支付结余</Text>
<Text>{deductionInfos.payMoney}</Text> <Text>
{deductionInfos && deductionInfos.remainAccount.toFixed(2)}
</Text>
</View>
</View> </View>
) : payWay && (payWay.payType === '7' || payWay.payType === '8') ? (
<View>
<View className='OrderPay-payinfo'>
<Text>
{deductionInfos && deductionInfos.titlePerfix}豆支付
</Text>
<Text>
-{deductionInfos && deductionInfos.payMoney.toFixed(2)}
</Text>
</View>
<View className='OrderPay-payinfo'>
<Text>
{deductionInfos && deductionInfos.titlePerfix}豆支付结余
</Text>
<Text>
{deductionInfos && deductionInfos.remainAccount.toFixed(2)}
</Text>
</View>
</View>
) : null}
</View> </View>
)} )}
{prePay ? ( {prePay ? (
<Button <Button
className='button OrderPay-next' className='button OrderPay-next'
onClick={this.changePayState} onClick={this.changePayState}>
>
下一步 下一步
</Button> </Button>
) : ( ) : (
......
...@@ -16,7 +16,6 @@ import agreeIcon from '../../images/login/icon_zhuce_sel@2x.png'; ...@@ -16,7 +16,6 @@ import agreeIcon from '../../images/login/icon_zhuce_sel@2x.png';
import agreeNotIcon from '../../images/login/icon_zhuce_nor@2x.png'; import agreeNotIcon from '../../images/login/icon_zhuce_nor@2x.png';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo'; import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo';
import { getVcode, fetchWxUserRegister } from '../../api/wx';
import { wxUserRegister } from '../../api/customer'; import { wxUserRegister } from '../../api/customer';
type PageStateProps = { type PageStateProps = {
......
...@@ -3,7 +3,7 @@ import Taro, { Component, Config } from '@tarojs/taro'; ...@@ -3,7 +3,7 @@ import Taro, { Component, Config } from '@tarojs/taro';
import { View } from '@tarojs/components'; import { View } from '@tarojs/components';
import './index.scss'; import './index.scss';
import { LoginReponse, login } from '../../api/wx'; import { LoginReponse } from '../../api/wx';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import { updateUserInfo, UserState } from '../../store/rootReducers/userinfo'; import { updateUserInfo, UserState } from '../../store/rootReducers/userinfo';
......
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