historyToday.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view class="ht-box">
  3. <view @tap.stop.prevent="godetails" class="ht-list" :data-id="item.e_id" v-for="(item, index) in getdata" :key="index">
  4. <view class="ht-list-year">{{ item.date }}</view>
  5. <view class="ht-list-event">{{ item.title }}</view>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. data() {
  12. return {
  13. getdata: [],
  14. show: false
  15. };
  16. },
  17. onLoad: function (t) {
  18. this.getData();
  19. },
  20. onShareAppMessage: function () {},
  21. methods: {
  22. getData: function () {
  23. uni.showLoading({
  24. title: '加载中'
  25. });
  26. var that = this;
  27. var e = new Date();
  28. var a = e.getMonth() + 1;
  29. var n = e.getDate();
  30. uni.request({
  31. url: 'https://v.juhe.cn/todayOnhistory/queryEvent.php?key=8525e2cd6ff71f07f54d3c7432f71685&date=' + a + '/' + n,
  32. data: {},
  33. header: {
  34. 'content-type': 'application/json'
  35. },
  36. success: function (e) {
  37. uni.hideLoading();
  38. if ('success' == e.data.reason) {
  39. that.show=true;
  40. that.getdata=e.data.result;
  41. } else {
  42. uni.showModal({
  43. title: '提示',
  44. content: '查询失败',
  45. success: function (e) {
  46. that.show=false;
  47. }
  48. });
  49. }
  50. }
  51. });
  52. },
  53. godetails: function (t) {
  54. console.log(t.currentTarget.dataset.id);
  55. uni.navigateTo({
  56. url: './details?id=' + t.currentTarget.dataset.id
  57. });
  58. }
  59. }
  60. };
  61. </script>
  62. <style>
  63. @import './historyToday.css';
  64. </style>