更新h5
parent
7d8fd2bbfe
commit
81cfd72096
@ -0,0 +1,18 @@
|
||||
const env = process.env.NODE_ENV || 'development'
|
||||
|
||||
const config = {
|
||||
development: {
|
||||
baseUrl: 'http://yiji-qhdzhongyiyuan'
|
||||
},
|
||||
production: {
|
||||
baseUrl: 'http://192.168.80.76'
|
||||
}
|
||||
}
|
||||
|
||||
export const getBaseUrl = () => {
|
||||
return config[env]?.baseUrl || config.development.baseUrl
|
||||
}
|
||||
|
||||
export default {
|
||||
getBaseUrl
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,40 +1,302 @@
|
||||
<template>
|
||||
<view class="LoginMain">
|
||||
<view style="padding-top: 30%;">
|
||||
<uni-easyinput type="text" v-model="regnum" placeholder="请输入患者id" />
|
||||
<button style="margin-top: 20rpx;background-color: #33cdc9;color: #fff;" @click="LoginFunc()">登 录</button>
|
||||
<view class="login-page">
|
||||
<view class="login-header">
|
||||
<view class="header-bg"></view>
|
||||
<view class="hospital-logo">
|
||||
<view class="logo-icon">
|
||||
<text class="icon-hospital">+</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="hospital-info">
|
||||
<text class="hospital-name">秦皇岛中医院</text>
|
||||
<text class="hospital-subtitle">医技预约系统</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="login-content">
|
||||
<view class="welcome-section">
|
||||
<text class="welcome-title">欢迎使用</text>
|
||||
<text class="welcome-desc">请输入患者登记号进行登录</text>
|
||||
</view>
|
||||
|
||||
<view class="login-form">
|
||||
<view class="form-item">
|
||||
<view class="input-wrapper">
|
||||
<uni-icons type="person" size="20" color="#2E7D32"></uni-icons>
|
||||
<input
|
||||
class="input-field"
|
||||
type="text"
|
||||
v-model="regnum"
|
||||
placeholder="请输入患者登记号"
|
||||
placeholder-class="placeholder-text"
|
||||
@confirm="LoginFunc"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="login-tips">
|
||||
<uni-icons type="info" size="14" color="#999"></uni-icons>
|
||||
<text class="tips-text">登记号可在就诊卡或挂号单上找到</text>
|
||||
</view>
|
||||
|
||||
<button class="login-btn" :disabled="regnum === ''" @click="LoginFunc()">
|
||||
<text v-if="!loading">登 录</text>
|
||||
<text v-else>登录中...</text>
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view class="login-footer">
|
||||
<view class="footer-item">
|
||||
<uni-icons type="medal" size="16" color="#2E7D32"></uni-icons>
|
||||
<text>三甲医院</text>
|
||||
</view>
|
||||
<view class="footer-divider"></view>
|
||||
<view class="footer-item">
|
||||
<uni-icons type="heart" size="16" color="#2E7D32"></uni-icons>
|
||||
<text>用心服务</text>
|
||||
</view>
|
||||
<view class="footer-divider"></view>
|
||||
<view class="footer-item">
|
||||
<uni-icons type="staff" size="16" color="#2E7D32"></uni-icons>
|
||||
<text>专业医疗</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import{ref,onMounted} from "vue"
|
||||
import {Login} from "@/api"
|
||||
import {onLoad} from "@dcloudio/uni-app"
|
||||
let regnum=ref('');
|
||||
const LoginFunc=()=> {
|
||||
if(regnum.value==''){
|
||||
import { ref, onMounted } from "vue"
|
||||
import { Login } from "@/api"
|
||||
import { onLoad } from "@dcloudio/uni-app"
|
||||
|
||||
let regnum = ref('');
|
||||
let loading = ref(false);
|
||||
|
||||
const LoginFunc = () => {
|
||||
if (regnum.value === '') {
|
||||
uni.showToast({
|
||||
title: '请输入患者登记号',
|
||||
icon: 'none'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
Login({regnum:regnum.value}).then(res => {
|
||||
console.log(res)
|
||||
if(res.status){
|
||||
sessionStorage.setItem("access_token",res.data.token)
|
||||
sessionStorage.setItem("refresh_token",res.data.refresh_token)
|
||||
uni.reLaunch({
|
||||
url: '/pages/CheckItemMainList'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
loading.value = true;
|
||||
|
||||
Login({ regnum: regnum.value }).then(res => {
|
||||
loading.value = false;
|
||||
if (res.status) {
|
||||
uni.setStorageSync("access_token", res.data.token);
|
||||
uni.setStorageSync("refresh_token", res.data.refresh_token);
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/CheckItemMainList'
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
}).catch(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
onMounted(()=>{
|
||||
//LoginFunc()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
const token = uni.getStorageSync("access_token");
|
||||
if (token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/CheckItemMainList'
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.LoginMain{
|
||||
padding: 20rpx;
|
||||
<style lang="scss" scoped>
|
||||
.login-page {
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(180deg, #F5F7FA 0%, #FFFFFF 100%);
|
||||
}
|
||||
|
||||
.login-header {
|
||||
position: relative;
|
||||
padding: 80rpx 40rpx 60rpx;
|
||||
text-align: center;
|
||||
|
||||
.header-bg {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 280rpx;
|
||||
background: linear-gradient(135deg, #2E7D32 0%, #4CAF50 50%, #81C784 100%);
|
||||
border-radius: 0 0 60rpx 60rpx;
|
||||
}
|
||||
|
||||
.hospital-logo {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
margin-bottom: 24rpx;
|
||||
|
||||
.logo-icon {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
background: #FFFFFF;
|
||||
border-radius: 50%;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 8rpx 32rpx rgba(46, 125, 50, 0.3);
|
||||
|
||||
.icon-hospital {
|
||||
font-size: 60rpx;
|
||||
font-weight: bold;
|
||||
color: #2E7D32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.hospital-info {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
|
||||
.hospital-name {
|
||||
display: block;
|
||||
font-size: 40rpx;
|
||||
font-weight: 600;
|
||||
color: #FFFFFF;
|
||||
letter-spacing: 4rpx;
|
||||
text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.hospital-subtitle {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.login-content {
|
||||
padding: 40rpx 48rpx;
|
||||
|
||||
.welcome-section {
|
||||
text-align: center;
|
||||
margin-bottom: 60rpx;
|
||||
|
||||
.welcome-title {
|
||||
display: block;
|
||||
font-size: 44rpx;
|
||||
font-weight: 600;
|
||||
color: #333333;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.welcome-desc {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
|
||||
.login-form {
|
||||
.form-item {
|
||||
margin-bottom: 24rpx;
|
||||
|
||||
.input-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #FFFFFF;
|
||||
border: 2rpx solid #E8E8E8;
|
||||
border-radius: 24rpx;
|
||||
padding: 0 32rpx;
|
||||
height: 100rpx;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:focus-within {
|
||||
border-color: #2E7D32;
|
||||
box-shadow: 0 0 0 4rpx rgba(46, 125, 50, 0.1);
|
||||
}
|
||||
|
||||
.input-field {
|
||||
flex: 1;
|
||||
font-size: 32rpx;
|
||||
color: #333333;
|
||||
margin-left: 16rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.login-tips {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 32rpx 0;
|
||||
|
||||
.tips-text {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
margin-left: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
background: linear-gradient(135deg, #2E7D32 0%, #4CAF50 100%);
|
||||
border-radius: 24rpx;
|
||||
font-size: 34rpx;
|
||||
font-weight: 500;
|
||||
color: #FFFFFF;
|
||||
border: none;
|
||||
letter-spacing: 8rpx;
|
||||
box-shadow: 0 8rpx 24rpx rgba(46, 125, 50, 0.3);
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
background: #CCCCCC;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.login-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 80rpx;
|
||||
padding: 40rpx 0;
|
||||
|
||||
.footer-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
|
||||
text {
|
||||
margin-left: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.footer-divider {
|
||||
width: 2rpx;
|
||||
height: 24rpx;
|
||||
background: #E0E0E0;
|
||||
margin: 0 24rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.placeholder-text {
|
||||
color: #CCCCCC;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,86 @@
|
||||
$primary-color: #2E7D32;
|
||||
$primary-light: #4CAF50;
|
||||
$primary-dark: #1B5E20;
|
||||
$secondary-color: #1976D2;
|
||||
$warning-color: #FF9800;
|
||||
$danger-color: #F44336;
|
||||
$success-color: #4CAF50;
|
||||
$info-color: #2196F3;
|
||||
|
||||
$text-primary: #333333;
|
||||
$text-secondary: #666666;
|
||||
$text-hint: #999999;
|
||||
$text-white: #FFFFFF;
|
||||
|
||||
$bg-primary: #F5F7FA;
|
||||
$bg-card: #FFFFFF;
|
||||
$bg-header: linear-gradient(135deg, $primary-color 0%, $primary-light 100%);
|
||||
|
||||
$border-radius: 16rpx;
|
||||
$border-radius-lg: 24rpx;
|
||||
$border-radius-xl: 32rpx;
|
||||
|
||||
$shadow-sm: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
|
||||
$shadow-md: 0 4rpx 16rpx rgba(0, 0, 0, 0.12);
|
||||
$shadow-lg: 0 8rpx 24rpx rgba(0, 0, 0, 0.16);
|
||||
|
||||
$spacing-xs: 8rpx;
|
||||
$spacing-sm: 16rpx;
|
||||
$spacing-md: 24rpx;
|
||||
$spacing-lg: 32rpx;
|
||||
$spacing-xl: 48rpx;
|
||||
|
||||
@mixin card-style {
|
||||
background-color: $bg-card;
|
||||
border-radius: $border-radius-lg;
|
||||
box-shadow: $shadow-sm;
|
||||
}
|
||||
|
||||
@mixin button-primary {
|
||||
background: linear-gradient(135deg, $primary-color 0%, $primary-light 100%);
|
||||
color: $text-white;
|
||||
border-radius: $border-radius-lg;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:active {
|
||||
opacity: 0.9;
|
||||
transform: scale(0.98);
|
||||
}
|
||||
}
|
||||
|
||||
@mixin button-secondary {
|
||||
background: linear-gradient(135deg, $secondary-color 0%, #42A5F5 100%);
|
||||
color: $text-white;
|
||||
border-radius: $border-radius-lg;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
@mixin button-danger {
|
||||
background: linear-gradient(135deg, $danger-color 0%, #EF5350 100%);
|
||||
color: $text-white;
|
||||
border-radius: $border-radius-lg;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@mixin status-badge($color) {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 500;
|
||||
background-color: rgba($color, 0.1);
|
||||
color: $color;
|
||||
}
|
||||
|
||||
@mixin page-container {
|
||||
min-height: 100vh;
|
||||
background-color: $bg-primary;
|
||||
}
|
||||
|
||||
@mixin header-gradient {
|
||||
background: $bg-header;
|
||||
border-radius: 0 0 48rpx 48rpx;
|
||||
}
|
||||
@ -1,78 +1,88 @@
|
||||
// http.js
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
// 封装请求拦截器
|
||||
function requestInterceptor(options) {
|
||||
const token = uni.getStorageSync("access_token");
|
||||
|
||||
// 在请求发送之前做一些处理
|
||||
// 比如添加请求头、修改请求参数等
|
||||
options.header = {
|
||||
'Authorization': 'Bearer ' + sessionStorage.getItem("access_token"), // 假设需要添加 token
|
||||
'Content-Type': 'application/json' // 设置请求头
|
||||
};
|
||||
return options;
|
||||
options.header = {
|
||||
'Authorization': token ? 'Bearer ' + token : '',
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
return options;
|
||||
}
|
||||
|
||||
// 封装响应拦截器
|
||||
function responseInterceptor(response) {
|
||||
// 对响应数据进行处理
|
||||
// 比如根据响应状态码进行不同的操作
|
||||
if (response.statusCode === 200) {
|
||||
// 请求成功
|
||||
if(response.data.status==false){
|
||||
uni.showToast({
|
||||
title: response.data.msg ,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
return response.data;
|
||||
} else {
|
||||
// 请求失败
|
||||
uni.showToast({
|
||||
title: '请求失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
return Promise.reject(response.data);
|
||||
}
|
||||
if (response.statusCode === 200) {
|
||||
const data = response.data;
|
||||
|
||||
if (data.status === 'Toke_Error' || data.code === 10001) {
|
||||
uni.removeStorageSync("access_token");
|
||||
uni.removeStorageSync("refresh_token");
|
||||
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '登录已过期,请重新登录',
|
||||
showCancel: false,
|
||||
success: () => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/Login'
|
||||
});
|
||||
}
|
||||
});
|
||||
return Promise.reject(data);
|
||||
}
|
||||
|
||||
if (data.status === false) {
|
||||
uni.showToast({
|
||||
title: data.msg || data.meg || '操作失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '请求失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
return Promise.reject(response.data);
|
||||
}
|
||||
}
|
||||
|
||||
// 发送请求的方法,内部使用拦截器
|
||||
export function useHttp() {
|
||||
const isLoading = ref(false);
|
||||
const isLoading = ref(false);
|
||||
|
||||
function sendRequest(options) {
|
||||
isLoading.value = true;
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
});
|
||||
// 请求发送之前,先经过请求拦截器处理
|
||||
let processedOptions = requestInterceptor(options);
|
||||
function sendRequest(options) {
|
||||
isLoading.value = true;
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
});
|
||||
|
||||
let processedOptions = requestInterceptor(options);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
...processedOptions,
|
||||
success: (res) => {
|
||||
let processedResponse = responseInterceptor(res);
|
||||
isLoading.value = false;
|
||||
uni.hideLoading();
|
||||
resolve(processedResponse);
|
||||
},
|
||||
fail: (err) => {
|
||||
isLoading.value = false;
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '网络异常,请检查网络',
|
||||
icon: 'none'
|
||||
});
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
...processedOptions,
|
||||
success: (res) => {
|
||||
// 请求成功后,经过响应拦截器处理
|
||||
let processedResponse = responseInterceptor(res);
|
||||
isLoading.value = false;
|
||||
uni.hideLoading();
|
||||
resolve(processedResponse);
|
||||
},
|
||||
fail: (err) => {
|
||||
// 请求失败
|
||||
isLoading.value = false;
|
||||
uni.hideLoading();
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
isLoading,
|
||||
sendRequest
|
||||
};
|
||||
return {
|
||||
isLoading,
|
||||
sendRequest
|
||||
};
|
||||
}
|
||||
Loading…
Reference in New Issue