graceSpeaker.nvue 2.1 KB

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