Shopify Public App INSTALL按钮重定向奇怪

时间:2017-04-08 14:46:15

标签: javascript pug shopify

这是Shop的管理员用户点击“安装”按钮

后发生的奇怪现象

用户点击' GET'按钮,这工作得很好。用户看到的下一页是“安装”。按钮页面。

当用户点击安装时,会回复我的服务器,我会发送请求并返回适用的令牌。

然后转到我的服务器并提供一个页面,该页面在浏览器的完整窗口中呈现。我希望它出现在store's/admin/apps/_myapp_页面的iFrame中。

如果我关闭页面。然后导航到store's/admin/apps/_myapp_我主机 的页面现在正如您所期望的那样在iFrame中正确呈现。

提示/想法。 “安装”中的点击发生了什么或者没有发生什么?按钮

但这就是我发送给他“安装”的决议页面的方式。我相信我有适当的重新设定。但也许你会看到我没有的东西。这是在Jade / Pug。

extends layout
block content
  script(src="/jquery/dist/jquery.js")
  script.
    function doThePost() {
      alert('hello world');
    }

  h1= title
  p Welcome to #{title}
  p
  p
  p
  input(type="text", id="shopUrl", name="shopUrl", value="#{shopUrl}", hidden="hidden")
  input(type="text", id="shop", name="shop", value="#{shop}", hidden="hidden")
  p
  button(onclick='doThePost()') v1Demo
  p
  p end

  script(type="text/javascript").
    var shpUrl = $('#shopUrl').val();
    var shp = $('#shop').val();
    // If the current window is the 'parent', change the URL by setting location.href
    if (window.top == window.self) {
      window.top.location.href = 'https://' + shpUrl + '/admin/oauth?shop=' + shp;
    // If the current window is the 'child', change the parent's URL with postMessage
    } else {
      message = JSON.stringify({
        message: "Shopify.API.remoteRedirect"
        , data: { location: window.location.origin + '/admin/oauth?shop=' + shp }
      });
      window.parent.postMessage(message, 'https://' + shpUrl);
    }

0 个答案:

没有答案