处理用户登陆

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
})
});
};
}

View File

@@ -1 +1 @@
<view class="page-content data-v-1cf27b2a"><view class="data-v-1cf27b2a" style="{{'z-index:10000;position:sticky' + ';' + c}}"><view class="top-bar data-v-1cf27b2a"><nut-button wx:if="{{b}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{a}}" u-i="1cf27b2a-0" bind:__l="__l" u-p="{{b}}"> 新增商品订单 </nut-button></view></view><view class="room-grid data-v-1cf27b2a"><view wx:for="{{d}}" wx:for-item="room" wx:key="x" class="room-grid-item data-v-1cf27b2a" style="{{room.y}}"><view class="room-grid-card data-v-1cf27b2a"><view class="grid-item-content data-v-1cf27b2a"><view class="room-name data-v-1cf27b2a">{{room.a}}</view><view class="room-info data-v-1cf27b2a"><view wx:if="{{room.b}}" class="room-id data-v-1cf27b2a" bindtap="{{room.d}}">尾号: {{room.c}}</view><view wx:if="{{room.e}}" class="remark data-v-1cf27b2a" bindtap="{{room.g}}">备注: {{room.f}}</view></view><view class="room-buttons data-v-1cf27b2a"><view wx:if="{{room.h}}" class="data-v-1cf27b2a"><nut-button wx:if="{{room.k}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{room.i}}" u-i="{{room.j}}" bind:__l="__l" u-p="{{room.k}}">预约</nut-button></view><view wx:elif="{{room.l}}" class="data-v-1cf27b2a"><nut-button wx:if="{{room.o}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{room.m}}" u-i="{{room.n}}" bind:__l="__l" u-p="{{room.o}}">取消预约</nut-button></view><view wx:if="{{room.p}}" class="data-v-1cf27b2a"><nut-button wx:if="{{room.s}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{room.q}}" u-i="{{room.r}}" bind:__l="__l" u-p="{{room.s}}">详情</nut-button></view><view wx:else class="data-v-1cf27b2a"><nut-button wx:if="{{room.w}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{room.t}}" u-i="{{room.v}}" bind:__l="__l" u-p="{{room.w}}">开台</nut-button></view></view></view></view></view></view><nut-popup wx:if="{{p}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclose="{{n}}" u-i="1cf27b2a-5" bind:__l="__l" bindupdateVisible="{{o}}" u-p="{{p}}"><view class="data-v-1cf27b2a"><view class="title data-v-1cf27b2a">{{e}}</view><nut-form class="data-v-1cf27b2a" u-s="{{['d']}}" u-i="1cf27b2a-6,1cf27b2a-5" bind:__l="__l"><nut-form-item wx:if="{{h}}" class="data-v-1cf27b2a" u-s="{{['d']}}" u-i="1cf27b2a-7,1cf27b2a-6" bind:__l="__l" u-p="{{h}}"><nut-input wx:if="{{g}}" class="data-v-1cf27b2a" u-i="1cf27b2a-8,1cf27b2a-7" bind:__l="__l" bindupdateModelValue="{{f}}" u-p="{{g}}"></nut-input></nut-form-item><nut-form-item wx:if="{{k}}" class="data-v-1cf27b2a" u-s="{{['d']}}" u-i="1cf27b2a-9,1cf27b2a-6" bind:__l="__l" u-p="{{k}}"><nut-textarea wx:if="{{j}}" class="data-v-1cf27b2a" u-i="1cf27b2a-10,1cf27b2a-9" bind:__l="__l" bindupdateModelValue="{{i}}" u-p="{{j}}"></nut-textarea></nut-form-item></nut-form><view class="data-v-1cf27b2a" style="padding:0rpx 80rpx"><nut-button wx:if="{{m}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{l}}" u-i="1cf27b2a-11,1cf27b2a-5" bind:__l="__l" u-p="{{m}}"> 预约 </nut-button></view></view></nut-popup><nut-popup wx:if="{{y}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclose="{{w}}" u-i="1cf27b2a-12" bind:__l="__l" bindupdateVisible="{{x}}" u-p="{{y}}"><view class="data-v-1cf27b2a"><view class="title data-v-1cf27b2a">{{q}}</view><view class="room-info data-v-1cf27b2a"><view wx:if="{{r}}" class="room-id data-v-1cf27b2a">尾号: {{s}}</view><view wx:if="{{t}}" class="remark data-v-1cf27b2a">备注: {{v}}</view></view></view></nut-popup></view>
<view wx:if="{{a}}" class="page-content data-v-1cf27b2a"><view class="data-v-1cf27b2a" style="{{'z-index:10000;position:sticky' + ';' + d}}"><view class="top-bar data-v-1cf27b2a"><nut-button wx:if="{{c}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{b}}" u-i="1cf27b2a-0" bind:__l="__l" u-p="{{c}}"> 新增商品订单 </nut-button></view></view><view class="room-grid data-v-1cf27b2a"><view wx:for="{{e}}" wx:for-item="room" wx:key="x" class="room-grid-item data-v-1cf27b2a" style="{{room.y}}"><view class="room-grid-card data-v-1cf27b2a"><view class="grid-item-content data-v-1cf27b2a"><view class="room-name data-v-1cf27b2a">{{room.a}}</view><view class="room-info data-v-1cf27b2a"><view wx:if="{{room.b}}" class="room-id data-v-1cf27b2a" bindtap="{{room.d}}">尾号: {{room.c}}</view><view wx:if="{{room.e}}" class="remark data-v-1cf27b2a" bindtap="{{room.g}}">备注: {{room.f}}</view></view><view class="room-buttons data-v-1cf27b2a"><view wx:if="{{room.h}}" class="data-v-1cf27b2a"><nut-button wx:if="{{room.k}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{room.i}}" u-i="{{room.j}}" bind:__l="__l" u-p="{{room.k}}">预约</nut-button></view><view wx:elif="{{room.l}}" class="data-v-1cf27b2a"><nut-button wx:if="{{room.o}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{room.m}}" u-i="{{room.n}}" bind:__l="__l" u-p="{{room.o}}">取消预约</nut-button></view><view wx:if="{{room.p}}" class="data-v-1cf27b2a"><nut-button wx:if="{{room.s}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{room.q}}" u-i="{{room.r}}" bind:__l="__l" u-p="{{room.s}}">详情</nut-button></view><view wx:else class="data-v-1cf27b2a"><nut-button wx:if="{{room.w}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{room.t}}" u-i="{{room.v}}" bind:__l="__l" u-p="{{room.w}}">开台</nut-button></view></view></view></view></view></view><nut-popup wx:if="{{q}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclose="{{o}}" u-i="1cf27b2a-5" bind:__l="__l" bindupdateVisible="{{p}}" u-p="{{q}}"><view class="data-v-1cf27b2a"><view class="title data-v-1cf27b2a">{{f}}</view><nut-form class="data-v-1cf27b2a" u-s="{{['d']}}" u-i="1cf27b2a-6,1cf27b2a-5" bind:__l="__l"><nut-form-item wx:if="{{i}}" class="data-v-1cf27b2a" u-s="{{['d']}}" u-i="1cf27b2a-7,1cf27b2a-6" bind:__l="__l" u-p="{{i}}"><nut-input wx:if="{{h}}" class="data-v-1cf27b2a" u-i="1cf27b2a-8,1cf27b2a-7" bind:__l="__l" bindupdateModelValue="{{g}}" u-p="{{h}}"></nut-input></nut-form-item><nut-form-item wx:if="{{l}}" class="data-v-1cf27b2a" u-s="{{['d']}}" u-i="1cf27b2a-9,1cf27b2a-6" bind:__l="__l" u-p="{{l}}"><nut-textarea wx:if="{{k}}" class="data-v-1cf27b2a" u-i="1cf27b2a-10,1cf27b2a-9" bind:__l="__l" bindupdateModelValue="{{j}}" u-p="{{k}}"></nut-textarea></nut-form-item></nut-form><view class="data-v-1cf27b2a" style="padding:0rpx 80rpx"><nut-button wx:if="{{n}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{m}}" u-i="1cf27b2a-11,1cf27b2a-5" bind:__l="__l" u-p="{{n}}"> 预约 </nut-button></view></view></nut-popup><nut-popup wx:if="{{z}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclose="{{x}}" u-i="1cf27b2a-12" bind:__l="__l" bindupdateVisible="{{y}}" u-p="{{z}}"><view class="data-v-1cf27b2a"><view class="title data-v-1cf27b2a">{{r}}</view><view class="room-info data-v-1cf27b2a"><view wx:if="{{s}}" class="room-id data-v-1cf27b2a">尾号: {{t}}</view><view wx:if="{{v}}" class="remark data-v-1cf27b2a">备注: {{w}}</view></view></view></nut-popup></view><view wx:else class="login-page data-v-1cf27b2a"><view class="login-title data-v-1cf27b2a"><text class="title-text data-v-1cf27b2a">用户登陆</text></view><view class="login-container data-v-1cf27b2a"><nut-input wx:if="{{B}}" class="login-input data-v-1cf27b2a" u-i="1cf27b2a-13" bind:__l="__l" bindupdateModelValue="{{A}}" u-p="{{B}}"></nut-input><nut-input wx:if="{{D}}" class="login-input data-v-1cf27b2a" u-i="1cf27b2a-14" bind:__l="__l" bindupdateModelValue="{{C}}" u-p="{{D}}"></nut-input><view class="data-v-1cf27b2a" style="padding-top:100rpx"><nut-button wx:if="{{F}}" class="data-v-1cf27b2a" u-s="{{['d']}}" bindclick="{{E}}" u-i="1cf27b2a-15" bind:__l="__l" u-p="{{F}}"> 登录 </nut-button></view></view></view>

View File

@@ -143,4 +143,26 @@
}
.room-info .remark.data-v-1cf27b2a {
font-size: 26rpx;
}
.login-page.data-v-1cf27b2a {
display: flex;
align-items: center;
flex-direction: column;
height: 100vh;
}
.login-title.data-v-1cf27b2a {
margin-top: 240rpx;
margin-bottom: 40rpx;
font-size: 32rpx;
color: #333;
font-weight: bold;
}
.title-text.data-v-1cf27b2a {
font-size: 36rpx;
color: #ff6600;
text-align: center;
}
.login-container.data-v-1cf27b2a {
width: 80%;
padding: 40rpx;
}