graceSpeaker.nvue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template name="graceSpeaker">
  2. <view class="grace-swiper-msg">
  3. <view class="grace-swiper-msg-icon"><slot></slot></view>
  4. <swiper :vertical="vertical" autoplay="true" circular="true" @change="change"
  5. :interval="interval" class="grace-swiper-msg-swiper" :style="{height:height}">
  6. <swiper-item v-for="(item, index) in msgs" :key="index" class="grace-swiper-msg-swiper-item" :style="{height:height}">
  7. <text @tap="navto"
  8. :data-url="item.url" :data-opentype="item.opentype" class="grace-swiper-msg-text"
  9. :style="{fontSize:fontSize, color:fontColor, height:height, lineHeight:height, fontWeight:fontWeight}">{{item.title}}</text>
  10. </swiper-item>
  11. </swiper>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. name: "graceSpeaker",
  17. props: {
  18. msgs : {
  19. type : Array,
  20. default : function(){return [];}
  21. },
  22. interval : {
  23. type : Number,
  24. default: 5000
  25. },
  26. vertical : {
  27. type : Boolean,
  28. default : true
  29. },
  30. fontSize : {
  31. type : String,
  32. default : "26rpx"
  33. },
  34. fontColor : {
  35. type : String,
  36. default : "#333333"
  37. },
  38. fontWeight : {
  39. type : String,
  40. default : ""
  41. },
  42. height:{
  43. type : String,
  44. default : "60rpx"
  45. },
  46. fontWeight : {
  47. type : String,
  48. default : ""
  49. }
  50. },
  51. methods:{
  52. navto : function (e) {
  53. var url = e.currentTarget.dataset.url;
  54. var type = e.currentTarget.dataset.opentype;
  55. switch (type){
  56. case 'switchTab':
  57. uni.switchTab({
  58. url:url
  59. });
  60. break;
  61. case 'navigate':
  62. uni.navigateTo({
  63. url:url
  64. });
  65. break;
  66. case 'redirect':
  67. uni.redirectTo({
  68. url:url
  69. });
  70. break;
  71. default:
  72. break;
  73. }
  74. },
  75. change:function (index) {
  76. this.$emit('change', index.detail.current);
  77. }
  78. }
  79. }
  80. </script>
  81. <style scoped>
  82. .grace-swiper-msg{flex-wrap:nowrap; flex-direction:row; align-items:center;}
  83. .grace-swiper-msg-icon{margin-right:16rpx;}
  84. .grace-swiper-msg-swiper{width:750rpx; flex:1; height:60rpx; overflow:hidden;}
  85. .grace-swiper-msg-swiper-item{line-height:60rpx; height:60rpx; overflow:hidden;}
  86. .grace-swiper-msg-text{line-height:60rpx; height:60rpx; overflow:hidden; font-size:28rpx;}
  87. </style>