Commit bd87e46b by wangshuo

单集购买微信支付

parent 408c6f1a
...@@ -15,9 +15,17 @@ class OutLine extends Component { ...@@ -15,9 +15,17 @@ class OutLine extends Component {
} }
htmlDecode = (content) => { htmlDecode = (content) => {
let e = document.createElement('div'); // let e = document.createElement('div');
e.innerHTML = content; // e.innerHTML = content;
return e.childNodes.length === 0 ? "" : e.innerHTML; // return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
if(content) {
content = content.replace(/&lt;/g , '<');
content = content.replace(/&gt;/g , '>');
content = content.replace(/&amp;gt;/g , '');
content = content.replace(/&quot;/g , '"');
content = content.replace(/&amp;nbsp;/g , '');
}
return content;
} }
tabchange = (tab, index) => { tabchange = (tab, index) => {
......
...@@ -101,6 +101,7 @@ class Single extends Component { ...@@ -101,6 +101,7 @@ class Single extends Component {
} }
// 微信内部支付 // 微信内部支付
isweixinPay = () => { isweixinPay = () => {
let _this = this;
let weixin_code = getParam('code') let weixin_code = getParam('code')
if (weixin_code) { if (weixin_code) {
if (getParam('oid') === undefined) { if (getParam('oid') === undefined) {
...@@ -108,17 +109,71 @@ class Single extends Component { ...@@ -108,17 +109,71 @@ class Single extends Component {
} 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) {
const data = res.data.data const data = res.data.data;
this.onBridgeReady(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.home}/sys/orderStatus/${getParam('oid')}`).then((res) => {
if (res.data.data.errno == '200') {
// 正常购买单集成功
this.setState({
status: 6
})
} else if (res.data.data.errno == '201') {
// 0元参团
this.setState({
status: 4
})
} else if (res.data.data.errno == '202') {
// 0元购
this.setState({
status: 3
})
} else if (res.data.data.errno == '203') {
// 三天内特价
this.setState({
nowPrice: res.data.data.data.now_price,
laterPrice: res.data.data.data.three_day_later_price,
status: 2
})
} else {
Toast.info(res.data.data.msg, 2)
}
})
}
})
}, 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, 2) Toast.info(res.data.msg, 2)
...@@ -130,6 +185,13 @@ class Single extends Component { ...@@ -130,6 +185,13 @@ class Single extends Component {
// 支付完成之后获取状态 // 支付完成之后获取状态
payCallback = () => { 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;
// 获取课程类型
http.get(`${API.home}/sys/orderStatus/${getParam('oid')}`).then((res) => { http.get(`${API.home}/sys/orderStatus/${getParam('oid')}`).then((res) => {
if (res.data.data.errno == '200') { if (res.data.data.errno == '200') {
// 正常购买单集成功 // 正常购买单集成功
...@@ -158,6 +220,9 @@ class Single extends Component { ...@@ -158,6 +220,9 @@ class Single extends Component {
} }
}) })
} }
})
}, 1000)
}
// 特价购买全集 // 特价购买全集
......
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