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"; import { B as BackTop } from "./index-9e456003.js"; import { P as PullRefresh } from "./index-e8b8fc91.js"; import { S as SwipeCell } from "./index-73d5a905.js"; import { C as Cell } from "./index-8540448e.js"; import { I as Image } from "./index-f1ec0231.js"; import { B as Button } from "./index-b1054607.js"; import { F as Field } from "./index-41ec7e28.js"; import { p as post_promise } from "./index-18735c56.js"; import { C as CusNavigation } from "./CusNavigation-87012716.js"; import { I as Icon } from "./index-487cde8c.js"; import { L as Loading } from "./index-217c49a0.js"; import "./index-eef3af38.js"; import "./use-scope-id-0b5b8615.js"; import "./on-popup-reopen-c5ca1603.js"; import "./use-route-726f0d0b.js"; import "./axios-8cd254ce.js"; import "./function-call-dc072a29.js"; import "./mount-component-2b0f7b23.js"; const _hoisted_1 = { style: { "display": "flex", "flex-direction": "column", "height": "100vh" } }; const _hoisted_2 = { style: { "padding": "16px" } }; const _hoisted_3 = { style: { "background-color": "#eee", "border-radius": "2.5rem", "margin": "0px 5px" } }; const _hoisted_4 = { style: { "margin-top": "16px", "display": "flex" } }; const _hoisted_5 = { style: { "flex-grow": "1" } }; const _hoisted_6 = { style: { "flex-grow": "1" } }; const _hoisted_7 = { style: { "padding": "16px" } }; const _hoisted_8 = { style: { "height": "80px", "display": "flex" } }; const _hoisted_9 = { style: { "margin-right": "18px" } }; const _hoisted_10 = { key: 0 }; const _hoisted_11 = { key: 1, style: { "text-align": "center", "padding": "10px 20px 20px 20px", "color": "#ccc" } }; const _hoisted_12 = { key: 2, style: { "text-align": "center", "padding": "10px 20px 20px 20px" } }; const _hoisted_13 = { key: 3, style: { "text-align": "center", "padding": "10px 20px 20px 20px", "color": "#ccc" } }; const _hoisted_14 = { key: 4, style: { "text-align": "center", "padding": "10px 20px 20px 20px" } }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "Index", setup(__props) { const cusNavigation = ref(); const onSearch = () => { console.log("jjj"); console.log(keyWord); onRefresh(); }; const onCancel = () => { cusNavigation.value.closeSearchPopup(); }; const onScan = () => { cusNavigation.value.closePlusPopup(); }; const keyWord = ref(""); const page = reactive({ total: 0, pageNum: 1, pageSize: 10, pages: 0 }); const dataList = ref([]); const refreshing = ref(false); const isLoading = ref(false); const finished = ref(false); const getData = () => { console.log("onload....."); post_promise({ url: "/device/search", data: { size: page.pageSize, page: page.pageNum, sort: "createtime", order: "desc", keyWord: keyWord.value, mac: "" } }).then((result) => { console.log(result); isLoading.value = false; refreshing.value = false; if (result.code == 0) { const dataArr = result.data; const total = result.total; const pages = Math.ceil(total / page.pageSize); console.log(pages); console.log(dataArr); if (page.pageNum == 1) { dataList.value.splice(0, dataList.value.length); } dataList.value.push(...dataArr); page.pages = pages; page.total = total; console.log(dataList.value, pages); } }, (result) => { console.log(result); isLoading.value = false; refreshing.value = false; }).catch((ex) => { console.log(ex); isLoading.value = false; refreshing.value = false; }); }; const onRefresh = () => { console.log("onrefresh..."); console.log(refreshing.value); page.pageNum = 1; finished.value = false; isLoading.value = true; getData(); }; onMounted(() => { console.log("onMounted"); getData(); }); const scrollRef = ref(null); const scrollTop = ref(0); onActivated(() => { console.log("onActived..."); nextTick(() => { scrollRef.value.scrollTop = scrollTop.value; }); }); onBeforeRouteLeave((to, from, next) => { console.log(to, from); console.log("onBeforeRouteLeave..."); scrollTop.value = scrollRef.value.scrollTop; next(); }); const clickLoading = () => { console.log("clickLoading"); page.pageNum++; isLoading.value = true; getData(); }; return (_ctx, _cache) => { const _component_van_icon = Icon; const _component_van_field = Field; const _component_van_button = Button; const _component_van_image = Image; const _component_van_cell = Cell; const _component_van_swipe_cell = SwipeCell; const _component_van_loading = Loading; const _component_van_pull_refresh = PullRefresh; const _component_van_back_top = BackTop; return openBlock(), createElementBlock("div", _hoisted_1, [ createVNode(unref(CusNavigation), { ref_key: "cusNavigation", ref: cusNavigation, gobackabled: "", title: "文章列表", searchabled: "", plusabled: false }, { search: withCtx(() => [ createBaseVNode("div", _hoisted_2, [ createBaseVNode("div", _hoisted_3, [ createVNode(_component_van_field, { style: { "padding": "6px 16px", "height": "44px", "line-height": "25px", "align-items": "center" }, modelValue: keyWord.value, "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => keyWord.value = $event), size: "normal", clearable: "" }, { "right-icon": withCtx(() => [ createBaseVNode("div", null, [ createVNode(_component_van_icon, { name: "scan", size: "1.5rem" }) ]) ]), _: 1 }, 8, ["modelValue"]) ]), createBaseVNode("div", _hoisted_4, [ createBaseVNode("div", _hoisted_5, [ createVNode(_component_van_button, { type: "warning", size: "normal", round: "", block: "", onClick: onCancel }, { default: withCtx(() => _cache[2] || (_cache[2] = [ createTextVNode("取消") ])), _: 1 }) ]), _cache[4] || (_cache[4] = createBaseVNode("div", { style: { "width": "10px" } }, null, -1)), createBaseVNode("div", _hoisted_6, [ createVNode(_component_van_button, { type: "primary", size: "normal", round: "", block: "", onClick: onSearch }, { default: withCtx(() => _cache[3] || (_cache[3] = [ createTextVNode("搜索") ])), _: 1 }) ]) ]) ]) ]), plus: withCtx(() => [ createBaseVNode("div", _hoisted_7, [ createBaseVNode("div", null, [ createVNode(_component_van_button, { type: "primary", size: "normal", icon: "scan", round: "", block: "", onClick: onScan }, { default: withCtx(() => _cache[5] || (_cache[5] = [ createTextVNode("扫码添加设备") ])), _: 1 }) ]) ]) ]), _: 1 }, 512), createBaseVNode("div", { ref_key: "scrollRef", ref: scrollRef, class: "container", style: { "overflow-y": "auto", "flex-grow": "1" } }, [ createVNode(_component_van_pull_refresh, { style: { "min-height": "100%" }, modelValue: refreshing.value, "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => refreshing.value = $event), onRefresh }, { default: withCtx(() => [ (openBlock(true), createElementBlock(Fragment, null, renderList(dataList.value, (item) => { return openBlock(), createBlock(_component_van_swipe_cell, { style: { "background-color": "#fff", "margin-bottom": "10px" } }, { default: withCtx(() => [ createVNode(_component_van_cell, { clickable: "", to: "/article/detail/" + item.mac }, { default: withCtx(() => [ createBaseVNode("div", _hoisted_8, [ createBaseVNode("div", _hoisted_9, [ createVNode(_component_van_image, { width: "80", height: "80", radius: "6", src: "static/images/banner.png" }) ]), _cache[6] || (_cache[6] = createBaseVNode("div", { style: { "width": "0px", "flex-grow": "1", "display": "flex", "flex-direction": "column", "justify-content": "space-between" } }, [ createBaseVNode("div", { style: { "font-weight": "bold", "text-align": "left", "color": "#000" } }, [ createBaseVNode("span", null, "公务员考试笔试,政审都过了,单位叫我去上班我要去吗?") ]), createBaseVNode("div", { style: { "display": "flex", "justify-content": "space-between", "color": "#969799" } }, [ createBaseVNode("div", null, "河南新闻"), createBaseVNode("div", null, "2024-06-11") ]) ], -1)) ]) ]), _: 2 }, 1032, ["to"]) ]), _: 2 }, 1024); }), 256)), createBaseVNode("div", null, [ refreshing.value ? (openBlock(), createElementBlock("div", _hoisted_10)) : dataList.value.length == 0 ? (openBlock(), createElementBlock("div", _hoisted_11, _cache[7] || (_cache[7] = [ createBaseVNode("span", null, "暂无数据", -1) ]))) : isLoading.value ? (openBlock(), createElementBlock("div", _hoisted_12, [ createVNode(_component_van_loading, { type: "spinner", color: "#1989fa" }) ])) : page.pages <= page.pageNum ? (openBlock(), createElementBlock("div", _hoisted_13, _cache[8] || (_cache[8] = [ createBaseVNode("span", null, "没有更多了", -1) ]))) : (openBlock(), createElementBlock("div", _hoisted_14, [ createBaseVNode("span", { onClick: clickLoading }, "点击加载") ])) ]) ]), _: 1 }, 8, ["modelValue"]), createVNode(_component_van_back_top, { target: ".container", right: "5vw", bottom: "80px" }) ], 512) ]); }; } }); export { _sfc_main as default };