ykt-wxapp/pages/login/login.vue

146 lines
3.7 KiB
Vue
Raw Normal View History

2026-01-19 18:52:18 +08:00
<template>
2026-01-23 14:36:28 +08:00
<view class="pt-lg px-15 flex flex-col items-center text-center">
2026-01-20 10:49:33 +08:00
<image src="/static/logo-plain.png" class="logo"></image>
<view class="mt-15 text-xl font-semibold text-dark">柚健康</view>
<view class="mt-12 text-base text-dark">生命全周期健康管理伙伴</view>
</view>
<view class="login-btn-wrap">
2026-01-27 17:09:31 +08:00
<!-- <button v-if="checked" class="login-btn" type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
手机号快捷登录
</button> -->
<button v-if="checked" class="login-btn" type="primary" @click="getPhoneNumber()">
2026-01-20 10:49:33 +08:00
手机号快捷登录
</button>
<button v-else class="login-btn" type="primary" @click="remind()">
手机号快捷登录
</button>
</view>
2026-01-23 14:36:28 +08:00
<view class="flex items-center justify-center mt-12 px-15" @click="checked = !checked">
2026-01-20 10:49:33 +08:00
<checkbox :checked="checked" style="transform: scale(0.7)" />
<view class="text-sm text-gray">我已阅读并同意</view>
<view class="text-sm text-primary">用户协议</view>
<view class="text-sm text-primary">隐私政策</view>
</view>
2026-01-19 18:52:18 +08:00
</template>
<script setup>
2026-01-20 10:49:33 +08:00
import { ref } from "vue";
2026-01-23 14:36:28 +08:00
import { storeToRefs } from "pinia";
2026-01-19 18:52:18 +08:00
import { onLoad } from "@dcloudio/uni-app";
2026-01-20 10:49:33 +08:00
import useAccountStore from "@/store/account";
2026-01-19 18:52:18 +08:00
import { get } from "@/utils/cache";
2026-01-20 10:49:33 +08:00
import { toast } from "@/utils/widget";
2026-01-19 18:52:18 +08:00
2026-01-20 10:49:33 +08:00
const team = ref(true);
const checked = ref(false);
const redirectUrl = ref("");
2026-01-23 14:36:28 +08:00
const { doctorInfo } = storeToRefs(useAccountStore());
2026-01-19 18:52:18 +08:00
const { login } = useAccountStore();
function attempRedirect(url) {
2026-01-20 10:49:33 +08:00
return new Promise((resolve, reject) => {
uni.redirectTo({
url,
success: () => resolve(true),
fail: () => reject(false),
});
});
2026-01-19 18:52:18 +08:00
}
function attempSwitchTab(url) {
2026-01-20 10:49:33 +08:00
return new Promise((resolve, reject) => {
uni.switchTab({
url,
success: () => resolve(true),
fail: () => reject(false),
});
});
2026-01-19 18:52:18 +08:00
}
function remind() {
2026-01-20 10:49:33 +08:00
toast("请先阅读并同意用户协议和隐私政策");
2026-01-19 18:52:18 +08:00
}
function toHome() {
2026-01-23 14:36:28 +08:00
uni.switchTab({
url: "/pages/work/work",
2026-01-20 10:49:33 +08:00
});
2026-01-19 18:52:18 +08:00
}
async function getPhoneNumber(e) {
2026-01-20 10:49:33 +08:00
const phoneCode = e && e.detail && e.detail.code;
2026-01-27 17:09:31 +08:00
// if (e && !phoneCode) return;
2026-01-20 10:49:33 +08:00
const res = await login(phoneCode);
2026-01-27 17:09:31 +08:00
2026-01-20 10:49:33 +08:00
if (res && redirectUrl.value) {
await attempToPage(redirectUrl.value);
2026-01-23 16:17:59 +08:00
} else if (res && !(doctorInfo.value && doctorInfo.value.anotherName)) {
2026-01-23 14:36:28 +08:00
uni.redirectTo({
url: '/pages/work/profile'
})
2026-01-20 10:49:33 +08:00
} else if (res) {
toHome();
}
2026-01-19 18:52:18 +08:00
}
async function attempToPage(url) {
2026-01-20 10:49:33 +08:00
const res1 = attempRedirect(url);
if (res1) return;
const res2 = attempSwitchTab(url);
if (res2) return;
toHome();
2026-01-19 18:52:18 +08:00
}
2026-01-20 10:49:33 +08:00
onLoad((opts) => {
if (opts.source === "teamInvite") {
team.value = get("invite-team-info");
redirectUrl.value = `/pages/archive/edit-archive?teamId=${team.value.teamId}&corpId=${team.value.corpId}`;
return;
}
2026-01-20 16:30:03 +08:00
if (opts.redirect) {
redirectUrl.value = decodeURIComponent(opts.redirect);
} else {
redirectUrl.value = opts.redirectUrl || "";
}
2026-01-20 10:49:33 +08:00
});
2026-01-19 18:52:18 +08:00
</script>
<style scoped>
.pt-lg {
2026-01-20 10:49:33 +08:00
padding-top: 20vh;
2026-01-19 18:52:18 +08:00
}
.logo {
2026-01-20 10:49:33 +08:00
width: 160rpx;
height: 160rpx;
2026-01-19 18:52:18 +08:00
}
.login-btn-wrap {
2026-01-20 10:49:33 +08:00
width: 100vw;
display: flex;
justify-content: center;
margin-top: 80rpx;
2026-01-19 18:52:18 +08:00
}
.login-btn-wrap-loading {
2026-01-20 10:49:33 +08:00
pointer-events: none;
2026-01-19 18:52:18 +08:00
}
.login-btn {
2026-01-20 10:49:33 +08:00
width: calc(100vw - 112rpx);
max-width: 600rpx;
height: 80rpx;
line-height: 80rpx;
background: linear-gradient(270deg, #1b5cc8 2.26%, #0877f1 94.33%);
color: #fff;
font-size: 30rpx;
border-radius: 48rpx;
font-weight: 600;
box-shadow: 0 4rpx 16rpx rgba(59, 124, 255, 0.08);
border: none;
2026-01-19 18:52:18 +08:00
}
.login-btn:active {
2026-01-20 10:49:33 +08:00
background: linear-gradient(270deg, #1b5cc8 2.26%, #0877f1 94.33%);
2026-01-19 18:52:18 +08:00
}
</style>