欧美三级国产三级日韩三级_亚洲熟妇丰满大屁股熟妇_欧美亚洲成人一区二区三区_国产精品久久久久久模特

微信小程序 - dialog - 新聞資訊 - 云南小程序開發(fā)|云南軟件開發(fā)|云南網(wǎng)站建設(shè)-昆明葵宇信息科技有限公司

159-8711-8523

云南網(wǎng)建設(shè)/小程序開發(fā)/軟件開發(fā)

知識(shí)

不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價(jià)值,我們在追求其視覺表現(xiàn)的同時(shí),更側(cè)重于功能的便捷,營銷的便利,運(yùn)營的高效,讓網(wǎng)站成為營銷工具,讓軟件能切實(shí)提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序?yàn)楹笃谏?jí)提供便捷的支持!

您當(dāng)前位置>首頁 » 新聞資訊 » 小程序相關(guān) >

微信小程序 - dialog

發(fā)表時(shí)間:2021-3-31

發(fā)布人:葵宇科技

瀏覽次數(shù):60

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

可作為component 使用

直接上代碼

復(fù)制代碼
//遮罩的代碼
<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>
復(fù)制代碼
復(fù)制代碼
/**顯示或隱藏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
    });
  }
}
復(fù)制代碼
復(fù)制代碼
/**截?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;
}
復(fù)制代碼

 

相關(guān)案例查看更多