收藏
回答

点金计划商户小票无法查询订单什么原因?

测试机型iphone6s,iphone12 无法查询订单;安卓手机,苹果14可以查询订单,服务器用的tomcat7,

已经参考了https://developers.weixin.qq.com/community/develop/doc/000ae6b1a98cc099e64ba71f456009?highline=%E7%82%B9%E9%87%91%E8%AE%A1%E5%88%92,依然没有收获

    
    
    
    出行通知
    


    
        
        
        
        
        
            
                加载中...

            

        

    



    
        // 获取URL参数
        function getQueryParam(name) {
            const urlParams = new URLSearchParams(window.location.search);
            return urlParams.get(name);
        }
        
        // 初始化微信商家小票
        function wxInit() {
            if (window.parent) {
                try {
                    const mchData = {
                        action: 'onIframeReady',
                        displayStyle: 'SHOW_CUSTOM_PAGE',
	        height:960
                    };
                    const postData = JSON.stringify(mchData);
                    window.parent.postMessage(postData, 'https://payapp.weixin.qq.com');
                } catch (error) {
                    console.log('微信初始化失败:', error);
                }
            }
        }
        
        // 获取出行通知信息
        async function getTravelNotice() {
            const outTradeNo = getQueryParam('out_trade_no');
            const container = document.getElementById('contentContainer');
            
            if (!outTradeNo) {
                container.innerHTML = '<div class="no-data">缺少必要的参数</div>';
                return;
            }
            
            try {
                const baseUrl = "";
                // 构建请求URL - 根据实际情况调整路径
                const apiUrl = '/mobile/line/getTravelNoticeByOutTradeNo.jhtml?' + 
                    new URLSearchParams({ outTradeNo: outTradeNo });
                
                const response = await fetch(baseUrl+apiUrl);
                const data = await response.json();
                
                if (data && data.success) {
                    container.innerHTML = data.output || '<div class="no-data">暂无数据</div>';
                } else {
                    container.innerHTML = '<div class="no-data">系统繁忙,请稍后再试~</div>';
                }
                
                // 初始化微信功能
                wxInit();
                
            } catch (error) {
                console.error('请求失败:', error);
                container.innerHTML = '<div class="no-data">网络错误,请检查连接</div>';
            }
        }
        
        // 返回功能
        function setupBackButton() {
            const backBtn = document.getElementById('backBtn');
            const referrer = document.referrer;
            
            // 如果有上一页,显示返回按钮
            if (referrer && referrer !== window.location.href) {
                backBtn.style.display = 'block';
                backBtn.onclick = function() {
                    window.history.back();
                };
            }
        }
        
        // 图片懒加载(简化版)
        function lazyLoadImages() {
            const images = document.querySelectorAll('.content-list img');
            const observer = new IntersectionObserver((entries) => {
                entries.forEach(entry => {
                    if (entry.isIntersecting) {
                        const img = entry.target;
                        if (img.dataset.src) {
                            img.src = img.dataset.src;
                        }
                        observer.unobserve(img);
                    }
                });
            });
            
            images.forEach(img => observer.observe(img));
        }
        
        // 页面加载完成后执行
        document.addEventListener('DOMContentLoaded', function() {
        // 1. 确保body可滚动
        document.body.style.overflow = 'auto';
        document.body.style.height = 'auto';
        
        // 2. 确保html元素可滚动
        document.documentElement.style.overflow = 'auto';
        document.documentElement.style.height = 'auto';
// 3. 检测是否在iframe中
        if (window.self !== window.top) {
          // 在小票链接中
          console.log('在小票链接环境中');
          
          // 尝试与父页面通信调整高度
          const sendHeight = () => {
            const height = document.documentElement.scrollHeight;
            try {
              window.parent.postMessage({
                type: 'iframeHeight',
                height: height,
                source: 'ticketPage'
              }, '*');
            } catch (e) {
              console.log('无法与父页面通信');
            }
          };
          
          // 初始发送高度
          setTimeout(sendHeight, 100);
          
          // 内容变化时重新发送高度
          const observer = new MutationObserver(sendHeight);
          observer.observe(document.body, {
            childList: true,
            subtree: true,
            attributes: true
          });
        }
        
        // 4. 启用iOS弹性滚动
        const style = document.createElement('style');
        style.textContent = `
          * {
            -webkit-overflow-scrolling: touch !important;
          }
          body {
            overscroll-behavior-y: auto !important;
          }
        `;
        document.head.appendChild(style);
      


            getTravelNotice();
            
            // 监听内容变化,设置图片懒加载
            const observer = new MutationObserver(function() {
                lazyLoadImages();
            });
            
            observer.observe(document.getElementById('contentContainer'), {
                childList: true,
                subtree: true
            });
        });
    



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

1 个回答

  • 焕^_^
    焕^_^
    02-09

    将body的script移到header问题解决了


    02-09
    有用
    回复
登录 后发表内容