Commit 95e7986c by xuzhenghua

test

parent 5a9609a8
......@@ -10,9 +10,10 @@ class HeaderBar extends Component {
window.history.go(-1);
}
toHref = () => {
const { href } = this.props;
location.replace(href)
toLink = () => {
const { toHref } = this.props;
console.log(toHref);
location.replace(toHref)
}
goShop = () => {
......@@ -20,15 +21,20 @@ class HeaderBar extends Component {
}
render() {
const { toHref } = this.props
return (
<div className="detail-header" style={{...this.props.style}}>
{
!this.props.href && this.props.arrow &&
!toHref && this.props.arrow &&
<i className='iconfont iconiconfront-68' onClick={this.goBack}></i>
}
{
this.props.href &&
<i className='iconfont iconiconfront-68' onClick={this.toHref}></i>
toHref && typeof toHref === 'function' &&
<i className='iconfont iconiconfront-68' onClick={toHref}>1</i>
}
{
toHref && typeof toHref === 'string' &&
<i className='iconfont iconiconfront-68' onClick={this.toLink}></i>
}
<span className='herder'>{this.props.title}</span>
{
......
import React, {Component} from 'react'
import {Course, CallApp} from '../../common'
import React, { Component } from 'react'
import { Course, CallApp } from '../../common'
import './index.scss'
import {WithTab} from '@/HOCs'
import { WithTab } from '@/HOCs'
import Swiper from 'react-mobile-swiper'
import createStyle from './createStyle'
import LazyLoad from 'react-lazy-load'
import {http} from '@/utils'
import { http } from '@/utils'
import LiveRoom from './liveRoom'
import {Link} from "react-router-dom"
import {Toast} from 'antd-mobile'
import {connect} from "react-redux";
import {getCourses} from './../detail/actions';
import { Link } from "react-router-dom"
import { Toast } from 'antd-mobile'
import { connect } from "react-redux";
import { getCourses } from './../detail/actions';
const animateTypes = Swiper.animateTypes
......@@ -66,11 +66,11 @@ class Index extends Component {
getIndexData = () => {
http.get(`${API.home}/m/home`).then((res) => {
if (res.data.code === 200) {
const { data } = res.data || {}
const {data} = res.data || {}
this.setState({
banner: data.banner,
lives: data.lives,
modules: typeof data.modules === 'object' && data.modules.length > 0? data.modules : []
modules: typeof data.modules === 'object' && data.modules.length > 0 ? data.modules : []
})
} else {
Toast.info(res.data.msg, 2)
......@@ -109,7 +109,7 @@ class Index extends Component {
}
toCourseDetail = (id) => {
const { dispatch, history } = this.props;
const {dispatch, history} = this.props;
dispatch(getCourses(id, () => {
history.push(`/detail?id=${id}`);
return false;
......@@ -156,10 +156,10 @@ class Index extends Component {
{
(this.state.lives && this.state.lives.length > 0) ?
<div className='lives'>
<h2 className="title">近期直播</h2>
<ScrollBox livesList={this.state.lives} liveCourse={this.liveCourse}/>
</div> : null
<div className='lives'>
<h2 className="title">近期直播</h2>
<ScrollBox livesList={this.state.lives} liveCourse={this.liveCourse}/>
</div> : null
}
{
......@@ -200,11 +200,15 @@ function TopSwiper({bannerList}) {
<Swiper type={animateTypes.CARD} loop={true} height={168} autoPlay={true} typePro createStyle={createStyle}>
{bannerList && bannerList.length > 0 && bannerList.map((item, index) => {
return (
<a href={item.jump_url} key={index}>
{/* <Link to={item.jump_url} key={index}> */}
<img className="item" src={item.name} alt=""/>
{/* </Link> */}
</a>
Number.isNaN(parseInt(item.jump_url)) ?
<a href={item.jump_url} key={index}>
{/* <Link to={item.jump_url} key={index}> */}
<img className="item" src={item.name} alt=""/>
{/* </Link> */}
</a> :
<Link to={{pathname: '/detail', search: `?id=${item.jump_url}`}}>
<img className="item" src={item.name} alt=""/>
</Link>
)
})
}
......@@ -219,7 +223,7 @@ function CourseList({modules, toDetail}) {
// 数量为奇数时,第一个课程显示大图(如后台未上传,前台显示小图),课程数量为偶数时,均显示小图
let filterList = ''
if(isOdd){
if (isOdd) {
filterList = modules.list
} else {
filterList = modules.list[0].course_img === modules.list[0].course_img_small ? modules.list : modules.list.slice(1)
......@@ -238,10 +242,10 @@ function CourseList({modules, toDetail}) {
<LazyLoad offset={50}>
<ul className='index-course-detail'>
{
!isOdd && modules.list[0].course_img!== modules.list[0].course_img_small &&
!isOdd && modules.list[0].course_img !== modules.list[0].course_img_small &&
<div className="category-vip" onClick={() => toDetail(modules.list[0].course_id)}>
{/* <Link to={`/detail?id=${modules.list[0].course_id}`}> */}
<img src={modules.list[0].course_img} alt=""/>
<img src={modules.list[0].course_img} alt=""/>
{/* </Link> */}
</div>
}
......
......@@ -125,7 +125,7 @@ class ToGroup extends Component {
toCourseDetail = (id) => {
const { dispatch, history } = this.props;
dispatch(getCourses(id, () => {
history.push(`/detail?id=${id}`);
history.push(`/detail?id=${id}`, {href: '/classify'});
return false;
}));
}
......@@ -150,7 +150,7 @@ class ToGroup extends Component {
)
return (
<div className='to-group-box'>
<HeaderBar title='拼团' arrow={true} cart={false}></HeaderBar>
<HeaderBar title='拼团' cart={false} toHref={() => this.toCourseDetail(course_id)}></HeaderBar>
{
!is_success &&
<VList
......
......@@ -184,7 +184,7 @@ class Detail extends Component {
const href = this.props.location && this.props.location.state? this.props.location.state.href : undefined;
return (
<div className='detail-box'>
<HeaderBar title='课程详情' arrow={true} cart={true} href={href}></HeaderBar>
<HeaderBar title='课程详情' arrow={true} cart={true} toHref={href}></HeaderBar>
<CallApp className='toapp'></CallApp>
{/*弹幕*/}
<Carouselw></Carouselw>
......
......@@ -97,7 +97,7 @@ export default class PayOrder extends Component {
pay = () => {
const {payType, orderId} = this.state;
if(payType === 0) {
this.alipayPay(orderId)
this.alipayPay(orderId);
} else if (payType === 1) {
this.weixinPay(orderId)
}
......@@ -109,42 +109,79 @@ export default class PayOrder extends Component {
weixinPay = (orderId) => {
// 微信内部-支付
if (is_weixin()) {
window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=" + encodeURIComponent(window.location.href + "&aa=bb&oid=" + orderId).toLowerCase() + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=" + encodeURIComponent(window.location.href + "&aa=bb").toLowerCase() + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
} else {
// 微信外部-支付
http.get(`${API['base-api']}/pay/wxpay/wap_charge/oid/${orderId}`).then((res) => {
console.log(res);
if (res.data.errno === 0) {
window.location.href = res.data.data.url + "&redirect_url=" + encodeURIComponent(window.location.href + "&weixinpay=1&oid=" + orderId).toLowerCase();
window.location.href = res.data.data.url + "&redirect_url=" + encodeURIComponent(window.location.href + "&weixinpay=1").toLowerCase();
} else {
Toast.info(res.data.msg + 'weixinPay', 2)
Toast.info(res.data.msg, 2)
}
})
}
}
// 微信内部支付
isweixinPay = () => {
let weixin_code = getParam('code')
let _this = this;
let weixin_code = getParam('code');
if (weixin_code) {
if (getParam('oid') === undefined) {
return
} else {
http.get(`${API['base-api']}/pay/wxpay/pub_charge/oid/${getParam('oid')}/code/${weixin_code}`).then((res) => {
if (res.data.errno === 0) {
this.bridgeData = res.data.data;
this.onBridgeReady();
let data = res.data.data;
function onBridgeReady() {
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
appId:data.appId, //公众号名称,由商户传入
timeStamp:data.timeStamp, //时间戳,自1970年以来的秒数
nonceStr:data.nonceStr, //随机串
package:data.package,
signType:data.signType, //微信签名方式:
paySign:data.paySign //微信签名
},
function (res) {
if (res.err_msg == "get_brand_wcpay_request:ok") {
Toast.info('支付成功', 2);
_this.intervalPayStatus = setInterval(function(){
http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
if (res.data.errno === 401) {
clearInterval(_this.intervalPayStatus);
_this.intervalPayStatus = null;
// 获取课程类型
http.get(`${API['base-api']}/m/app_order/detail/${getParam('oid')}`).then(res => {
if(Number(res.data.data.course_type) === 2) {
_this.props.history.replace(`/togroup?id=${getParam('oid')}`);
}else{
// 跳转到已购课程 /purchased 不需要传递任何参数
_this.props.history.replace(`/purchased`);
}
});
}
})
}, 1000)
} else {
alert('支付失败')
}
}
)
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady, false)
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady)
document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady)
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
}
} else {
this.onBridgeReady()
onBridgeReady();
}
} else {
Toast.info(res.data.msg + 'isweixinPay', 2)
Toast.info(res.data.msg, 2)
}
})
}
......@@ -156,17 +193,17 @@ export default class PayOrder extends Component {
// 支付回调
// 定时器轮训获取订单状态
_this.intervalPayStatus = setInterval(function(){
http.get(`${API.home}/m/orderState/oid/${getParam('oid')}`).then(res => {
http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
if (res.data.errno === 401) {
clearInterval(_this.intervalPayStatus);
_this.intervalPayStatus = null;
// 获取课程类型
http.get(`${API.home}/m/app_order/detail/${getParam('oid')}`).then(res => {
if(res.data.data.course_type === '2') {
this.props.history.replace(`/togroup?id=${getParam('oid')}`);
http.get(`${API['base-api']}/m/app_order/detail/${getParam('oid')}`).then(res => {
if(Number(res.data.data.course_type) === 2) {
_this.props.history.replace(`/togroup?id=${getParam('oid')}`);
}else{
// 跳转到已购课程 /purchased 不需要传递任何参数
this.props.history.replace(`/purchased`);
_this.props.history.replace(`/purchased`);
}
});
......@@ -175,12 +212,13 @@ export default class PayOrder extends Component {
}, 1000)
}
onBridgeReady = () => {
const data = this.bridgeData;
console.log(this.bridgeData);
onBridgeReady1 = (data) => {
let _this = this;
data = data || _this.BridgeData;
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": data.appId, //公众号名称,由商户传入
"appId": "wx23dac6775ac82877", //公众号名称,由商户传入
"timeStamp": data.timeStamp, //时间戳,自1970年以来的秒数
"nonceStr": data.nonceStr, //随机串
"package": data.package,
......@@ -189,7 +227,8 @@ export default class PayOrder extends Component {
},
function (res) {
if (res.err_msg == "get_brand_wcpay_request:ok") {
this.payCallback()
Toast.info('支付成功', 2);
_this.payCallback();
} else {
alert('支付失败')
}
......@@ -203,7 +242,7 @@ export default class PayOrder extends Component {
this.payCallback();
window.location = res.data.data.url;
} else {
Toast.info(res.data.msg + 'alipayPay', 2)
Toast.info(res.data.msg, 2)
}
})
}
......@@ -217,7 +256,7 @@ export default class PayOrder extends Component {
if (res.data.errno === 0) {
window.location = res.data.data.url;
} else {
Toast.info(res.data.msg + "huabeiPay", 2)
Toast.info(res.data.msg, 2)
}
});
}
......@@ -227,7 +266,7 @@ export default class PayOrder extends Component {
http.post(`${API['base-api']}/m/order/detail`, { order_id: this.state.orderId }).then((res) => {
console.log(res);
if (res.data.errno !== 200) {
Toast.info(res.data.msg + 'componentDidMount', 2);
Toast.info(res.data.msg, 2);
return;
}
const { course, pay_amount } = res.data.data;
......
......@@ -37,7 +37,7 @@ class Passport extends Component {
{
logo: qq,
text: 'QQ',
url: `${API["passport-api"]}/mob/qqlogin?redirect_url=${location.href}`
url: `${API["passport-api"]}/mob/qqlogin?redirect_url=https://m.julyedu.com`
},
{
logo: sina,
......
......@@ -37,7 +37,7 @@ class VideoCatalog extends Component {
}}>
<div className="exercise">
课后练习:{item.practice.title}
<i className={classnames('iconfont', item.practice.is_tested ? 'iconiconfront-3' : 'iconiconfront-74')}/>
<i className={classnames('iconfont',!item.video_auth ? 'iconiconfront-74' : item.practice.is_tested ? 'iconiconfront-3' : '')}/>
</div>
</Link>
: null
......
......@@ -18,6 +18,11 @@
}
.exercise{
border-top: 1px solid #E7EAF1;
font-size: $font_12;
.iconiconfront-3{
font-weight: bold;
color: $active;
}
}
}
......
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