t-i-notice.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="content">
  3. <view class="box">
  4. <!-- 文字滚动 -->
  5. <uni-notice-bar scrollable="true" :speed="30" background-color="#ffffff00" color="#fff" single="true"
  6. :text="text_time">
  7. </uni-notice-bar>
  8. <!-- 文字滚动 -->
  9. <uni-notice-bar scrollable="true" :speed="20" background-color="#ffffff00" color="#fff" single="true"
  10. :text="text"></uni-notice-bar>
  11. <!-- <view class="more" @click="go_duty_information()">
  12. <uni-icons type="more-filled" color="#fff"></uni-icons>
  13. </view> -->
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import {
  19. sloarToLunar,
  20. getYearMonthDay
  21. } from "../../components/Toling-DateSelect/computedLunarDate.js";
  22. // 返回指定日期距今多少天
  23. const daysComputed = time => {
  24. let oldTimeFormat = new Date(time)
  25. let nowDate = new Date()
  26. if (nowDate.getTime() - oldTimeFormat.getTime() > 0) {
  27. let times = nowDate.getTime() - oldTimeFormat.getTime()
  28. let days = parseInt(times / (60 * 60 * 24 * 1000))
  29. return days
  30. } else {
  31. throw ('传入时间不能大于当前日期')
  32. }
  33. }
  34. // console.log(daysComputed('2006-04-28'))
  35. // 返回指定日期前/后多少天的日期
  36. function getNextDate(date, day) {
  37. var dd = new Date(date);
  38. dd.setDate(dd.getDate() + day);
  39. var y = dd.getFullYear();
  40. var m = dd.getMonth() + 1 < 10 ? "0" + (dd.getMonth() + 1) : dd.getMonth() + 1;
  41. var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();
  42. return y + "-" + m + "-" + d;
  43. };
  44. // getNextDate("2018-09-27",10)
  45. export default {
  46. name: "t-i-notice",
  47. props: [
  48. "text",
  49. "mine_code"
  50. ],
  51. data() {
  52. return {
  53. text_time: "",
  54. year: 0,
  55. month: 0,
  56. today: 0,
  57. lunarStr2: "",
  58. days: 0
  59. };
  60. },
  61. created() {
  62. this.year = new Date().getFullYear();
  63. this.month = new Date().getMonth() + 1;
  64. this.today = new Date().getDate();
  65. this.lunarStr2 = " 农历: " + sloarToLunar(this.year, this.month.toString().padStart(2, '0'), this.today)
  66. .lunarStr2
  67. // console.log(sloarToLunar(this.year, this.month.toString().padStart(2, '0'), this.today))
  68. // console.log(getNextDate("2022-01-04",-5730))
  69. this.days = daysComputed('2006-04-28')
  70. // console.log(daysComputed('2006-04-28'))
  71. this.getCurrentDate()
  72. },
  73. methods: {
  74. getCurrentDate() {
  75. var myDate = new Date();
  76. var year = myDate.getFullYear(); //年
  77. var month = myDate.getMonth() + 1; //月
  78. var day = myDate.getDate(); //日
  79. var days = myDate.getDay();
  80. switch (days) {
  81. case 1:
  82. days = '星期一';
  83. break;
  84. case 2:
  85. days = '星期二';
  86. break;
  87. case 3:
  88. days = '星期三';
  89. break;
  90. case 4:
  91. days = '星期四';
  92. break;
  93. case 5:
  94. days = '星期五';
  95. break;
  96. case 6:
  97. days = '星期六';
  98. break;
  99. case 0:
  100. days = '星期日';
  101. break;
  102. }
  103. var str = "今日 " + " " + year + "年" + month + "月" + day + "日  " + days;
  104. if (uni.getStorageSync('mine_code') == 'zaoquan') {
  105. this.text_time = str + " " + this.lunarStr2 + " 累计安全生产 " + this.days + " 天"
  106. } else {
  107. this.text_time = str + " " + this.lunarStr2
  108. }
  109. },
  110. go_duty_information(){
  111. uni.navigateTo({
  112. url:"../../workbench/duty_information/duty_information"
  113. })
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss">
  119. .content {
  120. width: 750rpx;
  121. height: 244rpx;
  122. background-image: url(./icon/bg_img.jpg);
  123. background-size: 750rpx 334rpx;
  124. background-repeat: no-repeat;
  125. background-position: bottom;
  126. box-sizing: border-box;
  127. padding-top: 20rpx;
  128. }
  129. .box {
  130. margin: 0 auto;
  131. width: 700rpx;
  132. // height: 200rpx;
  133. background-color: rgba(255, 255, 255, .4);
  134. border-radius: 20rpx;
  135. box-sizing: border-box;
  136. padding: 0 20rpx;
  137. position: relative;
  138. /deep/.uni-noticebar {
  139. margin-bottom: 0;
  140. }
  141. /deep/.uni-noticebar:nth-child(2) {
  142. padding-top: 0;
  143. }
  144. .more{
  145. transform: rotate(90deg);
  146. position: absolute;
  147. top: 42rpx;
  148. right: 5rpx;
  149. }
  150. }
  151. </style>