|
@@ -23,9 +23,9 @@ export const CourseCatalog: React.FC = (props: any) => {
|
|
|
// 使用以上方式判断前端返回,微信团队郑重提示:
|
|
|
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
|
|
Toast.loading({
|
|
|
- message:'支付中',
|
|
|
- duration:3000,
|
|
|
-
|
|
|
+ message: '支付中',
|
|
|
+ duration: 3000,
|
|
|
+
|
|
|
})
|
|
|
window.setTimeout(() => {
|
|
|
Toast.clear()
|
|
@@ -43,21 +43,71 @@ export const CourseCatalog: React.FC = (props: any) => {
|
|
|
})
|
|
|
// wx.chooseWXPay()
|
|
|
}
|
|
|
-
|
|
|
+ const [isVideoFree,setIsVideoFree] = useState<string>('-1')
|
|
|
+ const createPayButton = () => {
|
|
|
+ if (isVideoFree == '1') {
|
|
|
+ return (<div
|
|
|
+
|
|
|
+ className="pay"
|
|
|
+ ><span className="pay-text">免费观看</span><img style={{ width: '100%' }} src='https://ndata.zzxcx.net/ctjk/mp-wx/courseCatalog/alreadyPay.png'></img></div>)
|
|
|
+ }
|
|
|
+ if (isVideoFree == '0' && !myExamIds.current.includes(Number(id))) {
|
|
|
+ return (<div className='pay'>
|
|
|
+ <div onClick={() => {
|
|
|
+ wxPay()
|
|
|
+
|
|
|
+ }} className="pay-text">
|
|
|
+ <span
|
|
|
+ >立即支付 ¥{price}</span>
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <img style={{ width: '100%' }} src='https://ndata.zzxcx.net/ctjk/mp-wx/courseCatalog/payBg.png'></img>
|
|
|
+ </div>)
|
|
|
+ }
|
|
|
+ else if (isVideoFree == '0' && myExamIds.current.includes(Number(id))) {
|
|
|
+ return (<div className='pay'>
|
|
|
+
|
|
|
+ <span className="pay-text">已购买</span>
|
|
|
+ <img
|
|
|
+ style={{ width: '100%' }}
|
|
|
+
|
|
|
+ src="https://ndata.zzxcx.net/ctjk/mp-wx/courseCatalog/alreadyPay.png"
|
|
|
+ ></img>
|
|
|
+ </div>)
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return (<div className='pay'>
|
|
|
+
|
|
|
+ <span className="pay-text">加载中...</span>
|
|
|
+ <img
|
|
|
+ style={{ width: '100%' }}
|
|
|
+
|
|
|
+ src="https://ndata.zzxcx.net/ctjk/mp-wx/courseCatalog/alreadyPay.png"
|
|
|
+ ></img>
|
|
|
+ </div>)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
const id = Number(new URLSearchParams(window.location.search).get("id") || '0')
|
|
|
const myExamIds = useRef<number[]>([])
|
|
|
+
|
|
|
const allowLook = (item: any) => {
|
|
|
if (item.permission == 1) {
|
|
|
window.location.href = item.videoUrl
|
|
|
return
|
|
|
}
|
|
|
- if(myExamIds.current.includes(id)){
|
|
|
+ if (myExamIds.current.includes(id)) {
|
|
|
window.location.href = item.videoUrl
|
|
|
return
|
|
|
}
|
|
|
Toast.info({
|
|
|
- message:"请购买",
|
|
|
- duration:1500
|
|
|
+ message: "请购买",
|
|
|
+ duration: 1500
|
|
|
})
|
|
|
|
|
|
|
|
@@ -99,6 +149,13 @@ export const CourseCatalog: React.FC = (props: any) => {
|
|
|
Toast.loading({
|
|
|
message: '加载中'
|
|
|
})
|
|
|
+ api.openApiSystemDictDataType("nbjk_set").then(res=>{
|
|
|
+ res.data.data.forEach(item=>{
|
|
|
+ item.dictLabel=='IS_VIDEO_FREE'?setIsVideoFree(item.dictValue):''
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ })
|
|
|
api.studentVipExamList().then(res => {
|
|
|
console.log(res)
|
|
|
myExamIds.current = res.data.rows.map(item => {
|
|
@@ -106,9 +163,6 @@ export const CourseCatalog: React.FC = (props: any) => {
|
|
|
})
|
|
|
// myExamIds.current=[1]
|
|
|
Toast.clear()
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
})
|
|
|
}, [])
|
|
|
|
|
@@ -118,7 +172,7 @@ export const CourseCatalog: React.FC = (props: any) => {
|
|
|
{list.map(Item => {
|
|
|
return (<div
|
|
|
|
|
|
- onClick={()=>{
|
|
|
+ onClick={() => {
|
|
|
allowLook(Item)
|
|
|
}}
|
|
|
className="video-item"
|
|
@@ -146,38 +200,7 @@ export const CourseCatalog: React.FC = (props: any) => {
|
|
|
|
|
|
|
|
|
</div >
|
|
|
- <div
|
|
|
-
|
|
|
- className="pay"
|
|
|
- >
|
|
|
- {
|
|
|
- !myExamIds.current.includes(Number(id)) ? <div onClick={() => {
|
|
|
- wxPay()
|
|
|
-
|
|
|
- }} className="pay-text">
|
|
|
- <span
|
|
|
- >立即支付 ¥{price}</span>
|
|
|
-
|
|
|
-
|
|
|
- </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>
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- </div>
|
|
|
+ {createPayButton()}
|
|
|
<div className="advantage">
|
|
|
<div className="advantage-title"> 实拍优势</div>
|
|
|
<div className="advantage-img">
|