Commit 6f366566 by wangshuo

特训营支付流程迁移完成版初版

parent df3df07d
......@@ -14,7 +14,7 @@ import {Link} from "react-router-dom";
*/
const OrderItem = ({ info, tab, children, src,id, ...restProps }) => {
const OrderItem = ({ info, tab, children, src,id, isaist, ...restProps }) => {
return (
<div className='public-list-item'>
<div className="public-content">
......@@ -23,6 +23,11 @@ const OrderItem = ({ info, tab, children, src,id, ...restProps }) => {
<Link to={`/detail?id=${id}`}>
<img src={src} alt="" />
</Link>
{
(isaist &&
<span className='return_cash'></span>
)
}
</div>
{info}
</div>
......
......@@ -21,6 +21,15 @@
border-radius: 3px;
}
}
.return_cash {
position: absolute;
top: 0;
right: 0;
width: 31px;
height: 18px;
background: url("./image/return.icon.png") no-repeat;
background-size: 100% 100%;
}
}
......
......@@ -6,6 +6,7 @@ import { getCourses } from "@/components/detail/actions"
import { connect } from "react-redux"
import './index.scss'
import Overlay from '../overlay'
import axios from "axios";
class BtnStatus extends Component {
......@@ -19,11 +20,11 @@ class BtnStatus extends Component {
countdown: 0,
barInfo: ''
}
console.log(props);
}
componentDidMount() {
this.getBargainInfo()
// this.getBargainInfo()
}
......@@ -38,6 +39,9 @@ class BtnStatus extends Component {
// }
componentWillReceiveProps(nextProps) {
if(nextProps.data && nextProps.data.is_bargain) {
this.getBargainInfo()
}
this.setState({
...nextProps.data.course_info,
countdown: nextProps.countdown,
......@@ -75,10 +79,10 @@ class BtnStatus extends Component {
}else{
let cidArr = JSON.stringify([Number(getParam('id'))]);
console.log(cidArr);
http.get(`${api['base-api']}/m/cart/addtopreorder/${cidArr}?type=1`).then((res) => {
http.get(`${API['base-api']}/m/cart/addtopreorder/${cidArr}?type=1`).then((res) => {
console.log(res);
if (res.data.errno === 0) {
this.props.history.push({pathname: '/order?id=' + res.data.data[0], state: {type: 1}});
this.props.history.push("/order?id=" + res.data.data[0], {type: 1});
} else {
Toast.info(res.data.msg, 2);
}
......@@ -145,7 +149,7 @@ class BtnStatus extends Component {
type: 1, // 1 用户自己砍价 2 使用砍价神器 3 好友助力砍价 4 好友第二次助力
parent_uid: 0 // 被助力人id 【自己本人操作传0】
}
http.post(`${api.home}/m/bargain/toBargain`, data).then((res) => {
http.post(`${API.home}/m/bargain/toBargain`, data).then((res) => {
if (res.data.code === 200) {
// this.props.getBargainInfo()
document.location.reload()
......
......@@ -11,7 +11,7 @@ import BtnStatus from "./btnstatus"
import Carouselw from "./carousel"
import {connect} from "react-redux"
import {fetchCoursesListIfNeeded} from "./actions"
import {api, getParam, http, browser} from "@/utils"
import {getParam, http, browser} from "@/utils"
import {Toast} from 'antd-mobile'
import {compose} from "redux";
......@@ -251,14 +251,14 @@ class Detail extends Component {
{/*拼团*/}
{
(courseInfo.group_status === 3 || courseInfo.group_status === 4) &&
(!courseInfo.is_aist && (courseInfo.group_status === 3 || courseInfo.group_status === 4)) &&
<Group history={this.props.history} countdown={countdown}/>
}
{/*砍价*/}
{
this.props.courseInfo && this.props.courseInfo.is_bargain &&
(!courseInfo.is_aist) && this.props.courseInfo && this.props.courseInfo.is_bargain &&
<Bargain/>
}
......@@ -298,13 +298,9 @@ class Detail extends Component {
const mapStateToProps = (state) => {
return {
courseInfo: state.courseInfo,
<<<<<<< HEAD
user: {
...state.user
}
=======
user: state.user
>>>>>>> master
}
}
......
......@@ -17,7 +17,6 @@ function OrderList(props) {
<div>
{
listData.map((item, index) => {
console.log(item);
const { is_coupon, course_id, image_name, price1, price0, simpledescription, course_title, coupon_num, coupon_desc } = item;
const Info = (
<div className="order-info">
......@@ -25,7 +24,7 @@ function OrderList(props) {
<p className='order-content' style={{ WebkitBoxOrient: 'vertical', WebkitLineClamp: '2', wordBreak: 'break-all', overflow: 'hidden', textOverflow: 'ellipsis', display: '-webkit-box' }}>{simpledescription}</p>
<p className='order-des'>
{
props.courseId === undefined ? (<span className='order-newprice'>¥{price1}</span>) : (<span className='order-newprice'>¥{item.pdd_group_info.price}</span>)
props.courseId === undefined ? (<span className='order-newprice'>¥{price1}</span>) : (<span className='order-newprice'>¥{price0}</span>)
}
<span className='order-price'>¥{price0}</span>
</p>
......@@ -33,7 +32,7 @@ function OrderList(props) {
);
return (
<OrderItem {...item} src={image_name} id={course_id} key={index} info={Info}>
<OrderItem {...item} src={image_name} id={course_id} key={index} info={Info} isaist={props.isaist}>
{
is_coupon === 1 ? (
<div className="order-prefer">
......@@ -93,9 +92,14 @@ class Order extends Component {
if (!this.state.perfect) {
Toast.info('请完善报名信息!');
}
http.post(`${API.home}/m/order/submitOrder`, { is_deduction: this.state.useBalance }).then(res => {
if(res.data.code !== 200) {
let url = `${API['base-api']}/m/v34/cart/order?ischeck=${this.state.useBalance}`;
if(this.props.location.state.type === 1) {
url += '&type=1'
}
http.get(url).then(res => {
console.log(res);
if(res.data.errno !== 0) {
Toast.info(res.data.msg, 2);
return;
}
sessionStorage.removeItem('orderUseCacheObj');
......@@ -111,7 +115,7 @@ class Order extends Component {
if (!useBalanceFlag) {
this.cacheObj = {
...this.state
}
};
sessionStorage.setItem('orderUseCacheObj', JSON.stringify(this.state));
}else{
sessionStorage.removeItem('orderUseCacheObj');
......@@ -174,7 +178,7 @@ class Order extends Component {
let _this = this;
console.log(this.props.location.state);
if(this.props.location.state && this.props.location.state.type === 1) {
http.get(`${api['home']}/m/order/preorder/`).then((res) => {
http.get(`${API['base-api']}/m/order/preorder?type=1`).then((res) => {
if(res.data.errno === 200) {
const { course, total, user_account, user_info, discount } = res.data.data;
this.cacheObj = {
......@@ -191,14 +195,24 @@ class Order extends Component {
total,
discount,
});
if(this.props.history.action === 'PUSH') {
sessionStorage.removeItem('orderUseCacheObj');
} else{
const cacheObj = sessionStorage.getItem('orderUseCacheObj');
if(cacheObj !== null) {
this.setState({
useBalance: true
});
this.computedMoneyByCache();
}
}
}else{
Toast.info(res.data.msg, 2);
return;
}
})
}else {
if(getParam('id')) {
Promise.all([http.get(`${api.home}/m/del_cart_order/${getParam('id')}`), http.get(`${api.home}/m/order/preorder`), http.get(`${api.home}/m/course/detail/${getParam('id')}`)]).then(res => {
Promise.all([http.get(`${API.home}/m/del_cart_order/${getParam('id')}`), http.get(`${API.home}/m/order/preorder`), http.get(`${API.home}/m/course/detail/${getParam('id')}`)]).then(res => {
console.log(res);
let preorder = res[1],
detail = res[2],
......@@ -231,7 +245,7 @@ class Order extends Component {
});
})
}else{
http.get(`${api['base-api']}/m/order/preorder`).then((res) => {
http.get(`${API['base-api']}/m/order/preorder`).then((res) => {
console.log(res.data);
if (res.data.errno !== 200) {
return;
......@@ -282,10 +296,14 @@ class Order extends Component {
<div className="order-wrapper">
<Flex>
<Flex.Item>
<HeaderBar title='课程报名' arrow={true}></HeaderBar>
<HeaderBar title='课程报名' arrow={true} />
{
!this.state.perfect &&
<Link to='/orderinfo' className="order-information">
<Link to={{
pathname: '/orderinfo',
state: {type: this.props.location.state.type, id: getParam('id')}
}}
className="order-information">
<i className="iconfont iconiconfront-6 order-addsize"></i>
<div className="order-infotext">完善报名信息</div>
<i className="iconfont iconiconfront-70 order-next"></i>
......@@ -297,7 +315,11 @@ class Order extends Component {
<WingBlank>
<Link to={{
pathname: '/orderinfo',
state: this.state.perfect
state: {
...this.state.perfect,
type: this.props.location.state.type,
id: getParam('id')
}
}
} >
<Flex align='center' justify='between' style={{ height: '80px' }}>
......@@ -318,7 +340,7 @@ class Order extends Component {
</div>
}
<div className="order-list">
<OrderList list={orderList} compute={this.computedMoney} courseId={getParam('id')} />
<OrderList list={orderList} compute={this.computedMoney} courseId={getParam('id')} isaist={this.props.location.state.type}/>
</div>
<div className="order-balance">
<List>
......
......@@ -78,36 +78,43 @@ const MyForm = withFormik({
Toast.info('请输入正确QQ号!', undefined, undefined, false);
return;
}
let same = false;
let same = 0;
if(FormBag.props.userInfo) {
const userInfo = FormBag.props.userInfo;
if(userInfo.real_name === real_name) {
same = true;
same += 1;
}
if(userInfo.cellphone === cellphone) {
same = true;
same += 1;
}
if(userInfo.qq === qq) {
same = true;
same += 1;
}
}
if(same) {
FormBag.props.history.replace({
pathname: '/order',
state: values
});
let pathName = '/order';
if(FormBag.props.userInfo.id) {
pathName = pathName + '?id=' + FormBag.props.userInfo.id;
}
if(same === 3) {
FormBag.props.history.replace(
pathName,
{
...values,
}
);
return;
}
http.post(`${API.home}/m/order/saveUserInfo`, {real_name: values.real_name, cellphone: (`${values.cellphone}`).replace(/\s+/g, ''), qq: values.qq}).then(res=>{
if(res.data.code !== 200) {
http.post(`${API['base-api']}/m/order/saveUserInfo`, {real_name: values.real_name, cellphone: (`${values.cellphone}`).replace(/\s+/g, ''), qq: values.qq}).then(res=>{
console.log(res);
if(res.data.errno !== 200) {
Toast.info(res.data.msg, undefined, undefined, false);
return;
}
Toast.info('保存成功!', undefined, undefined, false);
FormBag.props.history.replace({
pathname: '/order',
state: values
});
FormBag.props.history.replace(
pathName,
values
);
});
},
})(InnerForm);
......
import React, { Component } from 'react';
import { Flex, WingBlank, WhiteSpace, List, Radio } from 'antd-mobile';
import { api, http, getParam, is_weixin } from '@/utils';
import {Flex, WingBlank, WhiteSpace, List, Radio, Toast} from 'antd-mobile';
import {http, getParam, is_weixin } from '@/utils';
import { OrderItem, HeaderBar } from '@/common/index';
import { Link } from 'react-router-dom';
import './PayOrder.scss';
......@@ -51,7 +51,6 @@ export default class PayOrder extends Component {
console.log(item);
this.setState({
huabei: false,
checkPeriod: true,
stageNumber: item.value,
singleMoney: item.everyTotal,
periodNumber: item.stage,
......@@ -168,9 +167,10 @@ export default class PayOrder extends Component {
}
componentDidMount() {
http.post(`${API.home}/m/order/detail`, { order_id: this.state.orderId }).then((res) => {
http.post(`${API['base-api']}/m/order/detail`, { order_id: this.state.orderId }).then((res) => {
console.log(res);
if (res.data.code !== 200) {
if (res.data.errno !== 200) {
Toast.info(res.data.msg, 2);
return;
}
const { course, pay_amount } = res.data.data;
......
import React, {Component} from 'react';
import {api, getParam, http, browser} from "@/utils";
import {getParam, http, browser} from "@/utils";
import './camp.scss';
import {CampTitle, Header, TestItem, ChangeQuestion, Resolve} from './common/common';
import {Toast} from "antd-mobile";
......@@ -43,7 +43,7 @@ class CampResolve extends Component {
this.qidP = getParam('qid');
let _this = this;
// 获取问题列表
http.get(`${api.home}/m/aist/analysis/${this.keshi_id}/${this.qidP}`).then(res => {
http.get(`${API.home}/m/aist/analysis/${this.keshi_id}/${this.qidP}`).then(res => {
console.log(res);
if(res.data.code === 4040) {
Toast.info(res.data.msg, 2, () => {
......
import React, {Component} from 'react';
import {api, getParam, http, browser} from "@/utils";
import {getParam, http, browser} from "@/utils";
import './camp.scss';
import {connect} from "react-redux";
import {Header, CampTitle, TestItem, ChangeQuestion} from './common/common';
......@@ -24,7 +24,7 @@ class CampTest extends Component {
this.qidP = getParam('qid');
let _this = this;
// 获取问题列表
http.get(`${api.home}/m/aist/get_questions/${this.keshi_id}/${this.qidP}`).then(res => {
http.get(`${API.home}/m/aist/get_questions/${this.keshi_id}/${this.qidP}`).then(res => {
if(res.data.code === 4040) {
Toast.info(res.data.msg, 2, () => {
this.props.history.push('/passport');
......@@ -133,7 +133,7 @@ class CampTest extends Component {
data.cost_time = this.time;
data.uid = this.props.user.data.uid;
data.answer_record = this.answerList;
http.post(`${api.home}/m/aist/submit`, data).then((res) => {
http.post(`${API.home}/m/aist/submit`, data).then((res) => {
if(res.data.code === 200) {
this.props.history.push(`/campResolve?keshi_id=${this.keshi_id}&qid=${this.qid}`)
}else{
......
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