modal.js 594 B

123456789101112131415161718192021222324252627282930313233343536
  1. const typeConst = {
  2. 'wx':1
  3. };
  4. export default {
  5. const:typeConst,
  6. confirm:function (data,type=typeConst.wx) {
  7. if (typeof data !== 'object') data={title};
  8. if (data.confirmColor === undefined) {
  9. data.confirmColor = '#8DD4BD';
  10. }
  11. if (data.cancelColor === undefined) {
  12. data.cancelColor = '#999';
  13. }
  14. data.success = function (res) {
  15. if (res.confirm) {
  16. this.confirm && this.confirm();
  17. } else {
  18. this.cancel && this.cancel();
  19. }
  20. }.bind(data);
  21. return this[type] && this[type](data);
  22. },
  23. [typeConst.wx]:function (data) {
  24. return uni.showModal(data);
  25. },
  26. }