Browse Source

feature:增加喜马拉雅授权成功的检测判断

zeng.chen 10 hours ago
parent
commit
4f1b856bfa
4 changed files with 35 additions and 4 deletions
  1. 3 1
      app.js
  2. 15 1
      pages/pageB/authWeb/authWeb.js
  3. 1 1
      pages/pageB/authWeb/authWeb.wxml
  4. 16 1
      pages/pageB/deviceWake/deviceWake.js

+ 3 - 1
app.js

@@ -287,7 +287,9 @@ App({
       if (option.other) {
         data.other = option.other;
       };
-
+      data.other = data.other || {};
+      data.other.is_debug = that.globalData.is_debug;
+      data.other.version = 3;
       // /AIrSMArT_7cdfa1fd3af0/user/sub_control
       var publish = `/${DstDeviceName}/user/sub_control`;
       // {"type":"get_dev_info","DstDeviceName":"AIrSMArT_7cdfa1fd3af0","SrcDeviceName":"ALY_933625"}

+ 15 - 1
pages/pageB/authWeb/authWeb.js

@@ -13,6 +13,7 @@ Page({
         console.log("返回界面3:");
       }
     },
+    webCount: 0,
 
     // qrcodeUrl: "https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20250328100356565128956.png",
     qrcodeUrl: "",
@@ -107,7 +108,20 @@ Page({
       qrcodeUrl: url
     });
   },
-
+  bindload(e) {
+    console.log("webview加载完成:", e);
+    // 当做是加载成功了
+    this.data.webCount++;
+    if (this.data.webCount > 3) {
+      const pages = getCurrentPages();
+      if (pages.length < 2) {
+        return;
+      }
+      const prevPage = pages[pages.length - 2];
+      // 修改授权
+      prevPage.getAuthStatus(true);
+    }
+  },
   handleWebviewMessage(e) {
     // e.detail.data 是网页 postMessage 发送的数据数组
     console.log('收到 web-view 消息:', e);

+ 1 - 1
pages/pageB/authWeb/authWeb.wxml

@@ -4,4 +4,4 @@
     <web-view class="web-view" src="{{qrcodeUrl}}" bindmessage="webChannel"></web-view>
 </view> -->
 <!-- style="height: calc(100vh - {{navBarHeight}}px); width:100%; margin-top:{{navBarHeight}}px" -->
-<web-view src="{{qrcodeUrl}}" bindmessage="handleWebviewMessage"></web-view>
+<web-view src="{{qrcodeUrl}}" bindmessage="handleWebviewMessage" bindload="bindload"></web-view>

+ 16 - 1
pages/pageB/deviceWake/deviceWake.js

@@ -257,14 +257,29 @@ Page({
       default:
     }
   },
-  getAuthStatus() {
+  getAuthStatus(showXmlyToast = false) {
     var that = this;
     // 这个界面只有wifi的?
     getAuthStatus(EnumPlatformId.QQ, that.getDeivce()).then((res) => {
       that.setData({ isQQAuth: res });
+
     });
     getAuthStatus(EnumPlatformId.XMLY, that.getDeivce()).then((res) => {
       that.setData({ isAuthXmly: res });
+      if (showXmlyToast) {
+        wx.showModal({
+          title: 'QQ音乐授权成功',
+          showCancel: false,
+          success(res) {
+            if (res.confirm) {
+              console.log('用户点击确定');
+              wx.navigateBack({
+                delta: 1
+              });
+            }
+          }
+        })
+      };
     });
   },