log.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="content">
  3. <view class="" v-if="show == true">
  4. <view class="" v-for="(obj, index) in tabList" :key="index">
  5. <view class="title">
  6. <text>设备ID:</text>
  7. <!-- :style="obj.status == 1 ? 'color: #00ff08;' : 'color: #ff0000;'" -->
  8. <text>
  9. {{ obj.deviceId }}
  10. </text>
  11. </view>
  12. <view class="">
  13. <view class="content_boby">
  14. <view class="content_boby_view">
  15. <text>设备名称:</text>
  16. <text :class="obj.status == 1 ? 'showFalw' : 'showTres'">
  17. {{ obj.deviceName }}
  18. </text>
  19. </view>
  20. </view>
  21. <view class="content_boby">
  22. <view class="content_boby_view" style="width: 100%">
  23. <text>日志内容:</text>
  24. <text :class="obj.status == 1 ? 'showFalw' : 'showTres'">
  25. {{ obj.content }}
  26. </text>
  27. </view>
  28. </view>
  29. <view class="content_boby">
  30. <view class="content_boby_view">
  31. <text>状态:</text>
  32. <text
  33. :class="obj.status == 1 ? 'showFalw' : 'showTres'"
  34. v-if="obj.status == 1">
  35. 连接正常
  36. </text>
  37. <text :class="obj.status == 1 ? 'showFalw' : 'showTres'" v-else>
  38. 连接中断
  39. </text>
  40. </view>
  41. </view>
  42. <view class="content_boby">
  43. <view class="content_boby_view">
  44. <text>时间:</text>
  45. <text :class="obj.status == 1 ? 'showFalw' : 'showTres'">
  46. {{ obj.createTime }}
  47. </text>
  48. </view>
  49. </view>
  50. <!-- <view class="content_boby">
  51. <view class="content_boby_view">
  52. <text>备注:</text>
  53. <text>{{ obj.remark }}</text>
  54. </view>
  55. </view> -->
  56. <view class="hr"></view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="text" style="text-align: center; margin: 10vw 0" v-else>
  61. <text>暂无数据</text>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. export default {
  67. components: {},
  68. data() {
  69. return {
  70. obj: {},
  71. show: true,
  72. page: 1,
  73. tabList: [],
  74. host: "",
  75. deviceId: "",
  76. };
  77. },
  78. onLoad(option) {
  79. let _this = this;
  80. this.deviceId = option.id;
  81. uni.getStorage({
  82. key: "hostappst",
  83. success(res) {
  84. console.log("获取成功", res.data);
  85. _this.host = res.data;
  86. },
  87. });
  88. this.getData();
  89. },
  90. onShow() {},
  91. created() {},
  92. mounted() {},
  93. onReachBottom() {
  94. this.page++;
  95. this.getData("addList");
  96. },
  97. methods: {
  98. logReter(id) {
  99. uni.navigateTo({
  100. url: "/pages/index/me/log/log?id=" + id,
  101. });
  102. },
  103. getData(type) {
  104. let that = this;
  105. let data = {
  106. deviceId: this.deviceId,
  107. pageNum: this.page,
  108. pageSize: 10,
  109. };
  110. uni.getStorage({
  111. key: "GetPhone_Token",
  112. success: function (res) {
  113. uni.request({
  114. url: `http://${that.host}` + "/device/log/list",
  115. header: {
  116. Authorization: res.data,
  117. "content-type": "application/x-www-form-urlencoded",
  118. },
  119. data: data,
  120. method: "GET",
  121. success(respenon) {
  122. console.log("chaoShiPanDuan", respenon);
  123. if (respenon.data.code == 200) {
  124. if (type == "addList") {
  125. that.tabList = [...that.tabList, ...respenon.data.rows];
  126. } else {
  127. that.tabList = respenon.data.rows;
  128. if (that.tabList.length > 0) {
  129. that.show = true;
  130. } else {
  131. that.show = false;
  132. }
  133. }
  134. } else {
  135. uni.showToast({
  136. title: respenon.data.msg,
  137. icon: "none",
  138. });
  139. }
  140. },
  141. });
  142. },
  143. });
  144. },
  145. },
  146. };
  147. </script>
  148. <style scoped lang="scss">
  149. .content {
  150. color: #787878;
  151. font-size: 14px;
  152. font-weight: 400;
  153. .title {
  154. height: 44px;
  155. padding: 12px 15px;
  156. font-size: 17px;
  157. font-weight: 600;
  158. color: #000;
  159. }
  160. .content_boby {
  161. padding: 0 15px;
  162. display: flex;
  163. justify-content: space-between;
  164. margin-bottom: 10px;
  165. .showFalw {
  166. color: #0bbc11;
  167. }
  168. .showTres {
  169. color: red;
  170. // display: -webkit-box;
  171. // overflow-wrap: anywhere;
  172. word-wrap: break-word;
  173. }
  174. }
  175. .hr {
  176. width: 100%;
  177. height: 1px;
  178. background: #cfcfcf;
  179. }
  180. }
  181. </style>