Commit 95e7986c by xuzhenghua

test

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