小程序 自定义置顶功能

261 阅读1分钟

前端自定义

plugin\app\template\web_v3\page\tpl_template_edit.html

<hr/>
<div class="form-group">
    <div class="col-sm-2 control-label">是否固定</div>
    <div class="col-sm-10">
        <label class="radio-inline"><input type="radio" name="posfix" value="1" class="diy-bind" data-bind-child="style" data-bind="posfix" <%if style.posfix=='1'%>checked="checked"<%/if%> > 是</label>
        <label class="radio-inline"><input type="radio" name="posfix" value="0" class="diy-bind" data-bind-child="style" data-bind="posfix" <%if style.posfix=='0'%>checked="checked"<%/if%>> 否</label>
    </div>
</div>

<div class="form-group">
    <div class="col-sm-2 control-label">对象高度</div>
    <div class="col-sm-10">
        <div class="input-group form-group" style="margin: 0;">
            <input class="form-control input-sm diy-bind" data-bind-child="style" data-bind="fixheight" data-placeholder="" placeholder="请输入对象高度" value="<%style.fixheight%>" />
            
        </div>
    </div>
</div>

<div class="form-group">
    <div class="col-sm-2 control-label">距顶高度</div>
    <div class="col-sm-10">
        <div class="input-group form-group" style="margin: 0;">
            <input class="form-control input-sm diy-bind" data-bind-child="style" data-bind="fixtop" data-placeholder="" placeholder="请输入对象高度" value="<%style.fixtop%>" />
            
        </div>
    </div>
</div>

wxml: pages\diy\template\tpl_menu.wxml

    style="background:{{diyitem.style.background}};position: {{diyitem.params.posfix==1?'fixed':'relative'}};width:750rpx;height:{{diyitem.params.fixheight}}rpx;top:{{diyitem.params.fixtop}}rpx;   {{diyitem.params.posfix==1?'z-index:999':''}}"
    
    style="background:{{diyitem.style.background}};position: {{diyitem.style.posfix==1?'fixed':'relative'}};width:750rpx;height:{{diyitem.style.fixheight}}rpx;top:{{diyitem.style.fixtop}}rpx;   {{diyitem.style.posfix==1?'z-index:999':''}}" wx:if="{{diyitem.style.showtype=='0'}}"