TypechoJoeTheme

Dcr163的博客

统计

微擎人人商城网页快照和虚拟微信用户修复

2022-11-13
/
5 评论
/
520 阅读
/
正在检测是否收录...
11/13

微擎人人商城网页快照和虚拟微信用户修复

自从微信公众号平台更新了用户授权的规则,微擎以前默认自动授权的方式,总是会出现网页快照,因为微擎默认的方式是打开前端默认跳转到微信授权的那个链接;正是因为没有经过用户的点击就授权,会常常出现网页快照,导致系统里总是会出现很多“微信用户”的虚拟用户,导致用户在人人商城或其他商城内出现下单付款失败的问题。

现在我们只需要把微擎默认的自动授权方式,改为引导用户手动点击授权就可以了;下面是修改的方式,需要修改到微擎源码。

第一步,新建一个手动授权的模板html文件,我这里命名为publicAuth.html,文件里的代码如下(可以根据自己的需要修改):

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
    <title>授权登录-{$_W['account']['name']}</title>
    <meta name="keywords" content="{$_W['account']['name']}">
    <meta name="description" content="{$_W['account']['name']}">
    <style>
        .container {
            padding: 50px 15px;
            text-align: center;
        }

        .logo {
            width: 140px;
            margin: 0 auto 42px;
            text-align: center;
        }

        .logo img {
            max-width: 100%;
            vertical-align: middle;
        }

        .container h2 {
            margin: 0;
            padding: 0;
            line-height: 44px;
            font-size: 24px;
            font-weight: 500;
        }

        .container p {
            margin: 0;
            padding: 0;
            line-height: 34px;
            font-size: 16px;
        }

        .auth-btn {
            width: 98%;
            display: block;
            line-height: 50px;
            background: #0bb20c;
            color: #FFFFFF;
            text-align: center;
            font-size: 20px;
            border-radius: 24px;
            text-decoration: none;
            margin-top: 44px;
        }
        .is-snapshoot {
            display: none;
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
            background: url('resource/images/snapshoot_bg.png') no-repeat;
            background-position: center;
            background-size: 100% 100%;
            z-index: 1;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="logo">
        <img src="{$_W['account']['logo']}"
             alt="{$_W['account']['name']}"></div>
    <h2>您好,请先登录~</h2>
    <p>授权登录后,可以更好的享受我们的服务!</p>
    <div class="login-btn">
        <a class="auth-btn" href="{$forward}">点击授权登录</a>
    </div>
</div>
<div class="is-snapshoot" {if isset($_GPC['is_snapshotuser']) && $_GPC['is_snapshotuser'] == '1' }style="display:block;"{/if} >
</div>
</body>
</html>

新建好文件后,我们把它放在目录:/app/themes/default/auth/publicAuth.html

第二步,修改 /app/common/bootstrap.app.inc.php这个文件,只需要在这块代码下

        if ($oauth_type == 'snsapi_base') {
            $forward = $oauth_account->getOauthCodeUrl($callback, $state);
        } else {
            $forward = $oauth_account->getOauthUserInfoUrl($callback, $state);
        }

大概168行附近新增:

template('auth/publicAuth');
exit();

第三步,修改用户授权SESSION有效时间;把 /app/common/bootstrap.app.inc.php 文件里的
这段代码
WeSession::start($_W['uniacid'], CLIENT_IP);
替换成:
WeSession::start($_W['uniacid'], CLIENT_IP, (15 * 86400)); //15天有效期
上面的有效期根据自己的情况设置

第四步,用户不授权的情况,再次进入系统,也会变成虚拟用户;修改文件:/app/source/auth/oauth.ctrl.php
在文件这段代码:

$oauth = $oauth_account->getOauthInfo($code);

下面新增(大概31行左右):

//  dcr163.cn start
if( isset($oauth['is_snapshotuser']) &&  intval($oauth['is_snapshotuser']) === 1){
    $_SESSION['oauth_openid'] = '';
    $backUrl = urldecode($_SESSION['dest_url']).'&is_snapshotuser=1'; //设置当前为快照模式,可以在授权页加个箭头引导右下角微信官方授权页面,这里可以自由发挥
    header('Location: ' . $backUrl);
    exit();
}
//  dcr163.cn end

第五步,把下面这张图片上传到 这个目录下/app/resource/images/snapshoot_bg.png

当访问快照的时候,会显示下面的那个页面,不是快照没有登录则跳转到登录页面。

最终,当用户访问人人商城或其他插件的时候,就会先跳转到手动授权登录页面,基本避免了用户打开我们商城就出现快照的模式;

欢迎大家评论区讨论~

微擎网页快照微信用户
朗读
赞(4)
版权属于:

Dcr163的博客

本文链接:

https://dcr163.cn/663.html(转载时请注明本文出处及文章链接)

评论 (5)
  1. 学习用户 作者
    Windows 7 · Google Chrome

    试过了,很好用,测试几个手机没问题

    2022-11-18 回复
  2. 微擎 作者
    Windows 10 · Google Chrome

    发现个bug,不从公众号进入没问题,如果是从公众号菜单进入的话,不提示授权,直接进入,获取不到用户头像 昵称 和openid

    2022-11-14 回复
    1. Shadow 作者
      Windows 10 · Google Chrome
      @微擎

      我这边测试过,在公众号菜单里添加链接,是正常的,可以自己再调试看看,能解决就好。

      2022-11-16 回复
  3. 为请用户 作者
    Windows 10 · Google Chrome

    测试过了,还是有个bug,点击授权登陆后,在弹出来的层,点取消,在进去还是显示快照页

    2022-11-13 回复
    1. Shadow 作者
      Windows 10 · Google Chrome
      @为请用户

      快照页测了很多此还是没办法避免,现在改了一些代码,现在逻辑会好很多,虚拟用户不会入库了,可以关注下文章。

      2022-11-13 回复

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. wzfaibaba
    2022-12-26
  2. 学习用户
    2022-11-18
  3. 微擎
    2022-11-14
  4. 为请用户
    2022-11-13
  5. admin
    2021-08-15

    {!{data:image/webp;base64,UklGRkAOAABXRUJQVlA4WAoAAAAQAAAAAQMAKwEAQUxQSEgMAAAB8Idt/yKn/f896oZDoO6Cu9trGxxeL3yxUFxTZCmuwa0WJHVeBHcPLvt6ldRCQwUPFPckhHho5P7j8ZjZ2cmEOeb5lo2ICaCA/wP+D/g/4P+A/wP+D/g/4P//p6ZL+eu2Ddu6KX57AexV/MAD/gv47/+aKPp69RCXPKDKi0+qc0O7hU75LHJn9OlbD+Br4tnvN385a2TIWMXtkwyYMWW2wvZoOMzqVtYqHIB53Yqa+xZ8/fvurfvnvTzu/s37PsCtpIVBvrL808lDuzSt/noR8vGJl6o26+GZ8811AW717MXNkEeQ/zcKcKtmTc9DPOciM24U4FbLRkHeWpLMuVHAfIXsmUjI08m0GwW4lbFa5yFe70Qm3ijArYhNhLzvXTL17wLcSlhfyJ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