feat
This commit is contained in:
parent
b58fe9df30
commit
32c3cd8936
4
.env
4
.env
|
@ -2,10 +2,10 @@
|
||||||
MALL_VERSION = v1.0.0
|
MALL_VERSION = v1.0.0
|
||||||
|
|
||||||
# 后端接口 - 正式环境(通过 process.env.NODE_ENV 非 development)
|
# 后端接口 - 正式环境(通过 process.env.NODE_ENV 非 development)
|
||||||
MALL_BASE_URL = http://api-dashboard.yudao.iocoder.cn
|
MALL_BASE_URL = https://mall.jiandyb.cn:49011
|
||||||
|
|
||||||
# 后端接口 - 测试环境(通过 process.env.NODE_ENV = development)
|
# 后端接口 - 测试环境(通过 process.env.NODE_ENV = development)
|
||||||
MALL_DEV_BASE_URL = https://mall-baclend-local.jiandyb9834.xyz
|
MALL_DEV_BASE_URL = https://mall.jiandyb.cn:49011
|
||||||
|
|
||||||
# 后端接口前缀(一般不建议调整)
|
# 后端接口前缀(一般不建议调整)
|
||||||
MALL_API_PATH = /merchant-api
|
MALL_API_PATH = /merchant-api
|
||||||
|
|
|
@ -1,56 +1,57 @@
|
||||||
import request from '@/peach/request'
|
import request from '@/peach/request'
|
||||||
|
|
||||||
const AuthUtil = {
|
const AuthUtil = {
|
||||||
smsLogin: (data) => {
|
smsLogin: (data) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/particulars/member/auth/sms-login',
|
url: '/particulars/member/auth/sms-login',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data,
|
data,
|
||||||
custom: {
|
custom: {
|
||||||
showSuccess: true,
|
showSuccess: true,
|
||||||
loadingMsg: '登陆中',
|
loadingMsg: '登陆中',
|
||||||
successMsg: '登陆成功',
|
successMsg: '登陆成功',
|
||||||
auth: false,
|
auth: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 退出登陆
|
// 退出登陆
|
||||||
logout: () => {
|
logout: () => {
|
||||||
return request({
|
return request({
|
||||||
url: '/particulars/member/auth/logout',
|
url: '/particulars/member/auth/logout',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 发送手机验证码
|
// 发送手机验证码
|
||||||
sendSmsCode: (mobile, scene) => {
|
sendSmsCode: (mobile, scene) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/member/auth/send-sms-code',
|
url: '/member/auth/send-sms-code',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: {
|
data: {
|
||||||
mobile,
|
mobile,
|
||||||
scene,
|
scene,
|
||||||
},
|
},
|
||||||
custom: {
|
custom: {
|
||||||
loadingMsg: '发送中',
|
loadingMsg: '发送中',
|
||||||
showSuccess: true,
|
showSuccess: true,
|
||||||
successMsg: '发送成功',
|
successMsg: '发送成功',
|
||||||
},
|
auth: false,
|
||||||
})
|
},
|
||||||
},
|
})
|
||||||
// 刷新令牌
|
},
|
||||||
refreshToken: (refreshToken) => {
|
// 刷新令牌
|
||||||
return request({
|
refreshToken: (refreshToken) => {
|
||||||
url: '/particulars/member/auth/refresh-token',
|
return request({
|
||||||
method: 'POST',
|
url: '/particulars/member/auth/refresh-token',
|
||||||
params: {
|
method: 'POST',
|
||||||
refreshToken,
|
params: {
|
||||||
},
|
refreshToken,
|
||||||
custom: {
|
},
|
||||||
loading: false, // 不用加载中
|
custom: {
|
||||||
showError: false, // 不展示错误提示
|
loading: false, // 不用加载中
|
||||||
},
|
showError: false, // 不展示错误提示
|
||||||
})
|
},
|
||||||
},
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AuthUtil
|
export default AuthUtil
|
||||||
|
|
|
@ -12,15 +12,15 @@ import AuthUtil from '@/peach/api/member/auth'
|
||||||
* @returns {Type}
|
* @returns {Type}
|
||||||
*/
|
*/
|
||||||
export function showAuthModal(type = 'smsLogin') {
|
export function showAuthModal(type = 'smsLogin') {
|
||||||
const modal = $store('modal')
|
const modal = $store('modal')
|
||||||
if (modal.auth !== '') {
|
if (modal.auth !== '') {
|
||||||
closeAuthModal()
|
closeAuthModal()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
modal.auth = type
|
modal.auth = type
|
||||||
}, 100)
|
}, 100)
|
||||||
} else {
|
} else {
|
||||||
modal.auth = type
|
modal.auth = type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +30,7 @@ export function showAuthModal(type = 'smsLogin') {
|
||||||
* @returns {Type}
|
* @returns {Type}
|
||||||
*/
|
*/
|
||||||
export function closeAuthModal() {
|
export function closeAuthModal() {
|
||||||
$store('modal').auth = ''
|
$store('modal').auth = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +40,7 @@ export function closeAuthModal() {
|
||||||
* @returns {Type}
|
* @returns {Type}
|
||||||
*/
|
*/
|
||||||
export function showShareModal() {
|
export function showShareModal() {
|
||||||
$store('modal').share = true
|
$store('modal').share = true
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +50,7 @@ export function showShareModal() {
|
||||||
* @returns {Type}
|
* @returns {Type}
|
||||||
*/
|
*/
|
||||||
export function closeShareModal() {
|
export function closeShareModal() {
|
||||||
$store('modal').share = false
|
$store('modal').share = false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +60,7 @@ export function closeShareModal() {
|
||||||
* @returns {Type}
|
* @returns {Type}
|
||||||
*/
|
*/
|
||||||
export function showMenuTools() {
|
export function showMenuTools() {
|
||||||
$store('modal').menu = true
|
$store('modal').menu = true
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,7 +71,7 @@ export function showMenuTools() {
|
||||||
*/
|
*/
|
||||||
// 关闭快捷菜单
|
// 关闭快捷菜单
|
||||||
export function closeMenuTools() {
|
export function closeMenuTools() {
|
||||||
$store('modal').menu = false
|
$store('modal').menu = false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,46 +82,48 @@ export function closeMenuTools() {
|
||||||
* @returns {Type}
|
* @returns {Type}
|
||||||
*/
|
*/
|
||||||
export function getSmsCode(event, mobile) {
|
export function getSmsCode(event, mobile) {
|
||||||
const modalStore = $store('modal')
|
const modalStore = $store('modal')
|
||||||
const lastSendTimer = modalStore.lastTimer[event]
|
const lastSendTimer = modalStore.lastTimer[event]
|
||||||
if (typeof lastSendTimer === 'undefined') {
|
|
||||||
$helper.toast('短信发送事件错误')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const duration = dayjs().unix() - lastSendTimer
|
if (typeof lastSendTimer === 'undefined') {
|
||||||
const canSend = duration >= 60
|
$helper.toast('短信发送事件错误')
|
||||||
if (!canSend) {
|
return
|
||||||
$helper.toast('请稍后再试')
|
}
|
||||||
return
|
|
||||||
}
|
|
||||||
// 只有 mobile 非空时才校验。因为部分场景(修改密码),不需要输入手机
|
|
||||||
if (mobile && !test.mobile(mobile)) {
|
|
||||||
$helper.toast('手机号码格式不正确')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送验证码 + 更新上次发送验证码时间
|
const duration = dayjs().unix() - lastSendTimer
|
||||||
let scene = -1
|
const canSend = duration >= 60
|
||||||
switch (event) {
|
if (!canSend) {
|
||||||
case 'resetPassword':
|
$helper.toast('请稍后再试')
|
||||||
scene = 4
|
return
|
||||||
break
|
}
|
||||||
case 'changePassword':
|
// 只有 mobile 非空时才校验。因为部分场景(修改密码),不需要输入手机
|
||||||
scene = 3
|
if (mobile && !test.mobile(mobile)) {
|
||||||
break
|
$helper.toast('手机号码格式不正确')
|
||||||
case 'changeMobile':
|
return
|
||||||
scene = 2
|
}
|
||||||
break
|
|
||||||
case 'smsLogin':
|
// 发送验证码 + 更新上次发送验证码时间
|
||||||
scene = 1
|
let scene = -1
|
||||||
break
|
switch (event) {
|
||||||
}
|
case 'resetPassword':
|
||||||
AuthUtil.sendSmsCode(mobile, scene).then((res) => {
|
scene = 4
|
||||||
if (res.code === 0) {
|
break
|
||||||
modalStore.lastTimer[event] = dayjs().unix()
|
case 'changePassword':
|
||||||
}
|
scene = 3
|
||||||
})
|
break
|
||||||
|
case 'changeMobile':
|
||||||
|
scene = 2
|
||||||
|
break
|
||||||
|
case 'smsLogin':
|
||||||
|
scene = 1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
AuthUtil.sendSmsCode(mobile, scene).then((res) => {
|
||||||
|
// if (res.code === 0) {
|
||||||
|
// modalStore.lastTimer[event] = dayjs().unix()
|
||||||
|
// }
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,27 +133,27 @@ export function getSmsCode(event, mobile) {
|
||||||
* @returns {Type}
|
* @returns {Type}
|
||||||
*/
|
*/
|
||||||
export function getSmsTimer(event) {
|
export function getSmsTimer(event) {
|
||||||
const modalStore = $store('modal')
|
const modalStore = $store('modal')
|
||||||
const lastSendTimer = modalStore.lastTimer[event]
|
const lastSendTimer = modalStore.lastTimer[event]
|
||||||
|
|
||||||
if (typeof lastSendTimer === 'undefined') {
|
if (typeof lastSendTimer === 'undefined') {
|
||||||
$helper.toast('短信发送事件错误')
|
$helper.toast('短信发送事件错误')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const duration = ref(dayjs().unix() - lastSendTimer - 60)
|
const duration = ref(dayjs().unix() - lastSendTimer - 60)
|
||||||
const canSend = duration.value >= 0
|
const canSend = duration.value >= 0
|
||||||
|
|
||||||
if (canSend) {
|
if (canSend) {
|
||||||
return '获取验证码'
|
return '获取验证码'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canSend) {
|
if (!canSend) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
duration.value++
|
duration.value++
|
||||||
}, 1000)
|
}, 1000)
|
||||||
return -duration.value.toString() + ' 秒'
|
return -duration.value.toString() + ' 秒'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,11 +163,11 @@ export function getSmsTimer(event) {
|
||||||
* @returns {Type}
|
* @returns {Type}
|
||||||
*/
|
*/
|
||||||
export function saveAdvHistory(adv) {
|
export function saveAdvHistory(adv) {
|
||||||
const modal = $store('modal')
|
const modal = $store('modal')
|
||||||
|
|
||||||
modal.$patch((state) => {
|
modal.$patch((state) => {
|
||||||
if (!state.advHistory.includes(adv.imgUrl)) {
|
if (!state.advHistory.includes(adv.imgUrl)) {
|
||||||
state.advHistory.push(adv.imgUrl)
|
state.advHistory.push(adv.imgUrl)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,26 +10,26 @@ import $store from '@/peach/store'
|
||||||
import AuthUtil from '@/peach/api/member/auth'
|
import AuthUtil from '@/peach/api/member/auth'
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
// 显示操作成功消息 默认不显示
|
// 显示操作成功消息 默认不显示
|
||||||
showSuccess: false,
|
showSuccess: false,
|
||||||
// 成功提醒 默认使用后端返回值
|
// 成功提醒 默认使用后端返回值
|
||||||
successMsg: '',
|
successMsg: '',
|
||||||
// 显示失败消息 默认显示
|
// 显示失败消息 默认显示
|
||||||
showError: true,
|
showError: true,
|
||||||
// 失败提醒 默认使用后端返回信息
|
// 失败提醒 默认使用后端返回信息
|
||||||
errorMsg: '',
|
errorMsg: '',
|
||||||
// 显示请求时loading模态框 默认显示
|
// 显示请求时loading模态框 默认显示
|
||||||
showLoading: true,
|
showLoading: true,
|
||||||
// loading提醒文字
|
// loading提醒文字
|
||||||
loadingMsg: '加载中',
|
loadingMsg: '加载中',
|
||||||
// 需要授权才能请求 默认放开
|
// 需要授权才能请求 默认放开
|
||||||
auth: true,
|
auth: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loading全局实例
|
// Loading全局实例
|
||||||
let LoadingInstance = {
|
let LoadingInstance = {
|
||||||
target: null,
|
target: null,
|
||||||
count: 0,
|
count: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,20 +39,20 @@ let LoadingInstance = {
|
||||||
* @returns {Type}
|
* @returns {Type}
|
||||||
*/
|
*/
|
||||||
function closeLoading() {
|
function closeLoading() {
|
||||||
if (LoadingInstance.count > 0) LoadingInstance.count--
|
if (LoadingInstance.count > 0) LoadingInstance.count--
|
||||||
if (LoadingInstance.count === 0) uni.hideLoading()
|
if (LoadingInstance.count === 0) uni.hideLoading()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 请求实例
|
// 请求实例
|
||||||
const http = new Request({
|
const http = new Request({
|
||||||
baseURL: baseUrl + apiPath,
|
baseURL: baseUrl + apiPath,
|
||||||
timeout: 8000,
|
timeout: 8000,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
header: {
|
header: {
|
||||||
Accept: 'text/json',
|
Accept: 'text/json',
|
||||||
'Content-Type': 'application/json;charset=UTF-8',
|
'Content-Type': 'application/json;charset=UTF-8',
|
||||||
},
|
},
|
||||||
custom: options,
|
custom: options,
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,39 +63,40 @@ const http = new Request({
|
||||||
*/
|
*/
|
||||||
|
|
||||||
http.interceptors.request.use(
|
http.interceptors.request.use(
|
||||||
(config) => {
|
(config) => {
|
||||||
// 自定义处理【auth 授权】:必须登录的接口,否则提示登录
|
console.log(config)
|
||||||
if (config.custom.auth && !$store('user').isLogin) {
|
// 自定义处理【auth 授权】:必须登录的接口,否则提示登录
|
||||||
// 处理登录
|
if (config.custom.auth && !$store('user').isLogin) {
|
||||||
peach.$router.go('/pages/index/login')
|
// 处理登录
|
||||||
return Promise.reject()
|
peach.$router.go('/pages/index/login')
|
||||||
}
|
return Promise.reject()
|
||||||
|
|
||||||
// 自定义处理【loading 加载中】:如果需要显示 loading,则显示 loading
|
|
||||||
if (config.custom.showLoading) {
|
|
||||||
LoadingInstance.count++
|
|
||||||
LoadingInstance.count === 1 &&
|
|
||||||
uni.showLoading({
|
|
||||||
title: config.custom.loadingMsg,
|
|
||||||
mask: true,
|
|
||||||
fail: () => {
|
|
||||||
uni.hideLoading()
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 增加 token 令牌、terminal 终端、tenant 租户的请求头
|
|
||||||
const token = getAccessToken()
|
|
||||||
if (token) {
|
|
||||||
config.header['Authorization'] = token
|
|
||||||
}
|
|
||||||
config.header['Accept'] = '*/*'
|
|
||||||
config.header['tenant-id'] = '1'
|
|
||||||
return config
|
|
||||||
},
|
|
||||||
(error) => {
|
|
||||||
return Promise.reject(error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 自定义处理【loading 加载中】:如果需要显示 loading,则显示 loading
|
||||||
|
if (config.custom.showLoading) {
|
||||||
|
LoadingInstance.count++
|
||||||
|
LoadingInstance.count === 1 &&
|
||||||
|
uni.showLoading({
|
||||||
|
title: config.custom.loadingMsg,
|
||||||
|
mask: true,
|
||||||
|
fail: () => {
|
||||||
|
uni.hideLoading()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 增加 token 令牌、terminal 终端、tenant 租户的请求头
|
||||||
|
const token = getAccessToken()
|
||||||
|
if (token) {
|
||||||
|
config.header['Authorization'] = token
|
||||||
|
}
|
||||||
|
config.header['Accept'] = '*/*'
|
||||||
|
config.header['tenant-id'] = '1'
|
||||||
|
return config
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,194 +106,189 @@ http.interceptors.request.use(
|
||||||
* @returns {Type}
|
* @returns {Type}
|
||||||
*/
|
*/
|
||||||
http.interceptors.response.use(
|
http.interceptors.response.use(
|
||||||
(response) => {
|
(response) => {
|
||||||
// console.log('response', response)
|
// console.log('response', response)
|
||||||
// 约定:如果是 /auth/ 下的 URL 地址,并且返回了 accessToken 说明是登录相关的接口,则自动设置登陆令牌
|
// 约定:如果是 /auth/ 下的 URL 地址,并且返回了 accessToken 说明是登录相关的接口,则自动设置登陆令牌
|
||||||
if (response.config.url.indexOf('/member/auth/') >= 0 && response.data?.data?.accessToken) {
|
if (response.config.url.indexOf('/member/auth/') >= 0 && response.data?.data?.accessToken) {
|
||||||
$store('user').setToken(response.data.data.accessToken, response.data.data.refreshToken)
|
$store('user').setToken(response.data.data.accessToken, response.data.data.refreshToken)
|
||||||
}
|
|
||||||
|
|
||||||
// 自定处理【loading 加载中】:如果需要显示 loading,则关闭 loading
|
|
||||||
response.config.custom.showLoading && closeLoading()
|
|
||||||
|
|
||||||
// 自定义处理【error 错误提示】:如果需要显示错误提示,则显示错误提示
|
|
||||||
if (response.data.code !== 0) {
|
|
||||||
// 特殊:如果 401 错误码,则跳转到登录页 or 刷新令牌
|
|
||||||
if (response.data.code === 401) {
|
|
||||||
return refreshToken(response.config)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 错误提示
|
|
||||||
if (response.config.custom.showError) {
|
|
||||||
uni.showToast({
|
|
||||||
title: response.data.msg || '服务器开小差啦,请稍后再试~',
|
|
||||||
icon: 'none',
|
|
||||||
mask: true,
|
|
||||||
})
|
|
||||||
return Promise.reject(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 自定义处理【showSuccess 成功提示】:如果需要显示成功提示,则显示成功提示
|
|
||||||
if (
|
|
||||||
response.config.custom.showSuccess &&
|
|
||||||
response.config.custom.successMsg !== '' &&
|
|
||||||
response.data.code === 0
|
|
||||||
) {
|
|
||||||
uni.showToast({
|
|
||||||
title: response.config.custom.successMsg,
|
|
||||||
icon: 'none',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 返回结果:包括 code + data + msg
|
|
||||||
return Promise.resolve(response.data)
|
|
||||||
},
|
|
||||||
(error) => {
|
|
||||||
console.log('error', error)
|
|
||||||
const userStore = $store('user')
|
|
||||||
const isLogin = userStore.isLogin
|
|
||||||
let errorMessage = '网络请求出错'
|
|
||||||
if (error !== undefined) {
|
|
||||||
switch (error.statusCode) {
|
|
||||||
case 400:
|
|
||||||
errorMessage = '请求错误'
|
|
||||||
break
|
|
||||||
case 401:
|
|
||||||
errorMessage = isLogin ? '您的登陆已过期' : '请先登录'
|
|
||||||
// 正常情况下,后端不会返回 401 错误,所以这里不处理 handleAuthorized
|
|
||||||
break
|
|
||||||
case 403:
|
|
||||||
errorMessage = '拒绝访问'
|
|
||||||
break
|
|
||||||
case 404:
|
|
||||||
errorMessage = '请求出错'
|
|
||||||
break
|
|
||||||
case 408:
|
|
||||||
errorMessage = '请求超时'
|
|
||||||
break
|
|
||||||
case 429:
|
|
||||||
errorMessage = '请求频繁, 请稍后再访问'
|
|
||||||
break
|
|
||||||
case 500:
|
|
||||||
errorMessage = '服务器开小差啦,请稍后再试~'
|
|
||||||
break
|
|
||||||
case 501:
|
|
||||||
errorMessage = '服务未实现'
|
|
||||||
break
|
|
||||||
case 502:
|
|
||||||
errorMessage = '网络错误'
|
|
||||||
break
|
|
||||||
case 503:
|
|
||||||
errorMessage = '服务不可用'
|
|
||||||
break
|
|
||||||
case 504:
|
|
||||||
errorMessage = '网络超时'
|
|
||||||
break
|
|
||||||
case 505:
|
|
||||||
errorMessage = 'HTTP 版本不受支持'
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if (error.errMsg.includes('timeout')) errorMessage = '请求超时'
|
|
||||||
// #ifdef H5
|
|
||||||
if (error.errMsg.includes('Network'))
|
|
||||||
errorMessage = window.navigator.onLine ? '服务器异常' : '请检查您的网络连接'
|
|
||||||
// #endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error && error.config) {
|
|
||||||
if (error.config.custom.showError === true) {
|
|
||||||
uni.showToast({
|
|
||||||
title: error.data?.msg || errorMessage,
|
|
||||||
icon: 'none',
|
|
||||||
mask: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
error.config.custom.showLoading && closeLoading()
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.reject(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 自定处理【loading 加载中】:如果需要显示 loading,则关闭 loading
|
||||||
|
response.config.custom.showLoading && closeLoading()
|
||||||
|
|
||||||
|
// 自定义处理【error 错误提示】:如果需要显示错误提示,则显示错误提示
|
||||||
|
if (response.data.code !== 0) {
|
||||||
|
// 特殊:如果 401 错误码,则跳转到登录页 or 刷新令牌
|
||||||
|
if (response.data.code === 401) {
|
||||||
|
return refreshToken(response.config)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 错误提示
|
||||||
|
if (response.config.custom.showError) {
|
||||||
|
uni.showToast({
|
||||||
|
title: response.data.msg || '服务器开小差啦,请稍后再试~',
|
||||||
|
icon: 'none',
|
||||||
|
mask: true,
|
||||||
|
})
|
||||||
|
return Promise.reject(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自定义处理【showSuccess 成功提示】:如果需要显示成功提示,则显示成功提示
|
||||||
|
if (response.config.custom.showSuccess && response.config.custom.successMsg !== '' && response.data.code === 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: response.config.custom.successMsg,
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回结果:包括 code + data + msg
|
||||||
|
return Promise.resolve(response.data)
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.log('error', error)
|
||||||
|
const userStore = $store('user')
|
||||||
|
const isLogin = userStore.isLogin
|
||||||
|
let errorMessage = '网络请求出错'
|
||||||
|
if (error !== undefined) {
|
||||||
|
switch (error.statusCode) {
|
||||||
|
case 400:
|
||||||
|
errorMessage = '请求错误'
|
||||||
|
break
|
||||||
|
case 401:
|
||||||
|
errorMessage = isLogin ? '您的登陆已过期' : '请先登录'
|
||||||
|
// 正常情况下,后端不会返回 401 错误,所以这里不处理 handleAuthorized
|
||||||
|
break
|
||||||
|
case 403:
|
||||||
|
errorMessage = '拒绝访问'
|
||||||
|
break
|
||||||
|
case 404:
|
||||||
|
errorMessage = '请求出错'
|
||||||
|
break
|
||||||
|
case 408:
|
||||||
|
errorMessage = '请求超时'
|
||||||
|
break
|
||||||
|
case 429:
|
||||||
|
errorMessage = '请求频繁, 请稍后再访问'
|
||||||
|
break
|
||||||
|
case 500:
|
||||||
|
errorMessage = '服务器开小差啦,请稍后再试~'
|
||||||
|
break
|
||||||
|
case 501:
|
||||||
|
errorMessage = '服务未实现'
|
||||||
|
break
|
||||||
|
case 502:
|
||||||
|
errorMessage = '网络错误'
|
||||||
|
break
|
||||||
|
case 503:
|
||||||
|
errorMessage = '服务不可用'
|
||||||
|
break
|
||||||
|
case 504:
|
||||||
|
errorMessage = '网络超时'
|
||||||
|
break
|
||||||
|
case 505:
|
||||||
|
errorMessage = 'HTTP 版本不受支持'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (error.errMsg.includes('timeout')) errorMessage = '请求超时'
|
||||||
|
// #ifdef H5
|
||||||
|
if (error.errMsg.includes('Network')) errorMessage = window.navigator.onLine ? '服务器异常' : '请检查您的网络连接'
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error && error.config) {
|
||||||
|
if (error.config.custom.showError === true) {
|
||||||
|
uni.showToast({
|
||||||
|
title: error.data?.msg || errorMessage,
|
||||||
|
icon: 'none',
|
||||||
|
mask: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
error.config.custom.showLoading && closeLoading()
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.reject(false)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
let requestList = [] // 请求队列
|
let requestList = [] // 请求队列
|
||||||
let isRefreshToken = false // 是否正在刷新中
|
let isRefreshToken = false // 是否正在刷新中
|
||||||
const refreshToken = async (config) => {
|
const refreshToken = async (config) => {
|
||||||
// 如果当前已经是 refresh-token 的 URL 地址,并且还是 401 错误,说明是刷新令牌失败了,直接返回 Promise.reject(error)
|
// 如果当前已经是 refresh-token 的 URL 地址,并且还是 401 错误,说明是刷新令牌失败了,直接返回 Promise.reject(error)
|
||||||
if (config.url.indexOf('/member/auth/refresh-token') >= 0) {
|
if (config.url.indexOf('/member/auth/refresh-token') >= 0) {
|
||||||
return Promise.reject('error')
|
return Promise.reject('error')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果未认证,并且未进行刷新令牌,说明可能是访问令牌过期了
|
// 如果未认证,并且未进行刷新令牌,说明可能是访问令牌过期了
|
||||||
if (!isRefreshToken) {
|
if (!isRefreshToken) {
|
||||||
isRefreshToken = true
|
isRefreshToken = true
|
||||||
// 1. 如果获取不到刷新令牌,则只能执行登出操作
|
// 1. 如果获取不到刷新令牌,则只能执行登出操作
|
||||||
const refreshToken = getRefreshToken()
|
const refreshToken = getRefreshToken()
|
||||||
if (!refreshToken) {
|
if (!refreshToken) {
|
||||||
return handleAuthorized()
|
return handleAuthorized()
|
||||||
}
|
|
||||||
// 2. 进行刷新访问令牌
|
|
||||||
try {
|
|
||||||
const refreshTokenResult = await AuthUtil.refreshToken(refreshToken)
|
|
||||||
if (refreshTokenResult.code !== 0) {
|
|
||||||
// 如果刷新不成功,直接抛出 e 触发 2.2 的逻辑
|
|
||||||
// noinspection ExceptionCaughtLocallyJS
|
|
||||||
throw new Error('刷新令牌失败')
|
|
||||||
}
|
|
||||||
// 2.1 刷新成功,则回放队列的请求 + 当前请求
|
|
||||||
config.header.Authorization = 'Bearer ' + getAccessToken()
|
|
||||||
requestList.forEach((cb) => {
|
|
||||||
cb()
|
|
||||||
})
|
|
||||||
requestList = []
|
|
||||||
return request(config)
|
|
||||||
} catch (e) {
|
|
||||||
// 为什么需要 catch 异常呢?刷新失败时,请求因为 Promise.reject 触发异常。
|
|
||||||
// 2.2 刷新失败,只回放队列的请求
|
|
||||||
requestList.forEach((cb) => {
|
|
||||||
cb()
|
|
||||||
})
|
|
||||||
// 提示是否要登出。即不回放当前请求!不然会形成递归
|
|
||||||
return handleAuthorized()
|
|
||||||
} finally {
|
|
||||||
requestList = []
|
|
||||||
isRefreshToken = false
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 添加到队列,等待刷新获取到新的令牌
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
requestList.push(() => {
|
|
||||||
config.header.Authorization = 'Bearer ' + getAccessToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
|
||||||
resolve(request(config))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
// 2. 进行刷新访问令牌
|
||||||
|
try {
|
||||||
|
const refreshTokenResult = await AuthUtil.refreshToken(refreshToken)
|
||||||
|
if (refreshTokenResult.code !== 0) {
|
||||||
|
// 如果刷新不成功,直接抛出 e 触发 2.2 的逻辑
|
||||||
|
// noinspection ExceptionCaughtLocallyJS
|
||||||
|
throw new Error('刷新令牌失败')
|
||||||
|
}
|
||||||
|
// 2.1 刷新成功,则回放队列的请求 + 当前请求
|
||||||
|
config.header.Authorization = 'Bearer ' + getAccessToken()
|
||||||
|
requestList.forEach((cb) => {
|
||||||
|
cb()
|
||||||
|
})
|
||||||
|
requestList = []
|
||||||
|
return request(config)
|
||||||
|
} catch (e) {
|
||||||
|
// 为什么需要 catch 异常呢?刷新失败时,请求因为 Promise.reject 触发异常。
|
||||||
|
// 2.2 刷新失败,只回放队列的请求
|
||||||
|
requestList.forEach((cb) => {
|
||||||
|
cb()
|
||||||
|
})
|
||||||
|
// 提示是否要登出。即不回放当前请求!不然会形成递归
|
||||||
|
return handleAuthorized()
|
||||||
|
} finally {
|
||||||
|
requestList = []
|
||||||
|
isRefreshToken = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 添加到队列,等待刷新获取到新的令牌
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
requestList.push(() => {
|
||||||
|
config.header.Authorization = 'Bearer ' + getAccessToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
|
resolve(request(config))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 处理 401 未登陆的错误 */
|
/** 处理 401 未登陆的错误 */
|
||||||
const handleAuthorized = () => {
|
const handleAuthorized = () => {
|
||||||
const userStore = $store('user')
|
const userStore = $store('user')
|
||||||
userStore.logOut()
|
userStore.logOut()
|
||||||
peach.$router.go('/pages/index/login')
|
peach.$router.go('/pages/index/login')
|
||||||
// 登录超时
|
// 登录超时
|
||||||
return Promise.reject({
|
return Promise.reject({
|
||||||
code: 401,
|
code: 401,
|
||||||
msg: userStore.isLogin ? '您的登陆已过期' : '请先登录',
|
msg: userStore.isLogin ? '您的登陆已过期' : '请先登录',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获得访问令牌 */
|
/** 获得访问令牌 */
|
||||||
const getAccessToken = () => {
|
const getAccessToken = () => {
|
||||||
return uni.getStorageSync('token')
|
return uni.getStorageSync('token')
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获得刷新令牌 */
|
/** 获得刷新令牌 */
|
||||||
const getRefreshToken = () => {
|
const getRefreshToken = () => {
|
||||||
return uni.getStorageSync('refresh-token')
|
return uni.getStorageSync('refresh-token')
|
||||||
}
|
}
|
||||||
|
|
||||||
const request = (config) => {
|
const request = (config) => {
|
||||||
return http.middleware(config)
|
return http.middleware(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default request
|
export default request
|
||||||
|
|
|
@ -1,47 +1,47 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="page-app" :class="['theme-' + sys.mode, 'main-' + sys.theme, 'font-' + sys.fontSize]">
|
<view class="page-app" :class="['theme-' + sys.mode, 'main-' + sys.theme, 'font-' + sys.fontSize]">
|
||||||
<view class="page-main" :style="[bgMain]">
|
<view class="page-main" :style="[bgMain]">
|
||||||
<!-- 顶部导航栏-情况1:默认通用顶部导航栏 -->
|
<!-- 顶部导航栏-情况1:默认通用顶部导航栏 -->
|
||||||
<pb-navbar
|
<pb-navbar
|
||||||
v-if="navbar === 'normal'"
|
v-if="navbar === 'normal'"
|
||||||
:title="title"
|
:title="title"
|
||||||
:leftIcon="leftIcon"
|
:leftIcon="leftIcon"
|
||||||
statusBar
|
statusBar
|
||||||
:color="color"
|
:color="color"
|
||||||
:tools="tools"
|
:tools="tools"
|
||||||
:opacityBgUi="opacityBgUi"
|
:opacityBgUi="opacityBgUi"
|
||||||
@search="(e) => emits('search', e)"
|
@search="(e) => emits('search', e)"
|
||||||
:defaultSearch="defaultSearch"
|
:defaultSearch="defaultSearch"
|
||||||
/>
|
/>
|
||||||
<view class="page-body" :style="[bgBody]">
|
<view class="page-body" :style="[bgBody]">
|
||||||
<!-- 顶部导航栏-情况2:沉浸式头部 -->
|
<!-- 顶部导航栏-情况2:沉浸式头部 -->
|
||||||
<pb-inner-navbar
|
<pb-inner-navbar
|
||||||
v-if="navbar === 'inner'"
|
v-if="navbar === 'inner'"
|
||||||
:iconColor="iconColor"
|
:iconColor="iconColor"
|
||||||
:color="color"
|
:color="color"
|
||||||
:right="props.right"
|
:right="props.right"
|
||||||
:title="title"
|
:title="title"
|
||||||
:leftIcon="leftIcon"
|
:leftIcon="leftIcon"
|
||||||
/>
|
/>
|
||||||
<view v-if="navbar === 'inner'" :style="[{ paddingTop: peach.$platform.navBar + 'px' }]"></view>
|
<view v-if="navbar === 'inner'" :style="[{ paddingTop: peach.$platform.navBar + 'px' }]"></view>
|
||||||
|
|
||||||
<!-- 页面内容插槽 -->
|
<!-- 页面内容插槽 -->
|
||||||
<slot />
|
<slot />
|
||||||
|
|
||||||
<!-- 底部导航 -->
|
<!-- 底部导航 -->
|
||||||
<pb-tabbar v-if="tabbar !== ''" :path="tabbar" />
|
<pb-tabbar v-if="tabbar !== ''" :path="tabbar" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="page-modal">
|
|
||||||
<!-- 全局授权弹窗 -->
|
|
||||||
<!-- <p-auth-modal /> -->
|
|
||||||
<!-- 全局分享弹窗 -->
|
|
||||||
<!-- <p-share-modal :shareInfo="shareInfo" /> -->
|
|
||||||
<!-- 全局快捷入口 -->
|
|
||||||
<p-menu-tools />
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="page-modal">
|
||||||
|
<!-- 全局授权弹窗 -->
|
||||||
|
<!-- <p-auth-modal /> -->
|
||||||
|
<!-- 全局分享弹窗 -->
|
||||||
|
<!-- <p-share-modal :shareInfo="shareInfo" /> -->
|
||||||
|
<!-- 全局快捷入口 -->
|
||||||
|
<p-menu-tools />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
@ -66,70 +66,70 @@ import { onShareAppMessage } from '@dcloudio/uni-app'
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
leftIcon: {
|
leftIcon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: 'leftIcon',
|
||||||
},
|
},
|
||||||
navbar: {
|
navbar: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'normal',
|
default: 'normal',
|
||||||
},
|
},
|
||||||
opacityBgUi: {
|
opacityBgUi: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'bg-white',
|
default: 'bg-white',
|
||||||
},
|
},
|
||||||
color: {
|
color: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
tools: {
|
tools: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'title',
|
default: 'title',
|
||||||
},
|
},
|
||||||
bgStyle: {
|
bgStyle: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({
|
default: () => ({
|
||||||
src: '',
|
src: '',
|
||||||
color: 'var(--ui-BG-1)',
|
color: 'var(--ui-BG-1)',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
tabbar: {
|
tabbar: {
|
||||||
type: [String, Boolean],
|
type: [String, Boolean],
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
onShareAppMessage: {
|
onShareAppMessage: {
|
||||||
type: [Boolean, Object],
|
type: [Boolean, Object],
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
leftWidth: {
|
leftWidth: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: 100,
|
default: 100,
|
||||||
},
|
},
|
||||||
rightWidth: {
|
rightWidth: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: 100,
|
default: 100,
|
||||||
},
|
},
|
||||||
defaultSearch: {
|
defaultSearch: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
//展示返回按钮
|
//展示返回按钮
|
||||||
showLeftButton: {
|
showLeftButton: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
iconColor: {
|
iconColor: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '#000',
|
default: '#000',
|
||||||
},
|
},
|
||||||
right: {
|
right: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const emits = defineEmits(['search'])
|
const emits = defineEmits(['search'])
|
||||||
|
|
||||||
|
@ -141,102 +141,102 @@ const sys = computed(() => sysStore)
|
||||||
|
|
||||||
// 导航栏模式(因为有自定义导航栏 需要计算)
|
// 导航栏模式(因为有自定义导航栏 需要计算)
|
||||||
const navbarMode = computed(() => {
|
const navbarMode = computed(() => {
|
||||||
if (props.navbar === 'normal') {
|
if (props.navbar === 'normal') {
|
||||||
return 'normal'
|
return 'normal'
|
||||||
}
|
}
|
||||||
return 'inner'
|
return 'inner'
|
||||||
})
|
})
|
||||||
|
|
||||||
// 背景1
|
// 背景1
|
||||||
const bgMain = computed(() => {
|
const bgMain = computed(() => {
|
||||||
if (navbarMode.value === 'inner') {
|
if (navbarMode.value === 'inner') {
|
||||||
return {
|
return {
|
||||||
background: `${props.bgStyle.backgroundColor} url(${peach.$url.static(
|
background: `${props.bgStyle.backgroundColor} url(${peach.$url.static(
|
||||||
props.bgStyle.backgroundImage,
|
props.bgStyle.backgroundImage,
|
||||||
props.bgStyle.imageType
|
props.bgStyle.imageType
|
||||||
)}) no-repeat top center / 100% ${props.bgStyle.height || 'auto'}`,
|
)}) no-repeat top center / 100% ${props.bgStyle.height || 'auto'}`,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return {}
|
}
|
||||||
|
return {}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 背景2
|
// 背景2
|
||||||
const bgBody = computed(() => {
|
const bgBody = computed(() => {
|
||||||
if (navbarMode.value === 'normal') {
|
if (navbarMode.value === 'normal') {
|
||||||
return {
|
return {
|
||||||
background: `${props.bgStyle.backgroundColor} url(${peach.$url.static(
|
background: `${props.bgStyle.backgroundColor} url(${peach.$url.static(
|
||||||
props.bgStyle.backgroundImage,
|
props.bgStyle.backgroundImage,
|
||||||
props.bgStyle.imageType
|
props.bgStyle.imageType
|
||||||
)}) no-repeat top center / 100% auto`,
|
)}) no-repeat top center / 100% auto`,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return {}
|
}
|
||||||
|
return {}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 分享信息
|
// 分享信息
|
||||||
const shareInfo = computed(() => {
|
const shareInfo = computed(() => {
|
||||||
if (props.onShareAppMessage === true) {
|
if (props.onShareAppMessage === true) {
|
||||||
return peach.$platform.share.getShareInfo()
|
return peach.$platform.share.getShareInfo()
|
||||||
} else {
|
} else {
|
||||||
if (!isEmpty(props.onShareAppMessage)) {
|
if (!isEmpty(props.onShareAppMessage)) {
|
||||||
// peach.$platform.share.updateShareInfo(props.onShareAppMessage)
|
// peach.$platform.share.updateShareInfo(props.onShareAppMessage)
|
||||||
return props.onShareAppMessage
|
return props.onShareAppMessage
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return {}
|
}
|
||||||
|
return {}
|
||||||
})
|
})
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
// 微信小程序分享
|
// 微信小程序分享
|
||||||
onShareAppMessage(() => {
|
onShareAppMessage(() => {
|
||||||
return {
|
return {
|
||||||
title: shareInfo.value.title,
|
title: shareInfo.value.title,
|
||||||
path: shareInfo.value.path,
|
path: shareInfo.value.path,
|
||||||
imageUrl: shareInfo.value.image,
|
imageUrl: shareInfo.value.image,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
if (!isEmpty(shareInfo.value)) {
|
if (!isEmpty(shareInfo.value)) {
|
||||||
// peach.$platform.share.updateShareInfo(shareInfo.value)
|
// peach.$platform.share.updateShareInfo(shareInfo.value)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.page-app {
|
.page-app {
|
||||||
position: relative;
|
position: relative;
|
||||||
color: var(--ui-TC);
|
color: var(--ui-TC);
|
||||||
background-color: var(--ui-BG-1) !important;
|
background-color: var(--ui-BG-1) !important;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
|
||||||
|
.page-main {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100vh;
|
min-height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
.page-main {
|
.page-body {
|
||||||
position: absolute;
|
width: 100%;
|
||||||
z-index: 1;
|
position: relative;
|
||||||
width: 100%;
|
z-index: 1;
|
||||||
min-height: 100%;
|
flex: 1;
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.page-body {
|
|
||||||
width: 100%;
|
|
||||||
position: relative;
|
|
||||||
z-index: 1;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-img {
|
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
z-index: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.page-img {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,80 +1,76 @@
|
||||||
<!-- 自定义导航栏 -->
|
<!-- 自定义导航栏 -->
|
||||||
<template>
|
<template>
|
||||||
<view class="uni-navbar" :class="{ 'uni-dark': dark }">
|
<view class="uni-navbar" :class="{ 'uni-dark': dark }">
|
||||||
<view
|
<view
|
||||||
:class="{
|
:class="{
|
||||||
'uni-navbar--fixed': fixed,
|
'uni-navbar--fixed': fixed,
|
||||||
'uni-navbar--shadow': shadow,
|
'uni-navbar--shadow': shadow,
|
||||||
'uni-navbar--border': border,
|
'uni-navbar--border': border,
|
||||||
}"
|
}"
|
||||||
class="uni-navbar__content"
|
class="uni-navbar__content"
|
||||||
>
|
>
|
||||||
<view class="fixed-bg" :class="[opacity ? '' : opacityBgUi]"></view>
|
<view class="fixed-bg" :class="[opacity ? '' : opacityBgUi]"></view>
|
||||||
<pb-status-bar v-if="statusBar" />
|
<pb-status-bar v-if="statusBar" />
|
||||||
<view
|
<view
|
||||||
:style="{
|
:style="{
|
||||||
color: themeColor,
|
color: themeColor,
|
||||||
height: navbarHeight,
|
height: navbarHeight,
|
||||||
background: backgroundColor,
|
background: backgroundColor,
|
||||||
}"
|
}"
|
||||||
class="uni-navbar__header"
|
class="uni-navbar__header"
|
||||||
>
|
>
|
||||||
<view class="uni-navbar__header-btns uni-navbar__header-btns-left" :style="{ width: leftIconWidth }">
|
<view class="uni-navbar__header-btns uni-navbar__header-btns-left" :style="{ width: leftIconWidth }">
|
||||||
<slot name="left">
|
<slot name="left">
|
||||||
<view class="uni-navbar__content_view" v-if="leftIcon.length > 0">
|
<view class="uni-navbar__content_view" v-if="leftIcon.length > 0">
|
||||||
<view class="icon-box ss-flex">
|
<view class="icon-box ss-flex">
|
||||||
<view class="icon-button icon-button-left ss-flex ss-row-center" @tap="onClickLeft">
|
<view class="icon-button icon-button-left ss-flex ss-row-center" @tap="onClickLeft">
|
||||||
<text class="sicon-back" v-if="hasHistory" />
|
<text class="sicon-back" v-if="hasHistory" />
|
||||||
<text class="sicon-home" v-else />
|
<text class="sicon-home" v-else />
|
||||||
</view>
|
|
||||||
<view class="line"></view>
|
|
||||||
<view class="icon-button icon-button-right ss-flex ss-row-center" @tap="showMenuTools">
|
|
||||||
<text class="sicon-more" />
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view
|
|
||||||
:class="{ 'uni-navbar-btn-icon-left': !leftIcon.length > 0 }"
|
|
||||||
class="uni-navbar-btn-text"
|
|
||||||
v-if="
|
|
||||||
titleAlign === 'left' &&
|
|
||||||
title.length &&
|
|
||||||
peach.$platform.name !== 'WechatOfficialAccount'
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<text :style="{ color: themeColor, fontSize: '18px' }">{{ title }}</text>
|
|
||||||
</view>
|
|
||||||
</slot>
|
|
||||||
</view>
|
</view>
|
||||||
<view v-if="tools === 'search'" class="ss-flex-1">
|
<view class="line"></view>
|
||||||
<slot name="center">
|
<view class="icon-button icon-button-right ss-flex ss-row-center" @tap="showMenuTools">
|
||||||
<uni-search-bar
|
<text class="sicon-more" />
|
||||||
class="ss-flex-1 search-box"
|
|
||||||
:radius="20"
|
|
||||||
placeholder="请输入关键词"
|
|
||||||
cancelButton="none"
|
|
||||||
v-model="searchModel"
|
|
||||||
@confirm="onSearch"
|
|
||||||
/>
|
|
||||||
</slot>
|
|
||||||
</view>
|
|
||||||
<view v-else class="uni-navbar__header-container" @tap="onClickTitle">
|
|
||||||
<slot name="center">
|
|
||||||
<view
|
|
||||||
v-if="tools === 'title' && titleAlign === 'center' && title.length"
|
|
||||||
class="uni-navbar__header-container-inner"
|
|
||||||
>
|
|
||||||
<text :style="{ color: themeColor, fontSize: '36rpx' }" class="ss-line-1">{{ title }}</text>
|
|
||||||
</view>
|
|
||||||
</slot>
|
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view
|
||||||
|
:class="{ 'uni-navbar-btn-icon-left': !leftIcon.length > 0 }"
|
||||||
|
class="uni-navbar-btn-text"
|
||||||
|
v-if="titleAlign === 'left' && title.length && peach.$platform.name !== 'WechatOfficialAccount'"
|
||||||
|
>
|
||||||
|
<text :style="{ color: themeColor, fontSize: '18px' }">{{ title }}</text>
|
||||||
|
</view>
|
||||||
|
</slot>
|
||||||
</view>
|
</view>
|
||||||
<view class="uni-navbar__placeholder" v-if="placeholder">
|
<view v-if="tools === 'search'" class="ss-flex-1">
|
||||||
<pb-status-bar v-if="statusBar" />
|
<slot name="center">
|
||||||
<view class="uni-navbar__placeholder-view" :style="{ height: navbarHeight }" />
|
<uni-search-bar
|
||||||
|
class="ss-flex-1 search-box"
|
||||||
|
:radius="20"
|
||||||
|
placeholder="请输入关键词"
|
||||||
|
cancelButton="none"
|
||||||
|
v-model="searchModel"
|
||||||
|
@confirm="onSearch"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
</view>
|
</view>
|
||||||
|
<view v-else class="uni-navbar__header-container" @tap="onClickTitle">
|
||||||
|
<slot name="center">
|
||||||
|
<view
|
||||||
|
v-if="tools === 'title' && titleAlign === 'center' && title.length"
|
||||||
|
class="uni-navbar__header-container-inner"
|
||||||
|
>
|
||||||
|
<text :style="{ color: themeColor, fontSize: '36rpx' }" class="ss-line-1">{{ title }}</text>
|
||||||
|
</view>
|
||||||
|
</slot>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="uni-navbar__placeholder" v-if="placeholder">
|
||||||
|
<pb-status-bar v-if="statusBar" />
|
||||||
|
<view class="uni-navbar__placeholder-view" :style="{ height: navbarHeight }" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
@ -105,322 +101,322 @@ const getVal = (val) => (typeof val === 'number' ? val + 'px' : val)
|
||||||
|
|
||||||
const emits = defineEmits(['clickLeft', 'clickRight', 'clickTitle', 'search'])
|
const emits = defineEmits(['clickLeft', 'clickRight', 'clickTitle', 'search'])
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dark: {
|
dark: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
// left | center
|
// left | center
|
||||||
titleAlign: {
|
titleAlign: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'center',
|
default: 'center',
|
||||||
},
|
},
|
||||||
rightText: {
|
rightText: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
leftIcon: {
|
leftIcon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: 'left',
|
||||||
},
|
},
|
||||||
rightIcon: {
|
rightIcon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
fixed: {
|
fixed: {
|
||||||
type: [Boolean, String],
|
type: [Boolean, String],
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: [Boolean, String],
|
type: [Boolean, String],
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
color: {
|
color: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
backgroundColor: {
|
backgroundColor: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
opacity: {
|
opacity: {
|
||||||
type: [Boolean, String],
|
type: [Boolean, String],
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
opacityBgUi: {
|
opacityBgUi: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'bg-white',
|
default: 'bg-white',
|
||||||
},
|
},
|
||||||
statusBar: {
|
statusBar: {
|
||||||
type: [Boolean, String],
|
type: [Boolean, String],
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
shadow: {
|
shadow: {
|
||||||
type: [Boolean, String],
|
type: [Boolean, String],
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
border: {
|
border: {
|
||||||
type: [Boolean, String],
|
type: [Boolean, String],
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
height: {
|
height: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: 44,
|
default: 44,
|
||||||
},
|
},
|
||||||
leftWidth: {
|
leftWidth: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: 80,
|
default: 80,
|
||||||
},
|
},
|
||||||
rightWidth: {
|
rightWidth: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
tools: {
|
tools: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'title',
|
default: 'title',
|
||||||
},
|
},
|
||||||
defaultSearch: {
|
defaultSearch: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const searchModel = computed(() => {
|
const searchModel = computed(() => {
|
||||||
return props.defaultSearch
|
return props.defaultSearch
|
||||||
})
|
})
|
||||||
|
|
||||||
const themeColor = computed(() => {
|
const themeColor = computed(() => {
|
||||||
if (props.dark) {
|
if (props.dark) {
|
||||||
return props.color ? props.color : '#fff'
|
return props.color ? props.color : '#fff'
|
||||||
}
|
}
|
||||||
return props.color || '#333'
|
return props.color || '#333'
|
||||||
})
|
})
|
||||||
const navbarHeight = computed(() => {
|
const navbarHeight = computed(() => {
|
||||||
return getVal(props.height)
|
return getVal(props.height)
|
||||||
})
|
})
|
||||||
const leftIconWidth = computed(() => {
|
const leftIconWidth = computed(() => {
|
||||||
return getVal(props.leftWidth)
|
return getVal(props.leftWidth)
|
||||||
})
|
})
|
||||||
|
|
||||||
function onSearch(e) {
|
function onSearch(e) {
|
||||||
emits('search', e.value)
|
emits('search', e.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
if (uni.report && props.title !== '') {
|
if (uni.report && props.title !== '') {
|
||||||
uni.report('title', props.title)
|
uni.report('title', props.title)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const hasHistory = peach.$router.hasHistory()
|
const hasHistory = peach.$router.hasHistory()
|
||||||
|
|
||||||
function onClickLeft() {
|
function onClickLeft() {
|
||||||
if (hasHistory) {
|
if (hasHistory) {
|
||||||
peach.$router.back()
|
peach.$router.back()
|
||||||
} else {
|
} else {
|
||||||
peach.$router.go('/pages/index/index')
|
peach.$router.go('/pages/index/index')
|
||||||
}
|
}
|
||||||
emits('clickLeft')
|
emits('clickLeft')
|
||||||
}
|
}
|
||||||
function onClickTitle() {
|
function onClickTitle() {
|
||||||
emits('clickTitle')
|
emits('clickTitle')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.bg-main {
|
.bg-main {
|
||||||
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient)) !important;
|
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient)) !important;
|
||||||
color: #fff !important;
|
color: #fff !important;
|
||||||
}
|
}
|
||||||
.icon-box {
|
.icon-box {
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
box-shadow: 0px 0px 4rpx rgba(51, 51, 51, 0.08), 0px 4rpx 6rpx 2rpx rgba(102, 102, 102, 0.12);
|
box-shadow: 0px 0px 4rpx rgba(51, 51, 51, 0.08), 0px 4rpx 6rpx 2rpx rgba(102, 102, 102, 0.12);
|
||||||
border-radius: 30rpx;
|
border-radius: 30rpx;
|
||||||
width: 134rpx;
|
width: 134rpx;
|
||||||
|
height: 56rpx;
|
||||||
|
margin-left: 8rpx;
|
||||||
|
.line {
|
||||||
|
width: 2rpx;
|
||||||
|
height: 24rpx;
|
||||||
|
background: #e5e5e7;
|
||||||
|
}
|
||||||
|
.sicon-back {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
.sicon-home {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
.sicon-more {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
.icon-button {
|
||||||
|
width: 67rpx;
|
||||||
height: 56rpx;
|
height: 56rpx;
|
||||||
margin-left: 8rpx;
|
&-left:hover {
|
||||||
.line {
|
background: rgba(0, 0, 0, 0.16);
|
||||||
width: 2rpx;
|
border-radius: 30rpx 0px 0px 30rpx;
|
||||||
height: 24rpx;
|
|
||||||
background: #e5e5e7;
|
|
||||||
}
|
}
|
||||||
.sicon-back {
|
&-right:hover {
|
||||||
font-size: 32rpx;
|
background: rgba(0, 0, 0, 0.16);
|
||||||
color: #000;
|
border-radius: 0px 30rpx 30rpx 0px;
|
||||||
}
|
|
||||||
.sicon-home {
|
|
||||||
font-size: 32rpx;
|
|
||||||
color: #000;
|
|
||||||
}
|
|
||||||
.sicon-more {
|
|
||||||
font-size: 32rpx;
|
|
||||||
color: #000;
|
|
||||||
}
|
|
||||||
.icon-button {
|
|
||||||
width: 67rpx;
|
|
||||||
height: 56rpx;
|
|
||||||
&-left:hover {
|
|
||||||
background: rgba(0, 0, 0, 0.16);
|
|
||||||
border-radius: 30rpx 0px 0px 30rpx;
|
|
||||||
}
|
|
||||||
&-right:hover {
|
|
||||||
background: rgba(0, 0, 0, 0.16);
|
|
||||||
border-radius: 0px 30rpx 30rpx 0px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$nav-height: 44px;
|
$nav-height: 44px;
|
||||||
|
|
||||||
.fixed-bg {
|
.fixed-bg {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-nav-bar-text {
|
.uni-nav-bar-text {
|
||||||
/* #ifdef APP-PLUS */
|
/* #ifdef APP-PLUS */
|
||||||
font-size: 34rpx;
|
font-size: 34rpx;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
/* #ifndef APP-PLUS */
|
/* #ifndef APP-PLUS */
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-nav-bar-right-text {
|
.uni-nav-bar-right-text {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-navbar__content {
|
.uni-navbar__content {
|
||||||
position: relative;
|
position: relative;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-navbar__content_view {
|
.uni-navbar__content_view {
|
||||||
// box-sizing: border-box;
|
// box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-navbar-btn-text {
|
.uni-navbar-btn-text {
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
display: flex;
|
display: flex;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-navbar__header {
|
.uni-navbar__header {
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
display: flex;
|
display: flex;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
height: $nav-height;
|
height: $nav-height;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-navbar__header-btns {
|
.uni-navbar__header-btns {
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
display: flex;
|
display: flex;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
min-width: 40rpx;
|
min-width: 40rpx;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
/* #ifdef H5 */
|
/* #ifdef H5 */
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-navbar__header-btns-left {
|
.uni-navbar__header-btns-left {
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
display: flex;
|
display: flex;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
width: 120rpx;
|
width: 120rpx;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-navbar__header-btns-right {
|
.uni-navbar__header-btns-right {
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
display: flex;
|
display: flex;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.uni-navbar__header-container {
|
.uni-navbar__header-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%) translateY(-50%);
|
transform: translateX(-50%) translateY(-50%);
|
||||||
top: 50%;
|
top: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-navbar__header-container-inner {
|
.uni-navbar__header-container-inner {
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
display: flex;
|
display: flex;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
flex: 1;
|
flex: 1;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-navbar__placeholder-view {
|
.uni-navbar__placeholder-view {
|
||||||
height: $nav-height;
|
height: $nav-height;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-navbar--fixed {
|
.uni-navbar--fixed {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 998;
|
z-index: 998;
|
||||||
/* #ifdef H5 */
|
/* #ifdef H5 */
|
||||||
left: var(--window-left);
|
left: var(--window-left);
|
||||||
right: var(--window-right);
|
right: var(--window-right);
|
||||||
/* #endif */
|
/* #endif */
|
||||||
/* #ifndef H5 */
|
/* #ifndef H5 */
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-navbar--shadow {
|
.uni-navbar--shadow {
|
||||||
box-shadow: 0 1px 6px #ccc;
|
box-shadow: 0 1px 6px #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-navbar--border {
|
.uni-navbar--border {
|
||||||
border-bottom-width: 1rpx;
|
border-bottom-width: 1rpx;
|
||||||
border-bottom-style: solid;
|
border-bottom-style: solid;
|
||||||
border-bottom-color: #eee;
|
border-bottom-color: #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-ellipsis-1 {
|
.uni-ellipsis-1 {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
/* #ifdef APP-NVUE */
|
/* #ifdef APP-NVUE */
|
||||||
lines: 1;
|
lines: 1;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暗主题配置
|
// 暗主题配置
|
||||||
|
|
Loading…
Reference in New Issue