cxTable.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <view class="content">
  3. <image src="https://taohaoliang.oss-cn-beijing.aliyuncs.com/chaoxi.png" mode="" style="width: 100vw;height: 100vh;"></image>
  4. <view class="table">
  5. <view class="row" v-for="(item,index) in tableList" :class="item.check?'row-active':''">
  6. <image src="../static/image/today.png" mode="widthFix" v-if="item.check" style="width: 34rpx;position: absolute;left: 5px;height: auto;"></image>
  7. <view class="col1 color">
  8. {{item.name}}
  9. </view>
  10. <view class="col2 col">
  11. {{item.val1}}
  12. </view>
  13. <view class="col3 col">
  14. {{item.val2}}
  15. </view>
  16. <view class="col4 col">
  17. {{item.val3}}
  18. </view>
  19. <view class="col5 col">
  20. {{item.val4}}
  21. </view>
  22. </view>
  23. <view class="bottom">
  24. <view class="title">
  25. 热门赶海地点推荐:
  26. </view>
  27. <view class="text">
  28. 白沙湾黄金海岸、仙人岛海域、金沙滩、望海寨龟石滩、山海广场
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. isShowStyle:false,
  39. tableList: [{
  40. name: '日期/时间',
  41. val1: '涨潮',
  42. val2: '落潮',
  43. val3: '涨潮',
  44. val4: '落潮',
  45. check:false,
  46. },
  47. {
  48. name: '初一/十六',
  49. val1: '5:44',
  50. val2: '11:44',
  51. val3: '17:44',
  52. val4: '23:44',
  53. check:false,
  54. }, {
  55. name: '初二/十七',
  56. val1: '6:32',
  57. val2: '12:32',
  58. val3: '18:32',
  59. val4: '24:32',
  60. check:false,
  61. }, {
  62. name: '初三/十八',
  63. val1: '7:20',
  64. val2: '12:20',
  65. val3: '19:20',
  66. val4: '1:20',
  67. check:false,
  68. }, {
  69. name: '初四/十九',
  70. val1: '8:08',
  71. val2: '14:08',
  72. val3: '20:08',
  73. val4: '2:08',
  74. check:false,
  75. }, {
  76. name: '初五/二十',
  77. val1: '8:56',
  78. val2: '14:56',
  79. val3: '20:56',
  80. val4: '2:56',
  81. check:false,
  82. }, {
  83. name: '初六/廿一',
  84. val1: '9:44',
  85. val2: '15:44',
  86. val3: '21:44',
  87. val4: '3:44',
  88. check:false,
  89. }, {
  90. name: '初七/廿二',
  91. val1: '10:32',
  92. val2: '16:32',
  93. val3: '22:32',
  94. val4: '4:32',
  95. check:false,
  96. }, {
  97. name: '初八/廿三',
  98. val1: '11:20',
  99. val2: '17:20',
  100. val3: '23:20',
  101. val4: '5:20',
  102. check:false,
  103. }, {
  104. name: '初九/廿四',
  105. val1: '12:08',
  106. val2: '18:08',
  107. val3: '0:08',
  108. val4: '6:08',
  109. check:false,
  110. }, {
  111. name: '初十/廿五',
  112. val1: '12:56',
  113. val2: '18:56',
  114. val3: '0:56',
  115. val4: '6:56',
  116. check:false,
  117. }, {
  118. name: '十一/廿六',
  119. val1: '13:44',
  120. val2: '19:44',
  121. val3: '1:44',
  122. val4: '7:44',
  123. check:false,
  124. }, {
  125. name: '十二/廿七',
  126. val1: '14:32',
  127. val2: '20:32',
  128. val3: '2:32',
  129. val4: '8:32',
  130. check:false,
  131. }, {
  132. name: '十三/廿八',
  133. val1: '15:20',
  134. val2: '21:20',
  135. val3: '3:20',
  136. val4: '9:20',
  137. check:false,
  138. }, {
  139. name: '十四/廿九',
  140. val1: '16:08',
  141. val2: '22:08',
  142. val3: '4:08',
  143. val4: '10:08',
  144. check:false,
  145. }, {
  146. name: '十五/三十',
  147. val1: '17:56',
  148. val2: '23:56',
  149. val3: '5:56',
  150. val4: '10:56',
  151. check:false,
  152. }
  153. ],
  154. day:''
  155. }
  156. },
  157. onLoad() {
  158. this.getLunar()
  159. },
  160. methods: {
  161. setRowColor(){debugger
  162. for(let i = 0;i<this.tableList.length;i++){
  163. this.tableList[i].check=false
  164. let _array = this.tableList[i].name.split("/")
  165. if(this.day==_array[0]||this.day==_array[1]){
  166. this.tableList[i].check = true
  167. }
  168. }
  169. },
  170. getLunar(){
  171. let that = this
  172. var nyear;
  173. var nmonth;
  174. var nday = -1;
  175. var nwday;
  176. var nhrs;
  177. var nmin;
  178. var nsec;
  179. var lmonth, lday, lleap; //农历参数
  180. function Draw() {
  181. NewTick();
  182. //显示时间
  183. var s = nyear + '年' + nmonth + '月' + nday + '日 ' + '星期' + cweekday(nwday) + ' ' + shapetime(nhrs, nmin, nsec);
  184. s += " 农历" + lmonth + "月" + lday; //农历
  185. that.day= lday;
  186. //需要展示在页面地方
  187. console.log("农历日期---",that.day);
  188. that.setRowColor()
  189. }
  190. function NewTick() {
  191. let noww = new Date();
  192. if (noww.getDate() != nday) {
  193. nyear = noww.getFullYear();
  194. nmonth = noww.getMonth() + 1;
  195. nwday = noww.getDay();
  196. nday = noww.getDate();
  197. getlunar(); //获取农历
  198. }
  199. nhrs = noww.getHours();
  200. nmin = noww.getMinutes();
  201. nsec = noww.getSeconds();
  202. }
  203. //辅助函数
  204. var hzWeek = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日");
  205. function cweekday(wday) {
  206. console.log('星期---',hzWeek[wday]);
  207. }
  208. function shapetime(vhrs, vmin, vsec) {
  209. if (vsec <= 9) vsec = "0" + vsec;
  210. if (vmin <= 9) vmin = "0" + vmin;
  211. if (vhrs <= 9) vhrs = "0" + vhrs;
  212. // return vhrs + ":" + vmin + ":" + vsec
  213. console.log("时间日期---",vhrs + ":" + vmin + ":" + vsec);
  214. }
  215. //阴历函数开始
  216. var lunarInfo = new Array(0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, 0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, 0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, 0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950, 0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, 0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5b0, 0x14573, 0x052b0, 0x0a9a8, 0x0e950, 0x06aa0, 0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0, 0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b6a0, 0x195a6, 0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, 0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x05ac0, 0x0ab60, 0x096d5, 0x092e0, //1990
  217. 0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, 0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, 0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, 0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, 0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0, 0x14b63);
  218. function lYearDays(y) {
  219. var i, sum = 348;
  220. for (i = 0x8000; i > 0x8; i >>= 1) sum += (lunarInfo[y - 1900] & i) ? 1 : 0;
  221. return (sum + leapDays(y));
  222. }
  223. function leapDays(y) {
  224. if (leapMonth(y)) return ((lunarInfo[y - 1900] & 0x10000) ? 30 : 29);
  225. else return (0);
  226. }
  227. function leapMonth(y) {
  228. return (lunarInfo[y - 1900] & 0xf);
  229. }
  230. function monthDays(y, m) {
  231. return ((lunarInfo[y - 1900] & (0x10000 >> m)) ? 30 : 29);
  232. }
  233. function Lunar(y, m, d) {
  234. var i, leap = 0,
  235. temp = 0;
  236. var offset = (Date.UTC(y, m, d) - Date.UTC(1900, 0, 31)) / 86400000;
  237. for (i = 1900; i < 2050 && offset > 0; i++) {
  238. temp = lYearDays(i);
  239. offset -= temp;
  240. }
  241. if (offset < 0) {
  242. offset += temp;
  243. i--;
  244. }
  245. this.year = i;
  246. leap = leapMonth(i);
  247. this.isLeap = false;
  248. for (i = 1; i < 13 && offset > 0; i++) {
  249. if (leap > 0 && i == (leap + 1) && this.isLeap == false) {--i;
  250. this.isLeap = true;
  251. temp = leapDays(this.year);
  252. } else {
  253. temp = monthDays(this.year, i);
  254. }
  255. if (this.isLeap == true && i == (leap + 1)) this.isLeap = false;
  256. offset -= temp;
  257. }
  258. if (offset == 0 && leap > 0 && i == leap + 1) if (this.isLeap) {
  259. this.isLeap = false;
  260. } else {
  261. this.isLeap = true; --i;
  262. }
  263. if (offset < 0) {
  264. offset += temp; --i;
  265. }
  266. this.month = i;
  267. this.day = offset + 1;
  268. }
  269. var nStr1 = new Array('', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二');
  270. var nStr2 = new Array('初', '十', '廿', '卅', '□');
  271. function GetcDay(d) {
  272. var s;
  273. switch (d) {
  274. case 10:
  275. s = '初十';
  276. break;
  277. case 20:
  278. s = '二十';
  279. break;
  280. case 30:
  281. s = '三十';
  282. break;
  283. default:
  284. s = nStr2[Math.floor(d / 10)];
  285. s += nStr1[d % 10];
  286. break;
  287. }
  288. return (s);
  289. }
  290. function GetcMon(m) {
  291. if (m == 1) return '正';
  292. else return nStr1[m];
  293. }
  294. function getlunar() {
  295. var lObj = new Lunar(nyear, nmonth - 1, nday);
  296. lmonth = GetcMon(lObj.month);
  297. lday = GetcDay(lObj.day);
  298. lleap = lObj.isLeap;
  299. if (lleap == 1) {
  300. lmonth = "闰" + lmonth;
  301. }
  302. }
  303. //阴历函数结束
  304. Draw();
  305. },
  306. }
  307. }
  308. </script>
  309. <style scoped lang="scss">
  310. .content {
  311. position: relative;
  312. overflow: hidden;
  313. height: 100vh;
  314. .table {
  315. position: absolute;
  316. top: 200rpx;
  317. padding: 20rpx 0;
  318. width: 90%;
  319. right: 0;
  320. left: 0;
  321. margin: auto;
  322. .row {
  323. display: flex;
  324. justify-content: space-around;
  325. align-items: center;
  326. .col1 {
  327. width: 40%;
  328. display: flex;
  329. justify-content: center;
  330. }
  331. .col{
  332. width: 20%;
  333. display: flex;
  334. justify-content: center;
  335. }
  336. }
  337. .row:nth-of-type(2n){
  338. background: rgba(255, 255, 255, 0.6);
  339. padding: 8rpx 0;
  340. }
  341. .row:nth-of-type(2n+1){
  342. background: rgba(214, 214, 214, 0.7);
  343. padding: 8rpx 0;
  344. }
  345. .row:nth-of-type(1){
  346. padding: 16rpx 0;
  347. font-weight: bold;
  348. }
  349. }
  350. .row-active{
  351. background: #92b8f1!important;
  352. }
  353. .bottom{
  354. margin-top: 50rpx;
  355. background: rgba(255, 255, 255, 0.7);
  356. padding: 20rpx;
  357. box-shadow: 2px 3px 3px 1px rgba(187, 187, 187, 0.4);
  358. border-radius: 20rpx;
  359. .title{
  360. font-size: 38rpx;
  361. margin-bottom: 10rpx;
  362. font-weight: bold;
  363. }
  364. .text{
  365. font-size: 32rpx;
  366. }
  367. }
  368. }
  369. </style>