Index-e0b19cb0.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. import { d as defineComponent, r as ref, n as reactive, o as onMounted, p as onActivated, q as onBeforeRouteLeave, b as createElementBlock, c as createVNode, f as withCtx, B as unref, e as createBaseVNode, j as openBlock, s as createTextVNode, F as Fragment, x as renderList, k as createBlock, z as nextTick } from "./index-5e4623ce.js";
  2. import { B as BackTop } from "./index-9e456003.js";
  3. import { P as PullRefresh } from "./index-e8b8fc91.js";
  4. import { S as SwipeCell } from "./index-73d5a905.js";
  5. import { C as Cell } from "./index-8540448e.js";
  6. import { I as Image } from "./index-f1ec0231.js";
  7. import { B as Button } from "./index-b1054607.js";
  8. import { F as Field } from "./index-41ec7e28.js";
  9. import { p as post_promise } from "./index-18735c56.js";
  10. import { C as CusNavigation } from "./CusNavigation-87012716.js";
  11. import { I as Icon } from "./index-487cde8c.js";
  12. import { L as Loading } from "./index-217c49a0.js";
  13. import "./index-eef3af38.js";
  14. import "./use-scope-id-0b5b8615.js";
  15. import "./on-popup-reopen-c5ca1603.js";
  16. import "./use-route-726f0d0b.js";
  17. import "./axios-8cd254ce.js";
  18. import "./function-call-dc072a29.js";
  19. import "./mount-component-2b0f7b23.js";
  20. const _hoisted_1 = { style: { "display": "flex", "flex-direction": "column", "height": "100vh" } };
  21. const _hoisted_2 = { style: { "padding": "16px" } };
  22. const _hoisted_3 = { style: { "background-color": "#eee", "border-radius": "2.5rem", "margin": "0px 5px" } };
  23. const _hoisted_4 = { style: { "margin-top": "16px", "display": "flex" } };
  24. const _hoisted_5 = { style: { "flex-grow": "1" } };
  25. const _hoisted_6 = { style: { "flex-grow": "1" } };
  26. const _hoisted_7 = { style: { "padding": "16px" } };
  27. const _hoisted_8 = { style: { "height": "80px", "display": "flex" } };
  28. const _hoisted_9 = { style: { "margin-right": "18px" } };
  29. const _hoisted_10 = { key: 0 };
  30. const _hoisted_11 = {
  31. key: 1,
  32. style: { "text-align": "center", "padding": "10px 20px 20px 20px", "color": "#ccc" }
  33. };
  34. const _hoisted_12 = {
  35. key: 2,
  36. style: { "text-align": "center", "padding": "10px 20px 20px 20px" }
  37. };
  38. const _hoisted_13 = {
  39. key: 3,
  40. style: { "text-align": "center", "padding": "10px 20px 20px 20px", "color": "#ccc" }
  41. };
  42. const _hoisted_14 = {
  43. key: 4,
  44. style: { "text-align": "center", "padding": "10px 20px 20px 20px" }
  45. };
  46. const _sfc_main = /* @__PURE__ */ defineComponent({
  47. __name: "Index",
  48. setup(__props) {
  49. const cusNavigation = ref();
  50. const onSearch = () => {
  51. console.log("jjj");
  52. console.log(keyWord);
  53. onRefresh();
  54. };
  55. const onCancel = () => {
  56. cusNavigation.value.closeSearchPopup();
  57. };
  58. const onScan = () => {
  59. cusNavigation.value.closePlusPopup();
  60. };
  61. const keyWord = ref("");
  62. const page = reactive({
  63. total: 0,
  64. pageNum: 1,
  65. pageSize: 10,
  66. pages: 0
  67. });
  68. const dataList = ref([]);
  69. const refreshing = ref(false);
  70. const isLoading = ref(false);
  71. const finished = ref(false);
  72. const getData = () => {
  73. console.log("onload.....");
  74. post_promise({ url: "/device/search", data: {
  75. size: page.pageSize,
  76. page: page.pageNum,
  77. sort: "createtime",
  78. order: "desc",
  79. keyWord: keyWord.value,
  80. mac: ""
  81. } }).then((result) => {
  82. console.log(result);
  83. isLoading.value = false;
  84. refreshing.value = false;
  85. if (result.code == 0) {
  86. const dataArr = result.data;
  87. const total = result.total;
  88. const pages = Math.ceil(total / page.pageSize);
  89. console.log(pages);
  90. console.log(dataArr);
  91. if (page.pageNum == 1) {
  92. dataList.value.splice(0, dataList.value.length);
  93. }
  94. dataList.value.push(...dataArr);
  95. page.pages = pages;
  96. page.total = total;
  97. console.log(dataList.value, pages);
  98. }
  99. }, (result) => {
  100. console.log(result);
  101. isLoading.value = false;
  102. refreshing.value = false;
  103. }).catch((ex) => {
  104. console.log(ex);
  105. isLoading.value = false;
  106. refreshing.value = false;
  107. });
  108. };
  109. const onRefresh = () => {
  110. console.log("onrefresh...");
  111. console.log(refreshing.value);
  112. page.pageNum = 1;
  113. finished.value = false;
  114. isLoading.value = true;
  115. getData();
  116. };
  117. onMounted(() => {
  118. console.log("onMounted");
  119. getData();
  120. });
  121. const scrollRef = ref(null);
  122. const scrollTop = ref(0);
  123. onActivated(() => {
  124. console.log("onActived...");
  125. nextTick(() => {
  126. scrollRef.value.scrollTop = scrollTop.value;
  127. });
  128. });
  129. onBeforeRouteLeave((to, from, next) => {
  130. console.log(to, from);
  131. console.log("onBeforeRouteLeave...");
  132. scrollTop.value = scrollRef.value.scrollTop;
  133. next();
  134. });
  135. const clickLoading = () => {
  136. console.log("clickLoading");
  137. page.pageNum++;
  138. isLoading.value = true;
  139. getData();
  140. };
  141. return (_ctx, _cache) => {
  142. const _component_van_icon = Icon;
  143. const _component_van_field = Field;
  144. const _component_van_button = Button;
  145. const _component_van_image = Image;
  146. const _component_van_cell = Cell;
  147. const _component_van_swipe_cell = SwipeCell;
  148. const _component_van_loading = Loading;
  149. const _component_van_pull_refresh = PullRefresh;
  150. const _component_van_back_top = BackTop;
  151. return openBlock(), createElementBlock("div", _hoisted_1, [
  152. createVNode(unref(CusNavigation), {
  153. ref_key: "cusNavigation",
  154. ref: cusNavigation,
  155. gobackabled: "",
  156. title: "文章列表",
  157. searchabled: "",
  158. plusabled: false
  159. }, {
  160. search: withCtx(() => [
  161. createBaseVNode("div", _hoisted_2, [
  162. createBaseVNode("div", _hoisted_3, [
  163. createVNode(_component_van_field, {
  164. style: { "padding": "6px 16px", "height": "44px", "line-height": "25px", "align-items": "center" },
  165. modelValue: keyWord.value,
  166. "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => keyWord.value = $event),
  167. size: "normal",
  168. clearable: ""
  169. }, {
  170. "right-icon": withCtx(() => [
  171. createBaseVNode("div", null, [
  172. createVNode(_component_van_icon, {
  173. name: "scan",
  174. size: "1.5rem"
  175. })
  176. ])
  177. ]),
  178. _: 1
  179. }, 8, ["modelValue"])
  180. ]),
  181. createBaseVNode("div", _hoisted_4, [
  182. createBaseVNode("div", _hoisted_5, [
  183. createVNode(_component_van_button, {
  184. type: "warning",
  185. size: "normal",
  186. round: "",
  187. block: "",
  188. onClick: onCancel
  189. }, {
  190. default: withCtx(() => _cache[2] || (_cache[2] = [
  191. createTextVNode("取消")
  192. ])),
  193. _: 1
  194. })
  195. ]),
  196. _cache[4] || (_cache[4] = createBaseVNode("div", { style: { "width": "10px" } }, null, -1)),
  197. createBaseVNode("div", _hoisted_6, [
  198. createVNode(_component_van_button, {
  199. type: "primary",
  200. size: "normal",
  201. round: "",
  202. block: "",
  203. onClick: onSearch
  204. }, {
  205. default: withCtx(() => _cache[3] || (_cache[3] = [
  206. createTextVNode("搜索")
  207. ])),
  208. _: 1
  209. })
  210. ])
  211. ])
  212. ])
  213. ]),
  214. plus: withCtx(() => [
  215. createBaseVNode("div", _hoisted_7, [
  216. createBaseVNode("div", null, [
  217. createVNode(_component_van_button, {
  218. type: "primary",
  219. size: "normal",
  220. icon: "scan",
  221. round: "",
  222. block: "",
  223. onClick: onScan
  224. }, {
  225. default: withCtx(() => _cache[5] || (_cache[5] = [
  226. createTextVNode("扫码添加设备")
  227. ])),
  228. _: 1
  229. })
  230. ])
  231. ])
  232. ]),
  233. _: 1
  234. }, 512),
  235. createBaseVNode("div", {
  236. ref_key: "scrollRef",
  237. ref: scrollRef,
  238. class: "container",
  239. style: { "overflow-y": "auto", "flex-grow": "1" }
  240. }, [
  241. createVNode(_component_van_pull_refresh, {
  242. style: { "min-height": "100%" },
  243. modelValue: refreshing.value,
  244. "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => refreshing.value = $event),
  245. onRefresh
  246. }, {
  247. default: withCtx(() => [
  248. (openBlock(true), createElementBlock(Fragment, null, renderList(dataList.value, (item) => {
  249. return openBlock(), createBlock(_component_van_swipe_cell, { style: { "background-color": "#fff", "margin-bottom": "10px" } }, {
  250. default: withCtx(() => [
  251. createVNode(_component_van_cell, {
  252. clickable: "",
  253. to: "/article/detail/" + item.mac
  254. }, {
  255. default: withCtx(() => [
  256. createBaseVNode("div", _hoisted_8, [
  257. createBaseVNode("div", _hoisted_9, [
  258. createVNode(_component_van_image, {
  259. width: "80",
  260. height: "80",
  261. radius: "6",
  262. src: "static/images/banner.png"
  263. })
  264. ]),
  265. _cache[6] || (_cache[6] = createBaseVNode("div", { style: { "width": "0px", "flex-grow": "1", "display": "flex", "flex-direction": "column", "justify-content": "space-between" } }, [
  266. createBaseVNode("div", { style: { "font-weight": "bold", "text-align": "left", "color": "#000" } }, [
  267. createBaseVNode("span", null, "公务员考试笔试,政审都过了,单位叫我去上班我要去吗?")
  268. ]),
  269. createBaseVNode("div", { style: { "display": "flex", "justify-content": "space-between", "color": "#969799" } }, [
  270. createBaseVNode("div", null, "河南新闻"),
  271. createBaseVNode("div", null, "2024-06-11")
  272. ])
  273. ], -1))
  274. ])
  275. ]),
  276. _: 2
  277. }, 1032, ["to"])
  278. ]),
  279. _: 2
  280. }, 1024);
  281. }), 256)),
  282. createBaseVNode("div", null, [
  283. refreshing.value ? (openBlock(), createElementBlock("div", _hoisted_10)) : dataList.value.length == 0 ? (openBlock(), createElementBlock("div", _hoisted_11, _cache[7] || (_cache[7] = [
  284. createBaseVNode("span", null, "暂无数据", -1)
  285. ]))) : isLoading.value ? (openBlock(), createElementBlock("div", _hoisted_12, [
  286. createVNode(_component_van_loading, {
  287. type: "spinner",
  288. color: "#1989fa"
  289. })
  290. ])) : page.pages <= page.pageNum ? (openBlock(), createElementBlock("div", _hoisted_13, _cache[8] || (_cache[8] = [
  291. createBaseVNode("span", null, "没有更多了", -1)
  292. ]))) : (openBlock(), createElementBlock("div", _hoisted_14, [
  293. createBaseVNode("span", { onClick: clickLoading }, "点击加载")
  294. ]))
  295. ])
  296. ]),
  297. _: 1
  298. }, 8, ["modelValue"]),
  299. createVNode(_component_van_back_top, {
  300. target: ".container",
  301. right: "5vw",
  302. bottom: "80px"
  303. })
  304. ], 512)
  305. ]);
  306. };
  307. }
  308. });
  309. export {
  310. _sfc_main as default
  311. };