Commit 81b7a05a authored by 柳 佳乐's avatar 柳 佳乐
Browse files

头版

parents
Pipeline #81 failed with stages
in 0 seconds
This diff is collapsed.
import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'
import store from './store'
Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.prototype.$axios = axios
new Vue({
render: h => h(App),
store
}).$mount('#app')
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
patientInfo: {
name: '柳佳乐',//姓名
age: 25,//年龄
gender: '',//性别
phone: '19955807499',//手机号
idCard: '341221200005067836',//身份证号
nativePlace: '',//籍贯
height: 165,//身高
weight: 55,//体重
bookingId: 1,//预约ID
bkBkTime:'2023-08-10 10:00:00',//预约时间
},
},
mutations: {
SET_PATIENT_INFO(state, payload) {
state.patientInfo = {...state.patientInfo, ...payload}
},
CLEAR_PATIENT_INFO(state) {
state.patientInfo = {
name: null,//姓名
age: null,//年龄
gender: null,//性别
phone: null,//手机号
idCard: null,//身份证号
nativePlace: null,//籍贯
height: null,//身高
weight: null,//体重
bookingId: null,//预约ID
bkBkTime:null,//预约时间
}
}
},
actions: {
updatePatientInfo({ commit }, patientData) {
commit('SET_PATIENT_INFO', patientData)
},
clearPatient({ commit }) {
commit('CLEAR_PATIENT_INFO')
}
},
getters: {
patientInfo: state => state.patientInfo,
username: (state) => {
let str = '';
state.patientInfo.name ? str += state.patientInfo.name : str+='null';//姓名
state.patientInfo.age ? str += state.patientInfo.age : str+='null';//年龄
state.patientInfo.gender ? str += state.patientInfo.gender : str+='null';//性别
state.patientInfo.phone ? str += state.patientInfo.phone : str+='null';//手机号
state.patientInfo.idCard ? str += state.patientInfo.idCard : str+='null';//身份证号
state.patientInfo.nativePlace ? str += state.patientInfo.nativePlace : str+='null';//籍贯
return str;
}
}
})
function pad(timeEl, total = 2, str = '0') {
return timeEl.toString().padStart(total, str)
}
export function timeProcessing(data) {
let timer
if(data){
timer = new Date(data)
}else{
timer = new Date()
}
const year = timer.getFullYear()
const month = timer.getMonth() + 1 // 由于月份从0开始,因此需加1
const day = timer.getDate()
const hour = timer.getHours()
const minute = timer.getMinutes()
const second = timer.getSeconds()
return `${pad(year, 4)}-${pad(month)}-${pad(day)} ${pad(hour)}:${pad(minute)}:${pad(second)}`
}
//开始时间
export function startTimeProcessing(data) {
let timer = new Date(data)
const year = timer.getFullYear()
const month = timer.getMonth() + 1 // 由于月份从0开始,因此需加1
const day = timer.getDate()
return `${pad(year, 4)}-${pad(month)}-${pad(day)} 00:00:00`
}
//结束时间
export function endTimeProcessing(data) {
let timer = new Date(data)
const year = timer.getFullYear()
const month = timer.getMonth() + 1 // 由于月份从0开始,因此需加1
const day = timer.getDate()
return `${pad(year, 4)}-${pad(month)}-${pad(day)} 59:59:59`
}
import axios from 'axios'
import { Loading, Message } from 'element-ui'
let loadingInstance = null
// 白名单路径 - 这些请求不会显示loading (使用正则表达式匹配关键部分)
const WHITE_LIST = [
/\/api\/cameras\/rgbd\/rgbd\/\d+\/current-frame/ // RGBD相机当前帧(带ID)
]
// 创建axios实例
const service = axios.create({
timeout: 10000
})
// 请求拦截器
service.interceptors.request.use(
config => {
// 检查请求是否匹配白名单中的任一正则
const isInWhiteList = WHITE_LIST.some(regex => regex.test(config.url))
// 不在白名单中的请求才显示loading
if (!isInWhiteList) {
loadingInstance = Loading.service({
lock: true,
text: '加载中...',
background: 'rgba(0, 0, 0, 0.7)'
})
}
return config
},
error => {
// 关闭loading
loadingInstance && loadingInstance.close()
return Promise.reject(error)
}
)
// 响应拦截器
service.interceptors.response.use(
response => {
loadingInstance && loadingInstance.close()
const res = response.data
console.log(res)
if(res.code == 200){
return res
}else{
Message.error(res.message)
console.log(res.message)
}
// 可在此根据业务状态码处理不同情况
// if (res.code !== 200) {
// Message.error(res.message || 'Error')
// return Promise.reject(new Error(res.message || 'Error'))
// }
return res
},
error => {
// 关闭loading
loadingInstance && loadingInstance.close()
// 可在此统一处理HTTP错误状态码
// Message.error(error.message)
return Promise.reject(error)
}
)
export default service
export const baseURL = '/api'
export const baseURLConsole ='192.168.0.103:8000'
\ No newline at end of file
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
devServer:{
client:{
overlay: false
}
}
})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment