skyblued 2 سال پیش
والد
کامیت
827dd8f7f8
5فایلهای تغییر یافته به همراه42 افزوده شده و 8 حذف شده
  1. 1 1
      src/api-router.ts
  2. 7 7
      src/helpers/request.ts
  3. 7 0
      src/helpers/utils.ts
  4. 24 0
      src/pages/detail/runtime.ts
  5. 3 0
      src/subpages/colexiu/uses/use-user.ts

+ 1 - 1
src/api-router.ts

@@ -1,7 +1,7 @@
 import { getRequestHostname } from '/src/helpers/utils'
 import qs from 'query-string'
 
-const isManage = getRequestHostname() === '/api-web'
+const isManage = getRequestHostname() === '/api-backend'
 // 后台管理,教学伴奏预览专用参数
 const parseSearch: any = qs.parse(location.search)
 

+ 7 - 7
src/helpers/request.ts

@@ -2,7 +2,7 @@ import { extend } from 'umi-request'
 import { Toast } from 'vant'
 import cleanDeep from 'clean-deep'
 import { getRequestHostname, browser } from '/src/helpers/utils'
-import ApiRouter from '/src/api-router'
+// import ApiRouter from '/src/api-router'
 import { postMessage } from './native-message'
 
 export interface SearchInitParams {
@@ -28,12 +28,12 @@ const request = extend({
 
 request.use(async (ctx, next) => {
   const { url, options } = ctx.req
-  const prefix = (options.prefix || '')
-  const baseUrl: string = url.replace(prefix, '') || ''
-  const linkUrl: string = (ApiRouter as any)[baseUrl]
-  if (linkUrl) {
-    ctx.req.url = prefix + linkUrl
-  }
+  // const prefix = (options.prefix || '')
+  // const baseUrl: string = url.replace(prefix, '') || ''
+  // const linkUrl: string = (ApiRouter as any)[baseUrl]
+  // if (linkUrl) {
+  //   ctx.req.url = prefix + linkUrl
+  // }
   await next()
 })
 

+ 7 - 0
src/helpers/utils.ts

@@ -41,6 +41,13 @@ export const browser = () => {
 }
 
 export const getRequestHostname = () => {
+  let search : any = ''
+  try {
+    search = qs.parse(location.search)
+  } catch (error) {}
+  if(search?.client){
+    return search.client === 'student' ? '/api-student' : search.client === 'teacher' ? '/api-teacher' : '/api-backend'
+  }
   const browserInfo = browser();
   if (browserInfo.isStudent){
     return '/api-student'

+ 24 - 0
src/pages/detail/runtime.ts

@@ -908,6 +908,30 @@ const updatePlayTime = async (time: number) => {
       })
       event.emit('updatePlayTimeSuccess', res.data)
     } catch (error) {}
+    //课后训练
+    if (search.lessonTrainingId) {
+      try {
+        console.log(prefix)
+        const res = await request.post('/studentLessonTraining/lessonTrainingRecord', {
+          prefix: prefix,
+          requestType: 'json',
+          data: {
+            materialType: 'SONG',
+            record: {
+              clientType: (clientType as string)?.toLocaleUpperCase(),
+              feature: 'LESSON_TRAINING',
+              deviceType: browserInfo.android ? 'ANDROID' : browserInfo.isApp ? 'IOS' : 'WEB',
+              behaviorId,
+              playTime: time,
+              musicSheetId: getLinkId(),
+            },
+            courseScheduleId: search.courseScheduleId,
+            lessonTrainingId: search.lessonTrainingId,
+            materialId: search.materialId,
+          },
+        })
+      } catch (error) {}
+    }
   }
 }
 

+ 3 - 0
src/subpages/colexiu/uses/use-user.ts

@@ -13,6 +13,9 @@ const browserInfo = browser()
 export type ClientType = 'student' | 'teacher' | 'web'
 
 export const useClientType = () => {
+  const search = useOriginSearch()
+  // console.log("🚀 ~ search", search)
+  if (search.client) return search.client
   /**
    * pathname 不可能是student | teacher
    */