apiCloud结合layer实现动态数据弹出层

简介:

css

/** 我的二维码 begin **/
    .aui-list .wechat-media {
        width: 3rem;
    }

    .wechat-middle {
        padding: 1.3em 3.2em 0.5em;

    }

    .ewm {
        padding: 0 2.6em 0.8em;
        text-align: center;
    }

    .ewm img {
        width: 100%;
    }

    .ewm p {
        font-size: 0.6rem;
        padding: 0 0 1.3em;
    }

    .wechat-list:before {
        background: none;
    }

    .wechat-list:after {
        background: none;
    }

    /** 我的二维码 end **/

Dot布局隐藏

<div id="qrcode_area" style="display: none;"></div>
<script id="qrcode_tmpl" type="text/html/x-dot-template">
    <div class="aui-list aui-media-list wechat-list">
        <div class=" aui-list-item-middle wechat-middle">
            <div class="aui-media-list-item-inner">
                <div class="aui-list-item-media wechat-media">
                    <img src="{{= it.Avatar}}">
                </div>
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-text">
                        <div class="aui-list-item-title">{{= it.DisplayName}}
                            {{? it.Sex == '0'}}
                            <i class="aui-iconfont aui-icon-my" style="color:#898683"></i>
                            {{?? it.Sex == '1'}}
                            <i class="aui-iconfont aui-icon-my" style="color:#1EA362"></i>
                            {{??}}
                            <i class="aui-iconfont aui-icon-my" style="color:#f44336"></i>
                            {{?}}
                        </div>

                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        {{= it.Place}}
                    </div>
                </div>
            </div>
        </div>
        <div class="ewm">
            <img src="{{= it.QrCode}}">
            <p>扫一扫上面的二维码图案,加我好友</p>
        </div>
    </div>
</script>

api异步获取数据

var user = $api.getStorage('user');
    // 获取店铺信息
    api.ajax({
        url: BASE_REQUEST_URL+'/Customer/GetCustomerQrInfo',
        method: 'post',
        data: {
            values: {
                memberId: user.member_id,
                customerId: user.customer_id
            }
        }
    }, function(json, err) {
        if (json.result) {
            var interText = doT.template($("#qrcode_tmpl").text());
            $("#qrcode_area").html(interText(json));
        }
    });

layer获取html

// show二维码
function showQrcode() {
    var html = $('#qrcode_area').html();
    layer.open({
        type: 1,
        title: false,
        shadeClose: true,
        closeBtn: 0,
        shade: 0.6,
        area: ['280px', '55%'],
        content: html
    });
}

1.弹出内容如果是iframe就无法获取异步数据了。api无法使用。
2.通过将内容隐藏来巧妙的处理。
3.获取html,通过layer的内容布局来弹出内容。


本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/6170876.html,如需转载请自行联系原作者

相关文章
|
Kubernetes 负载均衡 安全
【K8S系列】深入解析k8s 网络插件—kube-router
【K8S系列】深入解析k8s 网络插件—kube-router
1927 1
|
监控 前端开发 JavaScript
Sentry 监控部署与使用(详细流程)
Sentry 监控部署与使用(详细流程)
2272 0
|
存储 Kotlin
Kotlin中的内联函数:提升性能与解决Lambda表达式参数问题
Kotlin中的内联函数:提升性能与解决Lambda表达式参数问题
184 1
后端常用接口------注册接口的写法
后端常用接口------注册接口的写法
|
Rust 编译器 Linux
【Rust】——rust前言与安装rust
【Rust】——rust前言与安装rust
【Rust】——rust前言与安装rust
|
Prometheus 监控 Cloud Native
Java 服务挂掉,服务器异常宕机问题排查
Java 服务挂掉,服务器异常宕机问题排查
2293 1
|
存储 监控 前端开发
局域网管理软件的前端设计与实现:HTML/CSS在网络拓扑展示中的应用
本文探讨了局域网管理软件的前端设计,强调了HTML/CSS在网络拓扑展示中的作用。通过HTML/CSS创建设备节点和绘制连线,实现清晰的网络设备连接展示。此外,利用JavaScript定时收集监控数据,并通过HTTP请求自动提交到网站,便于管理员进行数据分析,提升了局域网管理效率。
271 3
|
JavaScript
Vue - You are using the runtime-only build of Vue where the template compiler is
Vue - You are using the runtime-only build of Vue where the template compiler is
287 0
|
应用服务中间件 nginx
Nginx源码阅读:nginx_shmtx共享互斥锁(进程锁)
Nginx源码阅读:nginx_shmtx共享互斥锁(进程锁)
256 0