收藏
回答

微信扫含有数值的码登录小程序后query.scene接收的值是不是我设置值?

我设置的是1775442346692448257 获取的是1775442346692448256

生成的代码private String getminiqrQr(Long userId) {
    String qrcode="";
   
    try
    {
        String accessToken = WeChat.getQJToken(weChatConfig.getLxrSjId(),weChatConfig.getLxrSjSecret(),weChatConfig.getQjTokenUrl());
        URL url = new URL("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+accessToken);
        HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
        httpURLConnection.setRequestMethod("POST");// 提交模式
        // conn.setConnectTimeout(10000);//连接超时 单位毫秒
        // conn.setReadTimeout(2000);//读取超时 单位毫秒
        // 发送POST请求必须设置如下两行
        httpURLConnection.setDoOutput(true);
        httpURLConnection.setDoInput(true);
        // 获取URLConnection对象对应的输出流
        PrintWriter printWriter = new PrintWriter(httpURLConnection.getOutputStream());
        // 发送请求参数
        JSONObject paramJson = new JSONObject();
      
        paramJson.put("scene", userId.toString());
        paramJson.put("page", "pages/index/index");
        paramJson.put("width", 430);
        paramJson.put("auto_color", true);
        /**
         * line_color生效
         * paramJson.put("auto_color", false);
         * JSONObject lineColor = new JSONObject();
         * lineColor.put("r", 0);
         * lineColor.put("g", 0);
         * lineColor.put("b", 0);
         * paramJson.put("line_color", lineColor);
         * */
        log.error(paramJson.toJSONString());
        printWriter.write(paramJson.toString());
        // flush输出流的缓冲
        printWriter.flush();
        //开始获取数据
        BufferedInputStream bis = new BufferedInputStream(httpURLConnection.getInputStream());

        SysOssVo sysOssVo = iSysOssService.uploadByInputStream(bis,".png","image/png");
         qrcode = sysOssVo.getUrl();

    } catch (Exception e)
    {
        throw new ServiceException("二维码生成失败:"+e.getMessage());
    }
    return qrcode;
}
获取的代码
   onLoad(option) {
                        const active = option.active || 0
                        const scene = decodeURIComponent(option.scene);
                        if(scene != '' && scene != undefined && scene != 'undefined'){
                                //设置全局变量
                                this.$store.commit('SET_DEVELOPERUSERID', scene)
                        }


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

2 个回答

  • 。。。。。。。。
    。。。。。。。。
    01-19
    生成的代码private String getminiqrQr(Long userId) {
        String qrcode="";
       
        try
        {
            String accessToken = WeChat.getQJToken(weChatConfig.getLxrSjId(),weChatConfig.getLxrSjSecret(),weChatConfig.getQjTokenUrl());
            URL url = new URL("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+accessToken);
            HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
            httpURLConnection.setRequestMethod("POST");// 提交模式
            // conn.setConnectTimeout(10000);//连接超时 单位毫秒
            // conn.setReadTimeout(2000);//读取超时 单位毫秒
            // 发送POST请求必须设置如下两行
            httpURLConnection.setDoOutput(true);
            httpURLConnection.setDoInput(true);
            // 获取URLConnection对象对应的输出流
            PrintWriter printWriter = new PrintWriter(httpURLConnection.getOutputStream());
            // 发送请求参数
            JSONObject paramJson = new JSONObject();
          
            paramJson.put("scene", userId.toString());
            paramJson.put("page", "pages/index/index");
            paramJson.put("width", 430);
            paramJson.put("auto_color", true);
            /**
             * line_color生效
             * paramJson.put("auto_color", false);
             * JSONObject lineColor = new JSONObject();
             * lineColor.put("r", 0);
             * lineColor.put("g", 0);
             * lineColor.put("b", 0);
             * paramJson.put("line_color", lineColor);
             * */
            log.error(paramJson.toJSONString());
            printWriter.write(paramJson.toString());
            // flush输出流的缓冲
            printWriter.flush();
            //开始获取数据
            BufferedInputStream bis = new BufferedInputStream(httpURLConnection.getInputStream());
    
            SysOssVo sysOssVo = iSysOssService.uploadByInputStream(bis,".png","image/png");
             qrcode = sysOssVo.getUrl();
    
        } catch (Exception e)
        {
            throw new ServiceException("二维码生成失败:"+e.getMessage());
        }
        return qrcode;
    }
    获取的代码
       onLoad(option) {
                            const active = option.active || 0
                            const scene = decodeURIComponent(option.scene);
                            if(scene != '' && scene != undefined && scene != 'undefined'){
                                    //设置全局变量
                                    this.$store.commit('SET_DEVELOPERUSERID', scene)
                            }
                    
    
    01-19
    有用
    回复
  • 智能回答 智能回答 本次回答由AI生成
    01-19
    有用
    回复
登录 后发表内容