t-i-notice.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <view class="content">
  3. <view class="box">
  4. <!-- 文字滚动 -->
  5. <uni-notice-bar :speed="50" background-color="#ffffff00" color="#fff" single="true"
  6. :text="text_time"></uni-notice-bar>
  7. <!-- 文字滚动 -->
  8. <uni-notice-bar scrollable="true" :speed="20" background-color="#ffffff00" color="#fff" single="true"
  9. :text="text"></uni-notice-bar>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: "t-i-notice",
  16. props: [
  17. "text"
  18. ],
  19. data() {
  20. return {
  21. text_time:"",
  22. };
  23. },
  24. created() {
  25. this.getCurrentDate()
  26. },
  27. methods: {
  28. getCurrentDate() {
  29. var myDate = new Date();
  30. var year = myDate.getFullYear(); //年
  31. var month = myDate.getMonth() + 1; //月
  32. var day = myDate.getDate(); //日
  33. var days = myDate.getDay();
  34. switch (days) {
  35. case 1:
  36. days = '星期一';
  37. break;
  38. case 2:
  39. days = '星期二';
  40. break;
  41. case 3:
  42. days = '星期三';
  43. break;
  44. case 4:
  45. days = '星期四';
  46. break;
  47. case 5:
  48. days = '星期五';
  49. break;
  50. case 6:
  51. days = '星期六';
  52. break;
  53. case 0:
  54. days = '星期日';
  55. break;
  56. }
  57. var str = "今日 " + " " + year + "年" + month + "月" + day + "日  " + days;
  58. this.text_time = str
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss">
  64. .content {
  65. width: 750rpx;
  66. height: 244rpx;
  67. background-image: url(./icon/bg_img.jpg);
  68. background-size: 750rpx 334rpx;
  69. background-repeat: no-repeat;
  70. background-position: bottom;
  71. box-sizing: border-box;
  72. padding-top: 20rpx;
  73. }
  74. .box {
  75. margin: 0 auto;
  76. width: 700rpx;
  77. // height: 200rpx;
  78. background-color: rgba(255, 255, 255, .4);
  79. border-radius: 20rpx;
  80. box-sizing: border-box;
  81. padding: 0 20rpx;
  82. /deep/.uni-noticebar {
  83. margin-bottom: 0;
  84. }
  85. }
  86. </style>