收藏
回答

使用明文URL Scheme拉起小程序,部分手机无法拉起,点击跳转也无效,部分手机是有效的?

框架类型 问题类型 操作系统 操作系统版本 手机型号 微信版本
小程序 Bug iOS 14.3 IPhone 11 Pro 未知

https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/url-scheme.htmlhttps://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/url-scheme.html

跳转逻辑

(function () {
      function GetQueryValue(queryName) {
        var reg = new RegExp("(^|&)" + queryName + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) {
          return decodeURI(r[2]);
        } else {
          return null;
        }
      }


      var jump = function () {
        const appid = "xxx";
        const token = GetQueryValue("id");
        const type = GetQueryValue("type");
        const batch = GetQueryValue("batch");
        const bookId = GetQueryValue("bookId");
        const versionId = GetQueryValue("versionId");


        let query = {};
        let queryStr = "";
        let href = "";
        let path = "";
        if (type == "answer") {
          /* query = {
            batch: batch,
          } */
          path = "page/words/print-details";
          queryStr = `batch=${batch}`;
          href = `weixin://dl/business/?appid=${appid}&path=${path}&query=${encodeURIComponent(
            queryStr
          )}&env_version=release`;
        } else if (type == "learning") {
          /* query = {
            id: token,
            type: "learning",
            status: "all",
            learningMode: 1,
            source: "scan",
          }; */
          path = "page/words/start";
          queryStr = `id=${token}&type=learning&status=all&learningMode=1&source=scan`;
          href = `weixin://dl/business/?appid=${appid}&path=${path}&query=${encodeURIComponent(
            queryStr
          )}&env_version=release&source=scan`;
        } else if (type == "listening") {
          /* query = {
            bookId: bookId,
            versionId: versionId,
            type: "listening",
            source: "scan",
          }; */
          path = "page/listening/list";
          queryStr = `bookId=${bookId}&versionId=${versionId}&type=listening&source=scan`;
          href = `weixin://dl/business/?appid=${appid}&path=${path}&query=${encodeURIComponent(
            queryStr
          )}&env_version=release&source=scan`;
        } else if (type == "dictation") {
          /* query = {
            batch: batch,
            type: "dictation",
          }; */
          path = "page/dictation/print-details";
          queryStr = `batch=${batch}&type=dictation`;
          href = `weixin://dl/business/?appid=${appid}&path=${path}&query=${encodeURIComponent(
            queryStr
          )}&env_version=release&source=scan`;
        }
        window.location.href = href;
      };


      document.getElementById("button").onclick = function () {
        jump();
      };
      jump();
    })();


最后一次编辑于  07-17
回答关注问题邀请回答
收藏

1 个回答

  • 智能回答 智能回答 本次回答由AI生成
    07-17
    有用
登录 后发表内容