处理用户登陆

This commit is contained in:
2026-01-15 16:10:27 +08:00
parent 88c8a4517b
commit b04c263e49
37 changed files with 567 additions and 497 deletions

View File

@@ -23,6 +23,40 @@ if (!Math) {
const _sfc_main = {
__name: "index",
setup(__props) {
const isLoggedIn = common_vendor.ref(false);
const username = common_vendor.ref("");
const password = common_vendor.ref("");
const handleLogin = () => {
if (username.value === "") {
common_vendor.index.showToast({
title: "请输入用户名",
icon: "none"
});
return;
}
if (password.value === "") {
common_vendor.index.showToast({
title: "请输入密码",
icon: "none"
});
return;
}
api_index.fetchLogin({
user_name: username.value,
password: password.value
}).then((res) => {
common_vendor.index.__f__("log", "at pages/index/index.vue:151", res);
common_vendor.index.setStorageSync("token", res.token);
common_vendor.index.setStorageSync("uid", res.user.user_id);
common_vendor.index.setStorageSync("username", res.user.user_name);
common_vendor.index.setStorageSync("role", res.user.role.value);
isLoggedIn.value = true;
common_vendor.index.showToast({
title: "登录成功",
icon: "success"
});
});
};
const form = common_vendor.reactive({
room_id: 0,
tel: "",
@@ -50,19 +84,19 @@ const _sfc_main = {
};
const visibleInfoPopup = common_vendor.ref(false);
const onShowInfoPopup = (room) => {
common_vendor.index.__f__("log", "at pages/index/index.vue:138", "----", room);
common_vendor.index.__f__("log", "at pages/index/index.vue:204", "----", room);
Object.assign(tempRoom, room);
visibleInfoPopup.value = true;
};
const onCloseInfoPopup = () => {
Object.assign(tempRoom, {});
visibleInfoPopup.value = false;
common_vendor.index.__f__("log", "at pages/index/index.vue:145", "关闭");
common_vendor.index.__f__("log", "at pages/index/index.vue:211", "关闭");
};
const visiblePopup = common_vendor.ref(false);
const tempRoom = common_vendor.reactive({});
const onBooking = (room) => {
common_vendor.index.__f__("log", "at pages/index/index.vue:152", "----", room);
common_vendor.index.__f__("log", "at pages/index/index.vue:218", "----", room);
Object.assign(tempRoom, room);
form.room_id = room.id;
visiblePopup.value = true;
@@ -75,18 +109,18 @@ const _sfc_main = {
remarks: ""
});
visiblePopup.value = false;
common_vendor.index.__f__("log", "at pages/index/index.vue:165", "关闭");
common_vendor.index.__f__("log", "at pages/index/index.vue:231", "关闭");
};
const getRooms = () => {
common_vendor.index.__f__("log", "at pages/index/index.vue:171", "房间");
common_vendor.index.__f__("log", "at pages/index/index.vue:238", "房间");
api_index.fetchRooms().then((res) => {
common_vendor.index.__f__("log", "at pages/index/index.vue:173", res);
common_vendor.index.__f__("log", "at pages/index/index.vue:240", res);
rooms.value = res;
});
};
const onSubmit = () => {
api_index.fetchBooking(form).then((res) => {
common_vendor.index.__f__("log", "at pages/index/index.vue:181", res);
common_vendor.index.__f__("log", "at pages/index/index.vue:248", res);
common_vendor.index.showToast({
icon: "none",
title: "预约成功"
@@ -99,7 +133,7 @@ const _sfc_main = {
api_index.fetchUnBooking({
id: room.id
}).then((res) => {
common_vendor.index.__f__("log", "at pages/index/index.vue:195", res);
common_vendor.index.__f__("log", "at pages/index/index.vue:262", res);
common_vendor.index.showToast({
icon: "none",
title: "取消预约成功"
@@ -108,25 +142,39 @@ const _sfc_main = {
});
};
const init = () => {
common_vendor.index.__f__("log", "at pages/index/index.vue:205", "init");
common_vendor.index.__f__("log", "at pages/index/index.vue:272", "init");
common_vendor.index.hideTabBar();
checkLogin();
getRooms();
};
common_vendor.onShow(() => {
common_vendor.index.__f__("log", "at pages/index/index.vue:210", "onshow---");
common_vendor.index.__f__("log", "at pages/index/index.vue:279", "onshow---");
common_vendor.index.hideTabBar();
checkLogin();
getRooms();
});
const checkLogin = () => {
let token = common_vendor.index.getStorageSync("token");
common_vendor.index.__f__("log", "at pages/index/index.vue:288", "token", token);
if (token) {
common_vendor.index.showTabBar();
isLoggedIn.value = true;
}
};
common_vendor.onMounted(() => {
init();
});
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.o(($event) => common_vendor.unref(utils_helper.navigateTo)("/pages/index/goodsOrderAdd")),
b: common_vendor.p({
a: isLoggedIn.value
}, isLoggedIn.value ? common_vendor.e({
b: common_vendor.o(($event) => common_vendor.unref(utils_helper.navigateTo)("/pages/index/goodsOrderAdd")),
c: common_vendor.p({
type: "primary",
block: true
}),
c: common_vendor.s("top:0px"),
d: common_vendor.f(rooms.value, (room, index, i0) => {
d: common_vendor.s("top:0px"),
e: common_vendor.f(rooms.value, (room, index, i0) => {
return common_vendor.e({
a: common_vendor.t(room.room_name),
b: room.tel
@@ -183,32 +231,32 @@ const _sfc_main = {
y: common_vendor.s(getRoomStyle(room.status))
});
}),
e: common_vendor.t(tempRoom == null ? void 0 : tempRoom.room_name),
f: common_vendor.o(($event) => form.tel = $event),
g: common_vendor.p({
f: common_vendor.t(tempRoom == null ? void 0 : tempRoom.room_name),
g: common_vendor.o(($event) => form.tel = $event),
h: common_vendor.p({
placeholder: "请输入尾号",
modelValue: form.tel
}),
h: common_vendor.p({
i: common_vendor.p({
label: "尾号"
}),
i: common_vendor.o(($event) => form.remarks = $event),
j: common_vendor.p({
j: common_vendor.o(($event) => form.remarks = $event),
k: common_vendor.p({
rows: 3,
placeholder: "请输入备注",
modelValue: form.remarks
}),
k: common_vendor.p({
l: common_vendor.p({
label: "备注"
}),
l: common_vendor.o(onSubmit),
m: common_vendor.p({
m: common_vendor.o(onSubmit),
n: common_vendor.p({
type: "primary",
block: true
}),
n: common_vendor.o(onClosePopup),
o: common_vendor.o(($event) => visiblePopup.value = $event),
p: common_vendor.p({
o: common_vendor.o(onClosePopup),
p: common_vendor.o(($event) => visiblePopup.value = $event),
q: common_vendor.p({
["custom-style"]: {
height: "75%"
},
@@ -217,18 +265,18 @@ const _sfc_main = {
["close-on-click-overlay"]: true,
visible: visiblePopup.value
}),
q: common_vendor.t(tempRoom == null ? void 0 : tempRoom.room_name),
r: tempRoom == null ? void 0 : tempRoom.tel
r: common_vendor.t(tempRoom == null ? void 0 : tempRoom.room_name),
s: tempRoom == null ? void 0 : tempRoom.tel
}, (tempRoom == null ? void 0 : tempRoom.tel) ? {
s: common_vendor.t(tempRoom.tel)
t: common_vendor.t(tempRoom.tel)
} : {}, {
t: tempRoom == null ? void 0 : tempRoom.remarks
v: tempRoom == null ? void 0 : tempRoom.remarks
}, (tempRoom == null ? void 0 : tempRoom.remarks) ? {
v: common_vendor.t(tempRoom.remarks)
w: common_vendor.t(tempRoom.remarks)
} : {}, {
w: common_vendor.o(onCloseInfoPopup),
x: common_vendor.o(($event) => visibleInfoPopup.value = $event),
y: common_vendor.p({
x: common_vendor.o(onCloseInfoPopup),
y: common_vendor.o(($event) => visibleInfoPopup.value = $event),
z: common_vendor.p({
["custom-style"]: {
height: "50%"
},
@@ -237,6 +285,27 @@ const _sfc_main = {
["close-on-click-overlay"]: true,
visible: visibleInfoPopup.value
})
}) : {
A: common_vendor.o(($event) => username.value = $event),
B: common_vendor.p({
placeholder: "请输入用户名",
clearable: true,
label: "用户名",
modelValue: username.value
}),
C: common_vendor.o(($event) => password.value = $event),
D: common_vendor.p({
placeholder: "请输入密码",
clearable: true,
label: "密码",
type: "password",
modelValue: password.value
}),
E: common_vendor.o(handleLogin),
F: common_vendor.p({
type: "primary",
block: true
})
});
};
}