109 lines
2.1 KiB
JavaScript
109 lines
2.1 KiB
JavaScript
// components/modalView/index.js
|
|
Component({
|
|
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
titleText:{
|
|
type:String,
|
|
value:''
|
|
},
|
|
titleTextCenter:{
|
|
type:Boolean,
|
|
value:true
|
|
},
|
|
editable:{
|
|
type:Boolean,
|
|
value:false
|
|
},
|
|
content:{
|
|
type:String,
|
|
value:''
|
|
},
|
|
contentPlaceholder:{
|
|
type:String,
|
|
value:'请输入内容'
|
|
},
|
|
isShowCancel:{
|
|
type:Boolean,
|
|
value:true
|
|
},
|
|
cancelButtonText:{
|
|
type:String,
|
|
value:'取消'
|
|
},
|
|
okButtonText:{
|
|
type:String,
|
|
value:'确定'
|
|
},
|
|
show:{
|
|
type:Boolean,
|
|
value:false,
|
|
observer(show){
|
|
if(show){
|
|
const windowInfo = wx.getWindowInfo();
|
|
this.createSelectorQuery().select('#modalViewMain').boundingClientRect((res)=>{
|
|
const viewHeight = res.height;
|
|
this.setData({
|
|
dynamicsStyle:`top:${(windowInfo.windowHeight-viewHeight)/2}px;height:${viewHeight}px;`
|
|
})
|
|
}).exec();
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
dynamicsStyle:''
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
cancelButtonTap(){
|
|
wx.showTabBar({
|
|
complete:()=>{
|
|
this.setData({
|
|
show:false
|
|
});
|
|
this.triggerEvent('cancel');
|
|
}
|
|
})
|
|
},
|
|
okButtonTap(){
|
|
wx.showTabBar({
|
|
complete:()=>{
|
|
this.setData({
|
|
show:false
|
|
});
|
|
this.triggerEvent('ok');
|
|
}
|
|
});
|
|
},
|
|
enterPageContainer(){
|
|
wx.hideTabBar();
|
|
},
|
|
leavePageContainer(){
|
|
wx.showTabBar();
|
|
}
|
|
},
|
|
|
|
lifetimes:{
|
|
// attached(){
|
|
// console.log(this);
|
|
// const windowInfo = wx.getWindowInfo();
|
|
// this.createSelectorQuery().select('#modalViewMain').boundingClientRect((res)=>{
|
|
// const viewHeight = res.height;
|
|
// console.log(res);
|
|
// this.setData({
|
|
// dynamicsStyle:`top:${(windowInfo.screenHeight-viewHeight)/2}px;height:${viewHeight}px;`
|
|
// })
|
|
// }).exec();
|
|
// }
|
|
}
|
|
}) |