酷炫直播运营系统小程序版本

mpwxs.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. let mpMixins = {}
  2. // #ifdef APP-VUE|| MP-WEIXIN || H5
  3. import {
  4. isPC
  5. } from "./isPC"
  6. mpMixins = {
  7. data() {
  8. return {
  9. is_show: 'none'
  10. }
  11. },
  12. watch: {
  13. show(newVal) {
  14. this.is_show = this.show
  15. }
  16. },
  17. created() {
  18. this.swipeaction = this.getSwipeAction()
  19. if (this.swipeaction.children !== undefined) {
  20. this.swipeaction.children.push(this)
  21. }
  22. },
  23. mounted() {
  24. this.is_show = this.show
  25. },
  26. methods: {
  27. // wxs 中调用
  28. closeSwipe(e) {
  29. if (!this.autoClose) return
  30. this.swipeaction.closeOther(this)
  31. },
  32. change(e) {
  33. this.$emit('change', e.open)
  34. if (this.is_show !== e.open) {
  35. this.is_show = e.open
  36. }
  37. },
  38. appTouchStart(e) {
  39. // #ifdef H5
  40. if (isPC()) return
  41. // #endif
  42. const {
  43. clientX
  44. } = e.changedTouches[0]
  45. this.clientX = clientX
  46. this.timestamp = new Date().getTime()
  47. },
  48. appTouchEnd(e, index, item, position) {
  49. // #ifdef H5
  50. if (isPC()) return
  51. // #endif
  52. const {
  53. clientX
  54. } = e.changedTouches[0]
  55. // fixed by xxxx 模拟点击事件,解决 ios 13 点击区域错位的问题
  56. let diff = Math.abs(this.clientX - clientX)
  57. let time = (new Date().getTime()) - this.timestamp
  58. if (diff < 40 && time < 300) {
  59. this.$emit('click', {
  60. content: item,
  61. index,
  62. position
  63. })
  64. }
  65. },
  66. onClickForPC(index, item, position) {
  67. // #ifdef H5
  68. if (!isPC()) return
  69. this.$emit('click', {
  70. content: item,
  71. index,
  72. position
  73. })
  74. // #endif
  75. }
  76. }
  77. }
  78. // #endif
  79. export default mpMixins