网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網(wǎng)

微信小程序 - dialog

發(fā)布時(shí)間:2018-04-25 11:13 所屬欄目:小程序開(kāi)發(fā)教程

實(shí)現(xiàn)了 標(biāo)題,內(nèi)容和按鈕設(shè)置,可動(dòng)態(tài)設(shè)置按鈕,以及按鈕點(diǎn)擊事件的回調(diào)

可作為component 使用

直接上代碼

//遮罩的代碼
<viewclass="uiComponent uiComponent_mask uiComponent_mask_{{uiComponent.mask.show &&'active'}}" style="{{uiComponent.mask.style}}" ></view>
 
//dialog的代碼
<view wx:if="{{uiComponent.dialog.show}}" class="uiComponent uiComponent-dialog uiComponent-dialog_{{ uiComponent.dialog.show &&'active' }}" 
style="{{uiComponent.dialog.style}}" 
 >
  <view class='uiComponent-dialog-title txt-nowrap' wx:if="{{ uiComponent.dialog.title }}">{{ uiComponent.dialog.title }}</view>
   <view class='uiComponent-dialog-content' wx:if="{{ uiComponent.dialog.content }}">{{ uiComponent.dialog.content }}</view>
   <view class='uiComponent-dialog-btns' wx:if="{{ uiComponent.dialog.btns.length>0 }}">
      <view bindtap='uiComponent_dialog_btnclick' class='uiComponent-dialog-btn  txt-nowrap' wx:for="{{uiComponent.dialog.btns}}" wx:key="{{index}}" data-index="{{index}}" style="width:{{1/uiComponent.dialog.btns.length*99.99999}}%;{{item.style}}"><view>{{item.text}}</view></view>
   </view>
 </view>
/**顯示或隱藏mask */
UIComponent.mask = function (show=false,style='') {
  var self = this;
  self.setData({
    'uiComponent.mask.show': show,
    'uiComponent.mask.style': style
  });
}



/** dialog
 *  按照界面,這里可排布的大概也就3個(gè)左右
 * btns:[
 *        {
 *          text: "確定",
 *          style: "",
 *          click: function(e, idx, btn){
 * 
 *        }  
 *    }
 * ]
 * 
 * 
 * 調(diào)用例子
  self.dialog({ show: true, title: "111", content: "2222", btns: [
      {
        text: "確定" ,
        click: function (e, idx, btn){
          self.toast(`選中了第${idx}個(gè)按鈕`)
        }
      },
      {
        text: "樣式",
        style:"color:white;background-color:green;"
      } ,
      {
        text: "不能取消",
        click:function(e,idx,btn){

            self.toast("不滿足條件,不能取消")
            return false;
        }
      }
    ]
  })
 * self.dialog({show:false})
 */
UIComponent.dialog = function (opt={}) {
  var self = this;
  let app = getApp();
  opt = app.util.extend({},{
    //默認(rèn)有遮罩
    mask:true,
    show:false ,
    //按鈕組
    btns:[

    ],
    title:"",
    content:""
  },opt);
 
  if (opt.mask){ 
        self.mask(opt.show) 
  }
  if(opt.show){
    if (!opt.btns || opt.btns.length==0){
      opt.btns=[
        {
          text:"確定"
        }
      ];
    }
  }
  self.setData({
    'uiComponent.dialog.show': opt.show,
    'uiComponent.dialog.style': opt.style,
    'uiComponent.dialog.btns': opt.btns,
    'uiComponent.dialog.title': opt.title,
    'uiComponent.dialog.content': opt.content
  });
  
}
/**
 * 所有的按鈕touch事件都關(guān)注到這里
 */
UIComponent.uiComponent_dialog_btnclick=function(e){
  var self = this;
  var index = e.currentTarget.dataset.index;
  var btns = self.data.uiComponent.dialog.btns;
  var btn = btns[index];
  var func = btn.click;
  if (typeof func=="function"){
    var ret= func.apply(self, [e, index, btn]);
    if(ret!==false){ //click事件可返false禁止關(guān)閉dialog
      self.dialog({
        show: false
      });
    }
  }else{
    self.dialog({
      show:false
    });
  }
}
/**截?cái)酁?行文字,超出...*/

.txt-nowrap {
  text-overflow: -o-ellipsis-lastline;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
/* 遮罩層 */
.uiComponent_mask{
    height:0;width:0;transform:translateZ(0) translateY(-1);
    transition: all .1s ;  
}
.uiComponent_mask_active{
    height:100vh;width:100%;display:block;position:fixed;top:0;left:0;z-index:99;
    background-color: rgba(0,0,0,.6);transform:translateZ(0) translateY(0); transition: all .01s ;  
}



/** dialog */
.uiComponent-dialog{
  display:none;
}
.uiComponent-dialog_active{
  display:block;background-color: white;border-radius:8rpx;
  width:70%;position:fixed;top:30%;left:15%;min-height:50px;
}
.uiComponent-dialog-title{
  text-align: center;font-size: 14px;color:#808080;
  padding:10px 5rpx 0 5rpx;

}
.uiComponent-dialog-content{
  text-align: center;font-size: 16px;color:#202020;
  padding:10px 5rpx;

}
.uiComponent-dialog-btns{
  display:flex;align-items: center;text-align: center;justify-content: space-around;border-top: 1px solid #ccc;
}
.uiComponent-dialog-btn:first-child{
   border-left: 0;
}
.uiComponent-dialog-btn{
   font-size: 14px;padding:10rpx 0; border-left: 1px solid #ccc;


易優(yōu)小程序(企業(yè)版)+靈活api+前后代碼開(kāi)源 碼云倉(cāng)庫(kù):starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/24077.html 復(fù)制鏈接 如需定制請(qǐng)聯(lián)系易優(yōu)客服咨詢:800182392 點(diǎn)擊咨詢
QQ在線咨詢
AI智能客服 ×