请求地址更换

This commit is contained in:
BianLzhaoMin 2024-10-21 09:24:11 +08:00
parent d28034fbf4
commit e388221252
5 changed files with 168 additions and 7 deletions

View File

@ -1,4 +1,5 @@
import request from '@/utils/request_new'
import request_yn from '@/utils/request_new_yn'
// 获取首页数据
export function getHomePageListApi(data) {
@ -18,7 +19,7 @@ export function getHomePageSelectApi() {
}
// 首页二级页面--作业计划详情-作业计划列表
export function getWorkPlanDetailsApi(data) {
return request({
return request_yn({
url: '/ynPlan/home/getjhxxq',
method: 'post',
data
@ -26,7 +27,7 @@ export function getWorkPlanDetailsApi(data) {
}
// 首页二级页面--作业计划详情-作业人员及持证信息
export function getWorkPersonnelApi(data) {
return request({
return request_yn({
url: '/ynPlan/home/getDayUser',
method: 'post',
data
@ -34,7 +35,7 @@ export function getWorkPersonnelApi(data) {
}
// 首页二级页面--作业计划详情-作业票、站班会照片
export function getStandGuardImgApi(data) {
return request({
return request_yn({
url: '/ynPlan/home/getZbhPhotos',
method: 'post',
data
@ -42,7 +43,7 @@ export function getStandGuardImgApi(data) {
}
// 首页二级页面--作业计划详情-持证信息详情
export function getHoldCardInfoApi(data) {
return request({
return request_yn({
url: '/ynPlan/home/getDayUserCZ',
method: 'post',
data

View File

@ -26,6 +26,8 @@ module.exports = {
realBmwUrl: 'http://192.168.0.14:1911/bmw',
//实名制移动端 -- 新
realNewBmwUrl: 'http://192.168.0.14:1911',
//实名制移动端 -- 新
realNewYnUrl: 'http://192.168.0.14:1918',
// 应用信息
appInfo: {

View File

@ -225,7 +225,7 @@ export default {
const response = await getStandGuardImgApi(params)
this.workPersonList = res.data
console.log('人员信息---', res.data)
console.log('人员信息---', res)
this.holdCardList = res.datac
this.standGuardList = response.data

View File

@ -18,10 +18,19 @@
class="uni-calendar--hook"
:range="true"
:showMonth="false"
:selected="info.selected"
@change="change"
@monthSwitch="monthSwitch"
/>
>
<template v-slot:day="{ date, lunar, extraInfo }">
<view class="custom-day">
<text class="day-number">{{ date.day }}</text>
<text v-if="extraInfo" class="custom-info" :class="getInfoClass(extraInfo)">
{{ extraInfo }}
</text>
<!-- <view v-if="hasEvent(date)" class="event-dot"></view> -->
</view>
</template>
</uni-calendar>
</view>
</view>
</template>
@ -38,10 +47,35 @@ export default {
range: true,
insert: false,
selected: []
},
customInfo: {
'2024-10-01': '重要',
'2024-10-15': '假期'
},
events: {
'2024-10-01': { type: 'important', text: '重要' },
'2024-10-15': { type: 'holiday', text: '假期' },
'2024-10-20': { type: 'birthday', text: '生日' }
}
}
},
methods: {
onChange(e) {
console.log('选择的日期变化:', e)
},
onMonthSwitch(e) {
console.log('月份切换:', e)
},
hasEvent(date) {
const dateString = `${date.year}-${String(date.month).padStart(2, '0')}-${String(date.day).padStart(2, '0')}`
return !!this.events[dateString]
},
getInfoClass(info) {
if (info === '重要') return 'info-important'
if (info === '假期') return 'info-holiday'
if (info === '生日') return 'info-birthday'
return ''
},
change() {
console.log('日期变化---')
},
@ -89,4 +123,43 @@ export default {
display: flex;
align-items: center;
}
.custom-day {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
position: relative;
}
.day-number {
font-size: 14px;
}
.custom-info {
font-size: 10px;
margin-top: 2px;
}
.info-important {
color: #ff4d4f;
}
.info-holiday {
color: #52c41a;
}
.info-birthday {
color: #1890ff;
}
.event-dot {
width: 4px;
height: 4px;
border-radius: 50%;
background-color: #1890ff;
position: absolute;
bottom: 2px;
}
</style>

85
utils/request_new_yn.js Normal file
View File

@ -0,0 +1,85 @@
import store from '@/store'
import config from '@/config'
import { getToken, setToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import { toast, showConfirm, tansParams } from '@/utils/common'
let timeout = 60000
const baseUrl = config.realNewYnUrl
console.log('baseUrl-请求', baseUrl)
const request = config => {
// 是否需要设置 token
const isToken = (config.headers || {}).isToken === false
config.header = config.header || {}
if (getToken() && !isToken) {
config.header['Authorization'] = 'Bearer ' + getToken()
}
// get请求映射params参数
if (config.params) {
let url = config.url + '?' + tansParams(config.params)
url = url.slice(0, -1)
config.url = url
}
if (config.method === 'post') {
config.header = {
...config.header,
'Content-Type': 'application/x-www-form-urlencoded'
}
// config.data = JSON.stringify(config.data);
}
return new Promise((resolve, reject) => {
uni
.request({
method: config.method || 'get',
timeout: config.timeout || timeout,
url: baseUrl + config.url,
data: config.data,
header: config.header,
dataType: 'json'
})
.then(response => {
// console.log(response)
let [error, res] = response
if (error) {
toast('后端接口连接异常')
reject('后端接口连接异常')
return
}
const code = res.data.code || 200
const msg = errorCode[code] || res.data.msg || errorCode['default']
if (code === 401) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
store.dispatch('LogOut').then(res => {
uni.reLaunch({ url: '/pages/login' })
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) {
toast(msg)
reject(msg)
} else if (code !== 200) {
toast(msg)
reject(msg)
}
resolve(res.data)
})
.catch(error => {
let { message } = error
if (message === 'Network Error') {
message = '后端接口连接异常'
} else if (message.includes('timeout')) {
message = '系统接口请求超时'
} else if (message.includes('Request failed with status code')) {
message = '系统接口' + message.substr(message.length - 3) + '异常'
}
toast(message)
reject(error)
})
})
}
export default request