Parcourir la source

新增免费观看参数来控制科目三视频

JXDS18FUJT il y a 1 an
Parent
commit
f3e4de3667

+ 8 - 0
src/api/index.ts

@@ -128,6 +128,14 @@ const api = {
             url:"student/vip/exam/list",
             method:'get'
         })
+    },
+    //根据字典类型查询字典数据信息
+    openApiSystemDictDataType(dictType:string):AxiosPromise<openApiSystemDictDataType>{
+        return request({
+            url:"open-api/system/dict/data/type/"+dictType,
+            method:'get'
+        })
+
     }
 
     

+ 20 - 0
src/api/type.d.ts

@@ -100,4 +100,24 @@ interface studentVipExamList extends Res {
         "expirationTime": string
     }[]
     total: number
+}
+interface openApiSystemDictDataType extends Res {
+    data: {
+        "searchValue": null,
+        "createBy": string,
+        "createTime": string,
+        "updateTime": null,
+        "updateBy": null,
+        "remark": null,
+
+        "dictCode": number,
+        "dictSort": number,
+        "dictLabel": string,
+        "dictValue": string,
+        "dictType": string,
+        "cssClass": null,
+        "listClass": null,
+        "isDefault": string,
+        "status": string
+    }[]
 }

+ 1 - 1
src/views/courseCatalog/components/courseCatalog/index.less

@@ -61,7 +61,7 @@
         width: 100%;
         text-align: center;
         color: white;
-        transform: translateY(-85%);
+        transform: translateY(-75%);
         display: flex;
         justify-content: center;
         align-items: center;

+ 66 - 43
src/views/courseCatalog/components/courseCatalog/index.tsx

@@ -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
+                    >立即支付&nbsp;&nbsp;¥{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
-                        >立即支付&nbsp;&nbsp;¥{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">