liushengqiang 2 роки тому
батько
коміт
49ecea3edb

+ 6 - 0
src/views/coursewarePlay/component/musicScore.module.less

@@ -39,4 +39,10 @@
   &:active{
     opacity: .8;
   }
+}
+.loading{
+  position: absolute;
+  left: 50%;
+  top: 0;
+  transform: translateX(-50%);
 }

+ 15 - 0
src/views/coursewarePlay/component/musicScore.tsx

@@ -4,6 +4,8 @@ import qs from 'query-string'
 import OEmpty from '@/components/o-empty'
 import iconStart from '../image/icon-start.svg'
 import { postMessage } from '@/helpers/native-message'
+import { Loading } from 'vant'
+import { usePageVisibility } from '@vant/use'
 
 export default defineComponent({
   name: 'musicScore',
@@ -18,6 +20,16 @@ export default defineComponent({
   },
   emits: ['setIframe'],
   setup(props, { emit }) {
+    const isLoading = ref(false)
+    const pageVisibility = usePageVisibility()
+    /** 页面显示和隐藏 */
+    watch(pageVisibility, (value) => {
+      if(value == 'hidden'){
+        isLoading.value = true
+      } else {
+        isLoading.value = false
+      }
+    })
     const iframeRef = ref()
     const renderError = ref(false)
     const renderSuccess = ref(false)
@@ -52,6 +64,8 @@ export default defineComponent({
 
     // 去云教练完整版
     const gotoAccomany = () => {
+      if (isLoading.value) return;
+      isLoading.value = true
       const parmas = qs.stringify({
         id:  props.music.content,
       })
@@ -92,6 +106,7 @@ export default defineComponent({
               gotoAccomany()
             }}>
               <img src={iconStart} />
+              {/* <Loading class={styles.loading} color="rgba(63,134,237,1)" /> */}
             </div>
           </>
         )}