综合办公系统
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

uv-notice-bar.vue 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view
  3. class="uv-notice-bar"
  4. v-if="show"
  5. :style="[{
  6. backgroundColor: bgColor
  7. }, $uv.addStyle(customStyle)]"
  8. >
  9. <template v-if="direction === 'column' || (direction === 'row' && step)">
  10. <uv-column-notice
  11. :color="color"
  12. :bgColor="bgColor"
  13. :text="text"
  14. :mode="mode"
  15. :step="step"
  16. :icon="icon"
  17. :disable-touch="disableTouch"
  18. :disable-scroll="disableScroll"
  19. :fontSize="fontSize"
  20. :duration="duration"
  21. @close="close"
  22. @click="click"
  23. @change="change"
  24. ></uv-column-notice>
  25. </template>
  26. <template v-else>
  27. <uv-row-notice
  28. :color="color"
  29. :bgColor="bgColor"
  30. :text="text"
  31. :mode="mode"
  32. :fontSize="fontSize"
  33. :speed="speed"
  34. :url="url"
  35. :linkType="linkType"
  36. :icon="icon"
  37. @close="close"
  38. @click="click"
  39. ></uv-row-notice>
  40. </template>
  41. </view>
  42. </template>
  43. <script>
  44. import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'
  45. import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'
  46. import props from './props.js';
  47. /**
  48. * noticeBar 滚动通知
  49. * @description 该组件用于滚动通告场景,有多种模式可供选择
  50. * @tutorial https://www.uvui.cn/components/noticeBar.html
  51. * @property {Array | String} text 显示的内容,数组
  52. * @property {String} direction 通告滚动模式,row-横向滚动,column-竖向滚动 ( 默认 'row' )
  53. * @property {Boolean} step direction = row时,是否使用步进形式滚动 ( 默认 false )
  54. * @property {String} icon 是否显示左侧的音量图标 ( 默认 'volume' )
  55. * @property {String} mode 通告模式,link-显示右箭头,closable-显示右侧关闭图标
  56. * @property {String} color 文字颜色,各图标也会使用文字颜色 ( 默认 '#f9ae3d' )
  57. * @property {String} bgColor 背景颜色 ( 默认 '#fdf6ec' )
  58. * @property {String | Number} speed 水平滚动时的滚动速度,即每秒滚动多少px(px),这有利于控制文字无论多少时,都能有一个恒定的速度 ( 默认 80 )
  59. * @property {String | Number} fontSize 字体大小 ( 默认 14 )
  60. * @property {String | Number} duration 滚动一个周期的时间长,单位ms ( 默认 2000 )
  61. * @property {Boolean} disableTouch 是否禁止用手滑动切换 目前HX2.6.11,只支持App 2.5.5+、H5 2.5.5+、支付宝小程序、字节跳动小程序(默认34) ( 默认 true )
  62. * @property {String} url 跳转的页面路径
  63. * @property {String} linkType 页面跳转的类型 ( 默认 navigateTo )
  64. * @property {Object} customStyle 定义需要用到的外部样式
  65. *
  66. * @event {Function} click 点击通告文字触发
  67. * @event {Function} close 点击右侧关闭图标触发
  68. * @example <uv-notice-bar :more-icon="true" :list="list"></uv-notice-bar>
  69. */
  70. export default {
  71. name: "uv-notice-bar",
  72. emits: ['click','close','change'],
  73. mixins: [mpMixin, mixin, props],
  74. data() {
  75. return {
  76. show: true
  77. }
  78. },
  79. methods: {
  80. // 点击通告栏
  81. click(index) {
  82. this.$emit('click', index)
  83. if (this.url && this.linkType) {
  84. // 此方法写在mixin中,另外跳转的url和linkType参数也在mixin的props中
  85. this.openPage()
  86. }
  87. },
  88. // 点击关闭按钮
  89. close() {
  90. this.show = false
  91. this.$emit('close')
  92. },
  93. // 竖向滚动时触发
  94. change(index){
  95. this.$emit('change',index)
  96. }
  97. }
  98. };
  99. </script>
  100. <style lang="scss" scoped>
  101. @import '@/uni_modules/uv-ui-tools/libs/css/components.scss';
  102. .uv-notice-bar {
  103. overflow: hidden;
  104. padding: 9px 12px;
  105. flex: 1;
  106. }
  107. </style>