Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
226 changes: 113 additions & 113 deletions dist/action-sheet/index.js
Original file line number Diff line number Diff line change
@@ -1,125 +1,125 @@
Component({
externalClasses: ['l-class-title', 'l-class-item', 'l-class-cancel'],
properties: {
locked: Boolean,
showCancel: Boolean,
show: Boolean,
itemList: Array,
cancelText: {
type: String,
value: '取消'
},
title: String,
openApi: {
type: Boolean,
value: true,
}
},
data: {
success: '',
fail: '',
isIphoneX: false
},
attached() {
if (this.data.openApi) {
this.initActionSheet();
}
this.initUIAdapter();
externalClasses: ['l-class-title', 'l-class-item', 'l-class-cancel'],
properties: {
locked: Boolean,
showCancel: Boolean,
show: Boolean,
itemList: Array,
cancelText: {
type: String,
value: '取消'
},
title: String,
openApi: {
type: Boolean,
value: true,
}
},
data: {
success: '',
fail: '',
isIphoneX: false
},
attached() {
if (this.data.openApi) {
this.initActionSheet();
}
this.initUIAdapter();
},

lifetimes: {
show() {
if (this.data.openApi) {
this.initActionSheet();
}
lifetimes: {
show() {
if (this.data.openApi) {
this.initActionSheet();
}

},
},
methods: {
/**
},
methods: {
/**
* 区分UI尺寸
*/
initUIAdapter() {
wx.getSystemInfo({
success: (res) => {
this.setData({
isIphoneX: res.model == "iPhone X" ? true : false,
})
}
})
},
initActionSheet() {
const config = {
itemList: [],
success: null,
fail: null,
title: '',
locked: true,
cancelText: '取消',
showCancel: false
}
wx.lin = wx.lin || {};
wx.lin.showActionSheet = (options={}) => {
const {
itemList = config.itemList,
success = config.success,
fail = config.fail,
title = config.title,
locked = config.locked,
cancelText = config.cancelText,
showCancel = config.showCancel,
} = options;
this.setData({
itemList: itemList.slice(0, 10),
success,
fail,
title,
locked,
cancelText,
showCancel,
show: true,
});
return this;
};
},
handleClickItem(e) {
const {
success
} = this.data;
success && success({ ...e.currentTarget.dataset });
this.triggerEvent('linitemtap', { ...e.currentTarget.dataset });
this._hideActionSheet();
},
initUIAdapter() {
wx.getSystemInfo({
success: (res) => {
this.setData({
isIphoneX: res.model == 'iPhone X' ? true : false,
});
}
});
},
initActionSheet() {
const config = {
itemList: [],
success: null,
fail: null,
title: '',
locked: true,
cancelText: '取消',
showCancel: false
};
wx.lin = wx.lin || {};
wx.lin.showActionSheet = (options={}) => {
const {
itemList = config.itemList,
success = config.success,
fail = config.fail,
title = config.title,
locked = config.locked,
cancelText = config.cancelText,
showCancel = config.showCancel,
} = options;
this.setData({
itemList: itemList.slice(0, 10),
success,
fail,
title,
locked,
cancelText,
showCancel,
show: true,
});
return this;
};
},
handleClickItem(e) {
const {
success
} = this.data;
success && success({ ...e.currentTarget.dataset });
this.triggerEvent('linitemtap', { ...e.currentTarget.dataset });
this._hideActionSheet();
},

_showActionSheet() {
this.setData({
show: true
})
},
_showActionSheet() {
this.setData({
show: true
});
},

_hideActionSheet() {
this.setData({
show: false
})
},
_hideActionSheet() {
this.setData({
show: false
});
},

handleClickCancel() {
const {
fail
} = this.data;
fail && fail({
errMsg: 'showactionsheet:fail cancel'
});
this.triggerEvent('lincancel', {
errMsg: 'showactionsheet:fail cancel'
})
this._hideActionSheet();
},
handleClickCancel() {
const {
fail
} = this.data;
fail && fail({
errMsg: 'showactionsheet:fail cancel'
});
this.triggerEvent('lincancel', {
errMsg: 'showactionsheet:fail cancel'
});
this._hideActionSheet();
},

handleClickPopUp() {
if (!this.data.locked) {
this.handleClickCancel();
}
},
}
handleClickPopUp() {
if (!this.data.locked) {
this.handleClickCancel();
}
},
}
});
Loading