"use strict"; const common_vendor = require("../../common/vendor.js"); const common_assets = require("../../common/assets.js"); const API_api = require("../../API/api.js"); if (!Array) { const _easycom_uni_notice_bar2 = common_vendor.resolveComponent("uni-notice-bar"); const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons"); (_easycom_uni_notice_bar2 + _easycom_uni_icons2)(); } const _easycom_uni_notice_bar = () => "../../uni_modules/uni-notice-bar/components/uni-notice-bar/uni-notice-bar.js"; const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js"; if (!Math) { (_easycom_uni_notice_bar + _easycom_uni_icons + common_vendor.unref(recommend))(); } const recommend = () => "../recommend/recommend.js"; const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "index", props: { damping: { type: Number, default: 10 }, direction: { type: String, default: "all" }, position: { type: Number, default: 4 } }, setup(__props) { const meishi = common_vendor.ref(""); const getCategoryList = () => { common_vendor.index.request({ url: API_api.apiImageUrl + "/api/category/list", method: "GET", success(res) { console.log(res.data.data); meishi.value = res.data.data; }, fail(err) { console.log(err); } }); }; common_vendor.onMounted(() => { getCategoryList(); }); const categorySort = (id) => { console.log(id); const pageRoutes = { 1: "/pages/food/food", 2: "/pages/drinks/drinks", 3: "/pages/fruits/fruits", 4: "/pages/points/points", 5: "/pages/more/more" }; if (pageRoutes[id]) { common_vendor.index.navigateTo({ url: pageRoutes[id] }); } else { console.warn("No matching page for id:", id); } }; const systemList = common_vendor.ref([]); const lastSystemItem = common_vendor.computed(() => systemList.value[systemList.value.length - 1]); const system = () => { common_vendor.index.request({ url: API_api.apiImageUrl + "/api/system/list", method: "POST", data: { type: 0 }, success(res) { systemList.value = res.data.data; console.log(systemList.value); }, fail() { console.log("失败啦"); } }); }; common_vendor.onMounted(system); common_vendor.ref(0); const goSearch = () => { common_vendor.index.navigateTo({ url: "/pages/goSearch/goSearch" }); }; const props = __props; const state = common_vendor.reactive({ x: 0, y: 0, x1: 0, x2: 0, y1: 0, y2: 0, move: { x: 0, y: 0 } }); common_vendor.onMounted(() => { common_vendor.index.getSystemInfo({ success: (res) => { state.x1 = 0; state.x2 = parseInt(res.windowWidth) - 50; state.y1 = 0; state.y2 = parseInt(res.windowHeight) - 20; setTimeout(() => { if ([1, 2].includes(props.position)) state.y = parseInt(state.y2 * 0.2); if ([3, 4].includes(props.position)) state.y = parseInt(state.y2 * 0.8); if ([1, 3].includes(props.position)) state.x = parseInt(state.x1); if ([2, 4].includes(props.position)) state.x = parseInt(state.x2); state.move.x = state.x; state.move.y = state.y; }, 1e3); } }); }); function onChange(e) { if (e.detail.source === "touch") { state.move.x = e.detail.x; state.move.y = e.detail.y; } } function onTap(e) { console.log("Tap event"); common_vendor.index.navigateTo({ url: "/pages/testFive/testFive" }); } function onTouchend() { state.x = state.move.x; state.y = state.move.y; setTimeout(() => { if (state.move.x < state.x2 / 2) state.x = state.x1; else state.x = state.x2; console.log("yuan" + state.x, state.y); }, 100); } const getloginUser = () => { const user = common_vendor.index.getStorageSync("userInfo"); console.log(user); if (user == "") { common_vendor.index.showToast({ title: "去登录", duration: 2e3 }); } }; common_vendor.onMounted(getloginUser); return (_ctx, _cache) => { return { a: common_vendor.p({ ["show-icon"]: true, scrollable: true, text: lastSystemItem.value.content }), b: common_vendor.o(goSearch), c: common_vendor.p({ type: "chat-filled", size: "30" }), d: common_vendor.f(meishi.value, (item, index, i0) => { return { a: item.image, b: common_vendor.t(item.name), c: item.url, d: index, e: common_vendor.o(($event) => categorySort(item.id)) }; }), e: common_assets._imports_0, f: state.x, g: state.y, h: props.direction, i: props.damping, j: common_vendor.o(onChange), k: common_vendor.o(onTap), l: common_vendor.o(onTouchend) }; }; } }); my.createPage(_sfc_main);