lex-xin 3 months ago
parent
commit
605dc48531

+ 19 - 0
src/helpers/validate.ts

@@ -15,6 +15,25 @@ export function vaildStudentUrl() {
   return returnUrl;
 }
 
+
+// 当前
+export function vaildCurrentUrl() {
+  const url = window.location.hostname;
+  let returnUrl = '';
+  if (/dev/.test(url)) {
+    // dev 环境
+    returnUrl = 'https://dev.gym.lexiaoya.cn';
+  } else if (/test/.test(url)) {
+    // dev 环境
+    returnUrl = 'https://test.gym.lexiaoya.cn';
+  } else {
+    // 默认线上环境
+    returnUrl = 'https://gym.lexiaoya.cn';
+  }
+  return returnUrl;
+}
+
+
 export function checkPhone(phone: string) {
   const phoneRule = /^((13[0-9])|(14(0|[5-7]|9))|(15([0-3]|[5-9]))|(16(2|[5-7]))|(17[0-8])|(18[0-9])|(19([0-3]|[5-9])))\d{8}$/;
   return phoneRule.test(phone);

+ 2 - 4
src/views/coursewarePlay/component/musicScore.tsx

@@ -8,6 +8,7 @@ import { usePageVisibility } from '@vant/use';
 import { useRoute } from 'vue-router';
 import { browser } from '@/helpers/utils';
 import { state } from '@/state';
+import { vaildCurrentUrl } from '@/helpers/validate';
 
 export default defineComponent({
   name: 'musicScore',
@@ -76,10 +77,7 @@ export default defineComponent({
       if (!browserInfo.ios) {
         isLoading.value = true;
       }
-      const origin = /(localhost|192)/.test(location.host)
-        ? 'https://test.gym.lexiaoya.cn'
-        : location.origin;
-      const src = `${origin}/accompany/?Authorization=${Authorization}#/detail/${props.music.content}?isHideBack=true`;
+      const src = `${vaildCurrentUrl()}/accompany/?Authorization=${Authorization}#/detail/${props.music.content}?isHideBack=true`;
       postMessage(
         {
           api: 'openAccompanyWebView',

+ 2 - 4
src/views/coursewarePlay/component/video-play.tsx

@@ -27,6 +27,7 @@ import TCPlayer from 'tcplayer.js';
 import 'tcplayer.js/dist/tcplayer.min.css';
 import { handleShowVip, state } from '@/state';
 import { showToast, Slider } from 'vant';
+import { vaildCurrentUrl } from '@/helpers/validate';
 
 // 秒转分
 export const getSecondRPM = (second: number, type?: string) => {
@@ -361,10 +362,7 @@ export default defineComponent({
       //   item.value.materialMusicId
       // }?Authorization=${Authorization}&isHideTitle=true`;
 
-    const origin = /(localhost|192)/.test(location.host)
-          ? 'https://test.gym.lexiaoya.cn/'
-          : location.origin;
-    const src = `${origin}/gym-music-score/?id=${item.value.materialMusicId}&isHideMusicList=true&systemType=${ state.platformType === 'TEACHER' ? 'teacher' : 'student'}`
+    const src = `${vaildCurrentUrl()}/gym-music-score/?id=${item.value.materialMusicId}&isHideMusicList=true&systemType=${ state.platformType === 'TEACHER' ? 'teacher' : 'student'}`
 
       postMessage({
         api: 'openAccompanyWebView',

+ 2 - 4
src/views/coursewarePlay/index.tsx

@@ -41,6 +41,7 @@ import CoursewareType from './component/courseware-type';
 import CoursewareTips from './component/courseware-tips';
 import GlobalTools from '@/components/globalTools';
 import { isHidden, isPlay, penShow, toolOpen, whitePenShow } from '@/components/globalTools/globalTools';
+import { vaildCurrentUrl } from '@/helpers/validate';
 
 export default defineComponent({
   name: 'CoursewarePlay',
@@ -1064,10 +1065,7 @@ export default defineComponent({
 
                             // const Authorization =
                             //   sessionStorage.getItem('Authorization') || '';
-                            const origin = /(localhost|192)/.test(location.host)
-                              ? 'https://test.gym.lexiaoya.cn/'
-                              : location.origin;
-                            const src = `${origin}/gym-music-score/?id=${m.materialMusicId}&isHideMusicList=true&systemType=${ state.platformType === 'TEACHER' ? 'teacher' : 'student'}`
+                            const src = `${vaildCurrentUrl()}/gym-music-score/?id=${m.materialMusicId}&isHideMusicList=true&systemType=${ state.platformType === 'TEACHER' ? 'teacher' : 'student'}`
                             postMessage({
                               api: 'openAccompanyWebView',
                               content: {

+ 3 - 2
src/views/hook/useFee.ts

@@ -1,5 +1,6 @@
 import { postMessage } from '@/helpers/native-message';
 import { browser } from '@/helpers/utils';
+import { vaildCurrentUrl } from '@/helpers/validate';
 import { state } from '@/state';
 import dayjs from 'dayjs';
 import { showDialog } from 'vant';
@@ -11,7 +12,7 @@ export const gotoMemberCenter = () => {
     pathname = '/mdaya/'
   }
   if (browserInfo.isApp) {
-    const url = window.location.origin + pathname + `#/member?id=${state.buyVipId}&type=${state.buyVipType}`;
+    const url = vaildCurrentUrl() + pathname + `#/member?id=${state.buyVipId}&type=${state.buyVipType}`;
     // const url = `https://test.gym.lexiaoya.cn/mdaya/#/member?id=${state.buyVipId}&type=${state.buyVipType}`;
     postMessage({
       api: 'openWebView',
@@ -22,7 +23,7 @@ export const gotoMemberCenter = () => {
     });
     return;
   }
-  location.href = window.location.origin + pathname + `#/member?id=${state.buyVipId}&type=${state.buyVipType}`;
+  location.href = vaildCurrentUrl() + pathname + `#/member?id=${state.buyVipId}&type=${state.buyVipType}`;
 };
 
 /**验证是否是会员 */