Commit 306c895f by xuzhenghua

登录

parents eed5843c acf4003d
......@@ -103,8 +103,8 @@
"python-class.css": "/mrstatic/css/python-class.1fe9d108.chunk.css",
"python-class.js": "/mrstatic/js/python-class.24cd3eb9.chunk.js",
"python-class.js.map": "/mrstatic/js/python-class.24cd3eb9.chunk.js.map",
"runtime~main.js": "/mrstatic/js/runtime~main.5700ac54.js",
"runtime~main.js.map": "/mrstatic/js/runtime~main.5700ac54.js.map",
"runtime~main.js": "/mrstatic/js/runtime~main.50eebd91.js",
"runtime~main.js.map": "/mrstatic/js/runtime~main.50eebd91.js.map",
"search.css": "/mrstatic/css/search.5716d9b3.chunk.css",
"search.js": "/mrstatic/js/search.20bbab86.chunk.js",
"search.js.map": "/mrstatic/js/search.20bbab86.chunk.js.map",
......@@ -138,8 +138,8 @@
"mrstatic/js/47.4ef49615.chunk.js": "/mrstatic/js/47.4ef49615.chunk.js",
"mrstatic/js/47.4ef49615.chunk.js.map": "/mrstatic/js/47.4ef49615.chunk.js.map",
"mrstatic/css/48.47bdf249.chunk.css": "/mrstatic/css/48.47bdf249.chunk.css",
"mrstatic/js/48.39932ed3.chunk.js": "/mrstatic/js/48.39932ed3.chunk.js",
"mrstatic/js/48.39932ed3.chunk.js.map": "/mrstatic/js/48.39932ed3.chunk.js.map",
"mrstatic/js/48.57fca03b.chunk.js": "/mrstatic/js/48.57fca03b.chunk.js",
"mrstatic/js/48.57fca03b.chunk.js.map": "/mrstatic/js/48.57fca03b.chunk.js.map",
"mrstatic/css/49.bff100af.chunk.css": "/mrstatic/css/49.bff100af.chunk.css",
"mrstatic/js/49.0dfc3020.chunk.js": "/mrstatic/js/49.0dfc3020.chunk.js",
"mrstatic/js/49.0dfc3020.chunk.js.map": "/mrstatic/js/49.0dfc3020.chunk.js.map",
......@@ -244,6 +244,6 @@
"mrstatic/media/iconfont.css": "/mrstatic/media/iconfont.f2f4294d.woff",
"mrstatic/media/kanjia_cg_icon.png": "/mrstatic/media/kanjia_cg_icon.81a489ac.png",
"mrstatic/media/video.scss": "/mrstatic/media/progress-share-bg.80011994.png",
"precache-manifest.d4afddf4d603abfc82fd7611779c5757.js": "/precache-manifest.d4afddf4d603abfc82fd7611779c5757.js",
"precache-manifest.02fff305b875b68509f2f33b95c45a3c.js": "/precache-manifest.02fff305b875b68509f2f33b95c45a3c.js",
"service-worker.js": "/service-worker.js"
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -232,8 +232,8 @@ self.__precacheManifest = [
"url": "/mrstatic/js/myorders.3d2381f9.chunk.js"
},
{
"revision": "638aaa2ceca474edbcc7",
"url": "/mrstatic/js/48.39932ed3.chunk.js"
"revision": "d59875493242f4210f9b",
"url": "/mrstatic/js/48.57fca03b.chunk.js"
},
{
"revision": "952434d03d9bbafc37dd",
......@@ -272,8 +272,8 @@ self.__precacheManifest = [
"url": "/mrstatic/js/python-class.24cd3eb9.chunk.js"
},
{
"revision": "a7e4591ac426f67af7ad",
"url": "/mrstatic/js/runtime~main.5700ac54.js"
"revision": "c3d6102fef69c28f26ec",
"url": "/mrstatic/js/runtime~main.50eebd91.js"
},
{
"revision": "602e7c833e2ac47b90f8",
......@@ -360,7 +360,7 @@ self.__precacheManifest = [
"url": "/mrstatic/css/47.2fd45d08.chunk.css"
},
{
"revision": "638aaa2ceca474edbcc7",
"revision": "d59875493242f4210f9b",
"url": "/mrstatic/css/48.47bdf249.chunk.css"
},
{
......@@ -528,7 +528,7 @@ self.__precacheManifest = [
"url": "/mrstatic/css/1.037b510f.chunk.css"
},
{
"revision": "290d8d67792624054bd6c0ccd7919b49",
"revision": "79754170d352dc0fb3679eeaec8725e9",
"url": "/index.html"
}
];
\ No newline at end of file
......@@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js");
importScripts(
"/precache-manifest.d4afddf4d603abfc82fd7611779c5757.js"
"/precache-manifest.02fff305b875b68509f2f33b95c45a3c.js"
);
workbox.clientsClaim();
......
......@@ -6,6 +6,7 @@ import {connect} from "react-redux"
import {addDays} from "date-fns"
import cookie from "js-cookie"
import {setCurrentUser, startFetchUser} from "@/store/userAction"
import {Toast} from "antd-mobile"
@connect(state => ({
......@@ -32,6 +33,88 @@ class ML extends Component {
window['loginInfo'] = result => {
_this.loginInfo(result)
}
if (browser.isWeixin) {
this.isweixinPay()
}
if (getParam('weixinpay')) {
this.payCallback()
}
}
// 微信内部支付回调
isweixinPay = () => {
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) {
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_wcpsys/order_status/ay_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;
location.reload()
}
})
}, 1000)
} else {
Toast.info('支付失败', 2);
}
}
)
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
}
} else {
onBridgeReady();
}
} else {
Toast.info(res.data.msg, 2)
}
})
}
}
}
// 支付完成之后获取状态
payCallback = () => {
const _this = this;
// 支付回调
// 定时器轮训获取订单状态
_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;
location.reload()
}
})
}, 1000)
}
// 获取app登录数据
......
import React, { Component } from 'react'
import React, {Component} from 'react'
import './index.scss'
import Description from './Description/index.js'
import Study from './Study/index.js'
......@@ -9,10 +9,10 @@ import Selection from './Selection'
import Mask from './../poup/index.js'
import InAction from "./InAction"
import ShareRank from "@components/detail/shareRank"
import { http, getParam, SendMessageToApp, browser} from '@/utils'
import { connect } from 'react-redux'
import { Toast } from "antd-mobile"
import { CallApp } from "@common/index"
import {http, getParam, SendMessageToApp, browser} from '@/utils'
import {connect} from 'react-redux'
import {Toast} from "antd-mobile"
import {CallApp} from "@common/index"
@connect(state => ({
user: state.user
......@@ -30,7 +30,7 @@ class PythonDes extends Component {
isOnline: true, //课程是否上架
courseInfo: {},
isShowChannel: window.sessionStorage.getItem('isShowSiteWindowByChannel'),
orderId:''
orderId: ''
}
}
......@@ -55,7 +55,7 @@ class PythonDes extends Component {
this.toLogin()
}
}
creatOid=()=>{
creatOid = () => {
http.post(`${API['base-api']}/sys/trial_create`, {course_id: getParam('id')}).then(res => {
const {errno, data, msg} = res.data
if (errno === 200) {
......@@ -72,94 +72,21 @@ class PythonDes extends Component {
weixinPay = (orderId) => {
// 微信内部-支付
if (browser.isWeixin) {
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&oid=" + orderId).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) => {
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&oid=" + orderId).toLowerCase()
} else {
Toast.info(res.data.msg, 2)
}
})
}
}
// 微信支付
isweixinPay = () => {
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) {
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_wcpsys/order_status/ay_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;
location.reload()
}
})
}, 1000)
} else {
Toast.info('支付失败', 2);
}
}
)
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
}
} else {
onBridgeReady();
}
} else {
Toast.info(res.data.msg, 2)
}
})
}
}
}
// 支付完成之后获取状态
payCallback = () => {
const _this = this;
// 支付回调
// 定时器轮训获取订单状态
_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;
location.reload()
}
})
}, 1000)
}
toLearn = () => {
const {backwardVersion} = this.props;
const {backwardVersion} = this.props
http.post(`${API['home']}/m/it/user/trialCourse`, {course_id: getParam('id')}).then((res) => {
const {code, msg} = res.data
if (code == 200) {
......@@ -187,7 +114,7 @@ class PythonDes extends Component {
}
toDetail = () => {
const {backwardVersion} = this.props;
const {backwardVersion} = this.props
const id = getParam('id')
if (!getParam('version')) { // H5
http.get(`${API['base-api']}/m/cart/addtopreorder/[${id}]`).then((res) => {
......@@ -199,12 +126,12 @@ class PythonDes extends Component {
})
} else { // APP
if (backwardVersion) {
Toast.info('当前版本不支持该课程模式,请升级到最新版本或前往PC端购买', 2);
Toast.info('当前版本不支持该课程模式,请升级到最新版本或前往PC端购买', 2)
let onlyoneUse = setTimeout(() => {
clearTimeout(onlyoneUse);
onlyoneUse = null;
clearTimeout(onlyoneUse)
onlyoneUse = null
SendMessageToApp('toPay', id)
}, 2000);
}, 2000)
} else {
SendMessageToApp('toPay', id)
}
......@@ -213,11 +140,27 @@ class PythonDes extends Component {
toLogin = () => {
if (!getParam('version')) { // H5
this.props.history.push('/passport')
this.changeLoginType()
} else { // APP
SendMessageToApp("toLogin")
}
}
// 点击登录 提示微信登录还是账号登录,微信授权登录不需要绑定手机号
changeLoginType = () => {
// 微信登录
if (browser.isWeixin) {
// tool.setCookie('redirect_url', window.location.href);
let url = window.location.href
if (url.includes('code=') && url.includes('state=STATE')) {
let index = url.lastIndexOf('code=')
url = url.substr(0, index - 1)
}
window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=" + encodeURIComponent(url).toLowerCase() + "&aa=bb&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
} else {
// 账号登录
this.props.history.push('/passport')
}
}
showAll = (key) => {
if (key === 1) {
......@@ -268,16 +211,9 @@ class PythonDes extends Component {
componentDidMount() {
this.getStatus()
const {backwardVersion, isPay} = this.props;
const {backwardVersion, isPay} = this.props
if (backwardVersion && isPay === 1) {
Toast.info('当前版本不支持该课程模式,请升级到最新版本或前往PC端学习', 2);
}
if (browser.isWeixin) {
this.isweixinPay()
}
if (getParam('weixinpay')) {
this.payCallback()
Toast.info('当前版本不支持该课程模式,请升级到最新版本或前往PC端学习', 2)
}
}
......@@ -326,7 +262,8 @@ class PythonDes extends Component {
<div className={'btn__group'}>
<div className={'try__study'} onClick={() => {
this.tryLearn(3)
}}>立即报名</div>
}}>立即报名
</div>
<div className={'sign__now'} onClick={() => {
this.tryLearn(2)
}}>9.9特价试学
......
......@@ -23,13 +23,6 @@ class PythonStudy extends Component {
componentDidMount() {
this.fetchCourseDetail()
if (browser.isWeixin) {
this.isweixinPay()
}
if (getParam('weixinpay')) {
this.payCallback()
}
}
fetchCourseDetail = () => {
......@@ -119,79 +112,7 @@ class PythonStudy extends Component {
})
}
}
// 微信支付
isweixinPay = () => {
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) {
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_wcpsys/order_status/ay_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;
location.reload()
}
})
}, 1000)
} else {
Toast.info('支付失败', 2);
}
}
)
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
}
} else {
onBridgeReady();
}
} else {
Toast.info(res.data.msg, 2)
}
})
}
}
}
// 支付完成之后获取状态
payCallback = () => {
const _this = this;
// 支付回调
// 定时器轮训获取订单状态
_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;
location.reload()
}
})
}, 1000)
}
render() {
const {user} = this.props
......
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