浏览代码

新增需要购买考场才能看考场视频

JXDS18FUJT 1 年之前
父节点
当前提交
784cdc9709
共有 1 个文件被更改,包括 27 次插入7 次删除
  1. 27 7
      src/views/courseCatalog/components/courseCatalog/index.tsx

+ 27 - 7
src/views/courseCatalog/components/courseCatalog/index.tsx

@@ -23,9 +23,9 @@ export const CourseCatalog: React.FC = (props: any) => {
                         // 使用以上方式判断前端返回,微信团队郑重提示:
                         //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
                         console.log('支付成功')
-                        window.setTimeout(()=>{
+                        window.setTimeout(() => {
                             window.location.reload()
-                        },1500)
+                        }, 1500)
 
                     }
                 });
@@ -38,8 +38,26 @@ 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 allowLook = (item: any) => {
+        if (item.permission == 1) {
+            window.location.href = item.videoUrl
+            return
+        }
+        if(myExamIds.current.includes(id)){
+            window.location.href = item.videoUrl
+            return
+        }
+        Toast.info({
+            message:"请购买",
+            duration:1500
+        })
+
+
+
+    }
     const [list, setList] = useState([{
         "createTime": "2023-05-09 21:43:53",
         "updateTime": "2023-05-11 13:42:22",
@@ -74,7 +92,7 @@ export const CourseCatalog: React.FC = (props: any) => {
             })
         }
         Toast.loading({
-            message:'加载中'
+            message: '加载中'
         })
         api.studentVipExamList().then(res => {
             console.log(res)
@@ -93,9 +111,11 @@ export const CourseCatalog: React.FC = (props: any) => {
         <div className='courseCatalog'>
             <div className="video">
                 {list.map(Item => {
-                    return (<a
+                    return (<div
 
-                        href={Item.videoUrl}
+                        onClick={()=>{
+                            allowLook(Item)
+                        }}
                         className="video-item"
                         key={Item.id}
                     >
@@ -115,7 +135,7 @@ export const CourseCatalog: React.FC = (props: any) => {
                             <div style={{ width: '100%' }}>{Item.videoName}</div>
                             <div className="video-item-right-icon">学习中</div>
                         </div>
-                    </a >)
+                    </div >)
 
                 })}
 
@@ -150,7 +170,7 @@ export const CourseCatalog: React.FC = (props: any) => {
                     ></img>
 
                 }
-               
+
 
             </div>
             <div className="advantage">