popup.js 928 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import message from './message.js';
  2. // 定义 type 类型:弹出类型:top/bottom/center
  3. const config = {
  4. // 顶部弹出
  5. top: 'top',
  6. // 底部弹出
  7. bottom: 'bottom',
  8. // 居中弹出
  9. center: 'center',
  10. // 消息提示
  11. message: 'top',
  12. // 对话框
  13. dialog: 'center',
  14. // 分享
  15. share: 'bottom',
  16. }
  17. export default {
  18. data() {
  19. return {
  20. config: config,
  21. popupWidth: 0,
  22. popupHeight: 0
  23. }
  24. },
  25. mixins: [message],
  26. computed: {
  27. isDesktop() {
  28. return this.popupWidth >= 500 && this.popupHeight >= 500
  29. }
  30. },
  31. mounted() {
  32. const fixSize = () => {
  33. const {
  34. windowWidth,
  35. windowHeight,
  36. windowTop
  37. } = uni.getSystemInfoSync()
  38. this.popupWidth = windowWidth
  39. this.popupHeight = windowHeight + windowTop
  40. }
  41. fixSize()
  42. // #ifdef H5
  43. window.addEventListener('resize', fixSize)
  44. this.$once('hook:beforeDestroy', () => {
  45. window.removeEventListener('resize', fixSize)
  46. })
  47. // #endif
  48. },
  49. }