Sfoglia il codice sorgente

Merge branch 'test'

DESKTOP-SVI9JE1\muzen 1 anno fa
parent
commit
f2119f1b51
2 ha cambiato i file con 26 aggiunte e 16 eliminazioni
  1. 23 14
      src/App.vue
  2. 3 2
      src/pages/content/index.vue

+ 23 - 14
src/App.vue

@@ -6,22 +6,31 @@ export default {
     // 状态栏
     statusBarHeight: 20,
     // 设备信息
-    deviceInfo: {}
+    deviceInfo: {},
+    // 是否在App内部H5
+    inside: false
   },
   onLaunch() {
-    // 获取App方法
-    getUserInfo.postMessage('获取用户信息')
-    getDeviceInfo.postMessage('获取设备信息')
-    getMWDeviceInfo.postMessage('获取音响信息')
-    // 暴露setUserInfo方法给APP
-    window['setUserInfo'] = res => {
-      this.globalData.userInfo = JSON.parse(res)
-    }
-    window['setDeviceInfo'] = res => {
-      this.globalData.statusBarHeight = JSON.parse(res).statusHeight
-    }
-    window['setMWDeviceInfo'] = res => {
-      this.globalData.deviceInfo = JSON.parse(res)
+    try {
+      // 获取App方法
+      getUserInfo.postMessage('获取用户信息')
+      getDeviceInfo.postMessage('获取设备信息')
+      getMWDeviceInfo.postMessage('获取音响信息')
+      // 在App内部H5
+      this.globalData.inside = true
+      // 暴露setUserInfo方法给APP
+      window['setUserInfo'] = res => {
+        this.globalData.userInfo = JSON.parse(res)
+      }
+      window['setDeviceInfo'] = res => {
+        this.globalData.statusBarHeight = JSON.parse(res).statusHeight
+      }
+      window['setMWDeviceInfo'] = res => {
+        this.globalData.deviceInfo = JSON.parse(res)
+      }
+    } catch {
+      // 在浏览器H5
+      this.globalData.inside = false
     }
   }
 }

+ 3 - 2
src/pages/content/index.vue

@@ -10,7 +10,8 @@
           <img v-if="item.layoutType === 0" mode="aspectFit" :src="item.contentPic" />
           <!-- 音频 -->
           <my-audio v-if="item.layoutType === 1" :ref="`video${item.sort}`" :bg="form.audioBackgroundImage"
-            :pic="item.contentPic" :name="item.contentName" :singer="item.contentInfo.singerName" :status="item.playStatus" @click="getPlay($event, item)" />
+            :pic="item.contentPic" :name="item.contentName" :singer="item.contentInfo.singerName"
+            :status="item.playStatus" @click="getPlay($event, item)" />
           <!-- 歌单 、专辑 -->
           <my-list v-if="item.layoutType === 2" :pic="item.contentPic" :name="item.contentName" :data="item.contentInfo"
             :type="item.contentType" @click="getOpen(item)" />
@@ -38,7 +39,7 @@ export default {
   data() {
     return {
       // 判断是否为APP内部H5
-      inside: JSON.stringify(getApp().globalData.userInfo) == "{}" ? false : true,
+      inside: getApp().globalData.inside,
       // 表单
       form: {},
       // 跳转地址