location_list.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <script src="https://web.tianyunperfect.cn/util.js"></script>
  7. <title>location_list</title>
  8. <script src="js/axios.min.js"></script>
  9. <script src="js/vue.min.js"></script>
  10. <style>
  11. .container {
  12. width: 500px;
  13. height: 50px;
  14. margin: 100px auto;
  15. }
  16. .parent {
  17. width: 100%;
  18. height: 42px;
  19. top: 4px;
  20. position: relative;
  21. }
  22. .parent > input:first-of-type {
  23. /*输入框高度设置为40px, border占据2px,总高度为42px*/
  24. width: 380px;
  25. height: 40px;
  26. border: 1px solid #ccc;
  27. font-size: 16px;
  28. outline: none;
  29. }
  30. .parent > input:first-of-type:focus {
  31. border: 1px solid #317ef3;
  32. padding-left: 10px;
  33. }
  34. .parent > input:last-of-type {
  35. /*button按钮border并不占据外围大小,设置高度42px*/
  36. width: 100px;
  37. height: 44px;
  38. position: absolute;
  39. background: #317ef3;
  40. border: 1px solid #317ef3;
  41. color: #fff;
  42. font-size: 16px;
  43. outline: none;
  44. }
  45. </style>
  46. </head>
  47. <body>
  48. <div id="tby">
  49. <div class="container">
  50. <form action="" class="parent">
  51. <input type="text" v-model="msg">
  52. <input type="button" value="搜索" @click="search">
  53. </form>
  54. </div>
  55. <table>
  56. <thead>
  57. <tr>
  58. <td>事件</td>
  59. <td>地点</td>
  60. <td>信息</td>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. <tr v-for="(item,index) in list">
  65. <td>{{new Date(item.create_time).format("yyyy-MM-dd hh:mm:ss")}}</td>
  66. <td>
  67. <a :href="'https://api.map.baidu.com/marker?location='+ item.location_xy + '&title=' + item.msg + '&content=&output=html&src=webapp.baidu.openAPIdemo'"
  68. target="_blank">{{item.location_xy}}</a>
  69. </td>
  70. <td>{{item.msg}}</td>
  71. </tr>
  72. </tbody>
  73. </table>
  74. <!-- 分页按钮 -->
  75. <div class="page-icon">
  76. <button class="firstPage" @click="first_click">第一页</button>
  77. <button class="beforePage" @click="prev_click">上一页</button>
  78. <button>第<input v-model="page" @change="choose_page" type="text" value="1"/>页</button>
  79. <button class="nextPage" @click="next_click">下一页</button>
  80. </div>
  81. </div>
  82. <script>
  83. Date.prototype.format = function (fmt) {
  84. var o = {
  85. "M+": this.getMonth() + 1, //月份
  86. "d+": this.getDate(), //日
  87. "h+": this.getHours(), //小时
  88. "m+": this.getMinutes(), //分
  89. "s+": this.getSeconds(), //秒
  90. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  91. "S": this.getMilliseconds() //毫秒
  92. };
  93. if (/(y+)/.test(fmt)) {
  94. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  95. }
  96. for (var k in o) {
  97. if (new RegExp("(" + k + ")").test(fmt)) {
  98. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  99. }
  100. }
  101. return fmt;
  102. }
  103. new Vue({
  104. el: '#tby',
  105. data: {
  106. page: 1,
  107. size: 1000,
  108. msg: "",
  109. user_id: "",
  110. list: []
  111. },
  112. mounted: function () {
  113. this.user_id = getQueryString("user_id");
  114. this.search();
  115. },
  116. methods: {
  117. first_click: function () {
  118. this.page = 1;
  119. this.search();
  120. },
  121. prev_click: function () {
  122. this.page -= 1;
  123. this.search();
  124. },
  125. choose_page: function () {
  126. this.search();
  127. },
  128. next_click: function () {
  129. this.page += 1;
  130. this.search();
  131. },
  132. getParam: function () {
  133. let obj = {};
  134. obj['user_id'] = this.user_id;
  135. obj['limit1'] = (this.page - 1) * this.size;
  136. obj['limit2'] = this.page * this.size;
  137. if (this.msg.length > 0) {
  138. obj["msg"] = this.msg;
  139. }
  140. return obj;
  141. },
  142. search: function () {
  143. let _this = this;
  144. axios.get("https://api.tianyunperfect.cn/web_history/location_history", {params: this.getParam()}).then(res => {
  145. if (res.data.code === 1) {
  146. _this.list = res.data.data;
  147. }
  148. });
  149. }
  150. }
  151. });
  152. </script>
  153. </body>
  154. </html>