|
@@ -3,6 +3,7 @@ import React, { useEffect, useRef, useState } from "react";
|
|
|
import api from '~/api'
|
|
|
import vip_angle from "./../../../../assets/images/vip_angle.png";
|
|
|
import try_angle from "./../../../../assets/images/try_angle.png";
|
|
|
+import { Toast } from 'react-vant';
|
|
|
export const CourseCatalog: React.FC = (props: any) => {
|
|
|
const wxPay = () => {
|
|
|
// WX.config()
|
|
@@ -14,7 +15,7 @@ export const CourseCatalog: React.FC = (props: any) => {
|
|
|
"foreType": 2,
|
|
|
"goodsId": query.get('id') || "",
|
|
|
"goodsType": 1,
|
|
|
- "phoneType": isIOS?1:2
|
|
|
+ "phoneType": isIOS ? 1 : 2
|
|
|
}).then(res => {
|
|
|
if (WeixinJSBridge) {
|
|
|
WeixinJSBridge.invoke("getBrandWCPayRequest", res.data.data, async function (res: any) {
|
|
@@ -22,6 +23,10 @@ export const CourseCatalog: React.FC = (props: any) => {
|
|
|
// 使用以上方式判断前端返回,微信团队郑重提示:
|
|
|
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
|
|
console.log('支付成功')
|
|
|
+ window.setTimeout(()=>{
|
|
|
+ window.location.reload()
|
|
|
+ },1500)
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -33,6 +38,8 @@ export const CourseCatalog: React.FC = (props: any) => {
|
|
|
})
|
|
|
// wx.chooseWXPay()
|
|
|
}
|
|
|
+ const id = Number(new URLSearchParams(window.location.search).get("id") || '0')
|
|
|
+ const myExamIds = useRef<number[]>([])
|
|
|
const [list, setList] = useState([{
|
|
|
"createTime": "2023-05-09 21:43:53",
|
|
|
"updateTime": "2023-05-11 13:42:22",
|
|
@@ -66,6 +73,20 @@ export const CourseCatalog: React.FC = (props: any) => {
|
|
|
|
|
|
})
|
|
|
}
|
|
|
+ Toast.loading({
|
|
|
+ message:'加载中'
|
|
|
+ })
|
|
|
+ api.studentVipExamList().then(res => {
|
|
|
+ console.log(res)
|
|
|
+ myExamIds.current = res.data.rows.map(item => {
|
|
|
+ return item.examId
|
|
|
+ })
|
|
|
+ // myExamIds.current=[1]
|
|
|
+ Toast.clear()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ })
|
|
|
}, [])
|
|
|
|
|
|
return (
|
|
@@ -104,26 +125,33 @@ export const CourseCatalog: React.FC = (props: any) => {
|
|
|
|
|
|
className="pay"
|
|
|
>
|
|
|
- <div onClick={()=>{
|
|
|
- wxPay()
|
|
|
+ {
|
|
|
+ !myExamIds.current.includes(Number(id)) ? <div onClick={() => {
|
|
|
+ wxPay()
|
|
|
|
|
|
- }} className="pay-text">
|
|
|
- <span
|
|
|
- >立即支付 ¥{price}</span>
|
|
|
+ }} className="pay-text">
|
|
|
+ <span
|
|
|
+ >立即支付 ¥{price}</span>
|
|
|
|
|
|
- {/* <span >已购买</span> */}
|
|
|
- </div>
|
|
|
- <img
|
|
|
|
|
|
- style={{ width: '100%' }}
|
|
|
+ </div> : <span className="pay-text">已购买</span>
|
|
|
+ }
|
|
|
+
|
|
|
+ {
|
|
|
+ !myExamIds.current.includes(Number(id)) ? <img
|
|
|
+
|
|
|
+ style={{ width: '100%' }}
|
|
|
+
|
|
|
+ src="https://ndata.zzxcx.net/ctjk/mp-wx/courseCatalog/payBg.png"
|
|
|
+ ></img> : <img
|
|
|
+ style={{ width: '100%' }}
|
|
|
+
|
|
|
+ src="https://ndata.zzxcx.net/ctjk/mp-wx/courseCatalog/alreadyPay.png"
|
|
|
+ ></img>
|
|
|
|
|
|
- src="https://ndata.zzxcx.net/ctjk/mp-wx/courseCatalog/payBg.png"
|
|
|
- ></img>
|
|
|
- {/* <img
|
|
|
- style={{ width: '100%' }}
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- src="https://ndata.zzxcx.net/ctjk/mp-wx/courseCatalog/alreadyPay.png"
|
|
|
- ></img> */}
|
|
|
</div>
|
|
|
<div className="advantage">
|
|
|
<div className="advantage-title"> 实拍优势</div>
|