处理用户登陆
This commit is contained in:
137
unpackage/dist/dev/mp-weixin/pages/index/index.js
vendored
137
unpackage/dist/dev/mp-weixin/pages/index/index.js
vendored
@@ -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
|
||||
})
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,83 +1,75 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const api_user = require("../../api/user.js");
|
||||
const utils_helper = require("../../utils/helper.js");
|
||||
const api_index = require("../../api/index.js");
|
||||
if (!Array) {
|
||||
const _easycom_nut_icon2 = common_vendor.resolveComponent("nut-icon");
|
||||
const _easycom_nut_avatar2 = common_vendor.resolveComponent("nut-avatar");
|
||||
const _easycom_nut_input2 = common_vendor.resolveComponent("nut-input");
|
||||
const _easycom_nut_button2 = common_vendor.resolveComponent("nut-button");
|
||||
(_easycom_nut_icon2 + _easycom_nut_avatar2 + _easycom_nut_button2)();
|
||||
(_easycom_nut_input2 + _easycom_nut_button2)();
|
||||
}
|
||||
const _easycom_nut_icon = () => "../../uni_modules/nutui-uni/components/icon/icon.js";
|
||||
const _easycom_nut_avatar = () => "../../uni_modules/nutui-uni/components/avatar/avatar.js";
|
||||
const _easycom_nut_input = () => "../../uni_modules/nutui-uni/components/input/input.js";
|
||||
const _easycom_nut_button = () => "../../uni_modules/nutui-uni/components/button/button.js";
|
||||
if (!Math) {
|
||||
(_easycom_nut_icon + _easycom_nut_avatar + _easycom_nut_button)();
|
||||
(_easycom_nut_input + _easycom_nut_button)();
|
||||
}
|
||||
const _sfc_main = {
|
||||
__name: "index",
|
||||
setup(__props) {
|
||||
const code = common_vendor.ref("");
|
||||
const redirect_url = common_vendor.ref("");
|
||||
common_vendor.onLoad((options) => {
|
||||
redirect_url.value = options.redirect_url;
|
||||
});
|
||||
common_vendor.onMounted(() => {
|
||||
common_vendor.index.login({
|
||||
provider: "weixin",
|
||||
success(res) {
|
||||
if (res.errMsg === "login:ok") {
|
||||
code.value = res.code;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
const getUserInfo = (res) => {
|
||||
if (code.value === "") {
|
||||
const username = common_vendor.ref("");
|
||||
const password = common_vendor.ref("");
|
||||
const handleLogin = () => {
|
||||
if (username.value === "") {
|
||||
common_vendor.index.showToast({
|
||||
icon: "none",
|
||||
title: "请稍后再试"
|
||||
title: "请输入用户名",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
api_user.login(code.value, JSON.stringify(res.detail.userInfo)).then((res2) => {
|
||||
common_vendor.index.__f__("log", "at pages/login/index.vue:63", res2);
|
||||
common_vendor.index.setStorageSync("token", res2.token);
|
||||
common_vendor.index.setStorageSync("uid", res2.user_id);
|
||||
if (res2.is_bind_phone) {
|
||||
utils_helper.navigateTo("/pages/login/phoneAuthorization");
|
||||
return;
|
||||
}
|
||||
if (password.value === "") {
|
||||
common_vendor.index.showToast({
|
||||
title: "授权成功",
|
||||
title: "请输入密码",
|
||||
icon: "none"
|
||||
});
|
||||
if (redirect_url.value !== "undefined") {
|
||||
utils_helper.navigateTo(redirect_url.value);
|
||||
} else {
|
||||
common_vendor.index.navigateBack();
|
||||
}
|
||||
return;
|
||||
}
|
||||
api_index.fetchLogin({
|
||||
user_name: username.value,
|
||||
password: password.value
|
||||
}).then((res) => {
|
||||
common_vendor.index.__f__("log", "at pages/login/index.vue:68", 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);
|
||||
common_vendor.index.showToast({
|
||||
title: "登录成功",
|
||||
icon: "success"
|
||||
});
|
||||
common_vendor.index.switchTab({
|
||||
url: "/pages/index/index"
|
||||
});
|
||||
});
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
a: common_vendor.p({
|
||||
size: "30",
|
||||
name: "my"
|
||||
}),
|
||||
a: common_vendor.o(($event) => username.value = $event),
|
||||
b: common_vendor.p({
|
||||
size: "80"
|
||||
placeholder: "请输入用户名",
|
||||
clearable: true,
|
||||
label: "用户名",
|
||||
modelValue: username.value
|
||||
}),
|
||||
c: common_vendor.o(getUserInfo),
|
||||
c: common_vendor.o(($event) => password.value = $event),
|
||||
d: common_vendor.p({
|
||||
type: "success",
|
||||
size: "large",
|
||||
["open-type"]: "getUserInfo"
|
||||
placeholder: "请输入密码",
|
||||
clearable: true,
|
||||
label: "密码",
|
||||
type: "password",
|
||||
modelValue: password.value
|
||||
}),
|
||||
e: common_vendor.o(($event) => common_vendor.unref(utils_helper.switchTab)("/pages/index/index")),
|
||||
e: common_vendor.o(handleLogin),
|
||||
f: common_vendor.p({
|
||||
type: "danger",
|
||||
size: "large"
|
||||
type: "primary",
|
||||
block: true
|
||||
})
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"navigationBarTitleText": "授权登录",
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "登陆",
|
||||
"usingComponents": {
|
||||
"nut-icon": "../../uni_modules/nutui-uni/components/icon/icon",
|
||||
"nut-avatar": "../../uni_modules/nutui-uni/components/avatar/avatar",
|
||||
"nut-input": "../../uni_modules/nutui-uni/components/input/input",
|
||||
"nut-button": "../../uni_modules/nutui-uni/components/button/button"
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
<view class="content data-v-d08ef7d4"><view class="avatar data-v-d08ef7d4"><nut-avatar wx:if="{{b}}" class="data-v-d08ef7d4" u-s="{{['d']}}" u-i="d08ef7d4-0" bind:__l="__l" u-p="{{b}}"><nut-icon wx:if="{{a}}" class="data-v-d08ef7d4" u-i="d08ef7d4-1,d08ef7d4-0" bind:__l="__l" u-p="{{a}}"/></nut-avatar></view><view class="divider data-v-d08ef7d4"></view></view><view class="tip-infos data-v-d08ef7d4"><text class="data-v-d08ef7d4">申请获取以下权限</text><text class="data-v-d08ef7d4">获得你的公开信息(昵称、头像等)</text></view><view class="authorize-btn-inner data-v-d08ef7d4"><nut-button wx:if="{{d}}" class="data-v-d08ef7d4" u-s="{{['d']}}" bindgetuserinfo="{{c}}" u-i="d08ef7d4-2" bind:__l="__l" u-p="{{d}}">授权登录</nut-button></view><view class="authorize-btn-inner data-v-d08ef7d4"><nut-button wx:if="{{f}}" class="data-v-d08ef7d4" u-s="{{['d']}}" bindclick="{{e}}" u-i="d08ef7d4-3" bind:__l="__l" u-p="{{f}}">暂不登录</nut-button></view>
|
||||
<view class="login-page data-v-d08ef7d4"><view class="login-title data-v-d08ef7d4"><text class="title-text data-v-d08ef7d4">用户登陆</text></view><view class="login-container data-v-d08ef7d4"><nut-input wx:if="{{b}}" class="login-input data-v-d08ef7d4" u-i="d08ef7d4-0" bind:__l="__l" bindupdateModelValue="{{a}}" u-p="{{b}}"></nut-input><nut-input wx:if="{{d}}" class="login-input data-v-d08ef7d4" u-i="d08ef7d4-1" bind:__l="__l" bindupdateModelValue="{{c}}" u-p="{{d}}"></nut-input><view class="data-v-d08ef7d4" style="padding-top:100rpx"><nut-button wx:if="{{f}}" class="data-v-d08ef7d4" u-s="{{['d']}}" bindclick="{{e}}" u-i="d08ef7d4-2" bind:__l="__l" u-p="{{f}}"> 登录 </nut-button></view></view></view>
|
||||
@@ -48,30 +48,25 @@
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.divider.data-v-d08ef7d4 {
|
||||
height: 1px;
|
||||
background: #eee;
|
||||
width: 100%;
|
||||
}
|
||||
.content.data-v-d08ef7d4 {
|
||||
.login-page.data-v-d08ef7d4 {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
padding: 25px 15px;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
.tip-infos.data-v-d08ef7d4 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
padding: 10px 25px;
|
||||
gap: 10px;
|
||||
height: 100vh;
|
||||
}
|
||||
.tip-infos text.data-v-d08ef7d4:nth-child(2) {
|
||||
font-size: 15px;
|
||||
color: #666;
|
||||
.login-title.data-v-d08ef7d4 {
|
||||
margin-top: 240rpx;
|
||||
margin-bottom: 40rpx;
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
.authorize-btn-inner.data-v-d08ef7d4 {
|
||||
padding: 15px;
|
||||
.title-text.data-v-d08ef7d4 {
|
||||
font-size: 36rpx;
|
||||
color: #ff6600;
|
||||
text-align: center;
|
||||
}
|
||||
.login-container.data-v-d08ef7d4 {
|
||||
width: 80%;
|
||||
padding: 40rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user