2024-10-18 07:53:00 +00:00
|
|
|
"use strict";
|
|
|
|
const common_vendor = require("../../common/vendor.js");
|
2025-04-11 06:42:29 +00:00
|
|
|
const common_assets = require("../../common/assets.js");
|
|
|
|
const API_api = require("../../API/api.js");
|
2024-10-18 07:53:00 +00:00
|
|
|
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",
|
2025-04-11 06:42:29 +00:00
|
|
|
props: {
|
|
|
|
damping: {
|
|
|
|
type: Number,
|
|
|
|
default: 10
|
|
|
|
},
|
|
|
|
direction: {
|
|
|
|
type: String,
|
|
|
|
default: "all"
|
|
|
|
},
|
|
|
|
position: {
|
|
|
|
type: Number,
|
|
|
|
default: 4
|
|
|
|
}
|
|
|
|
},
|
2024-10-18 07:53:00 +00:00
|
|
|
setup(__props) {
|
2025-04-11 06:42:29 +00:00
|
|
|
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);
|
2024-10-18 07:53:00 +00:00
|
|
|
common_vendor.ref(0);
|
2025-04-11 06:42:29 +00:00
|
|
|
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({
|
2024-10-18 07:53:00 +00:00
|
|
|
success: (res) => {
|
2025-04-11 06:42:29 +00:00
|
|
|
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);
|
2024-10-18 07:53:00 +00:00
|
|
|
}
|
|
|
|
});
|
2025-04-11 06:42:29 +00:00
|
|
|
});
|
|
|
|
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
|
|
|
|
});
|
|
|
|
}
|
2024-10-18 07:53:00 +00:00
|
|
|
};
|
2025-04-11 06:42:29 +00:00
|
|
|
common_vendor.onMounted(getloginUser);
|
2024-10-18 07:53:00 +00:00
|
|
|
return (_ctx, _cache) => {
|
|
|
|
return {
|
|
|
|
a: common_vendor.p({
|
|
|
|
["show-icon"]: true,
|
|
|
|
scrollable: true,
|
2025-04-11 06:42:29 +00:00
|
|
|
text: lastSystemItem.value.content
|
2024-10-18 07:53:00 +00:00
|
|
|
}),
|
2025-04-11 06:42:29 +00:00
|
|
|
b: common_vendor.o(goSearch),
|
2024-10-18 07:53:00 +00:00
|
|
|
c: common_vendor.p({
|
|
|
|
type: "chat-filled",
|
|
|
|
size: "30"
|
|
|
|
}),
|
2025-04-11 06:42:29 +00:00
|
|
|
d: common_vendor.f(meishi.value, (item, index, i0) => {
|
2024-10-18 07:53:00 +00:00
|
|
|
return {
|
2025-04-11 06:42:29 +00:00
|
|
|
a: item.image,
|
|
|
|
b: common_vendor.t(item.name),
|
2024-10-18 07:53:00 +00:00
|
|
|
c: item.url,
|
2025-04-11 06:42:29 +00:00
|
|
|
d: index,
|
|
|
|
e: common_vendor.o(($event) => categorySort(item.id))
|
2024-10-18 07:53:00 +00:00
|
|
|
};
|
2025-04-11 06:42:29 +00:00
|
|
|
}),
|
|
|
|
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)
|
2024-10-18 07:53:00 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
2025-04-11 06:42:29 +00:00
|
|
|
my.createPage(_sfc_main);
|