import {
|
minioBaseUrl
|
} from "./setting.js"
|
|
/**
|
* @description 设置图片回显路径
|
* @param {String} str 路径
|
* @param {Number} type 回显类型 1普通回显 2上传回显
|
*/
|
export const setImageUrl = (str, type = 1) => {
|
if (str) {
|
let strArr = str.split(",")
|
let urls = [];
|
if (type == 1) {
|
for (let i of strArr) {
|
urls.push(`${minioBaseUrl}${i}`)
|
}
|
} else {
|
for (let i of strArr) {
|
urls.push({
|
name: i,
|
url: `${minioBaseUrl}${i}`
|
})
|
}
|
}
|
return urls;
|
} else {
|
return []
|
}
|
}
|
|
/**
|
*
|
* 显示完整路径
|
*/
|
export const setFullUrl = (str) => {
|
return `${minioBaseUrl}${str}`
|
}
|
|
|
|
export const showTips = (text, icon) => {
|
uni.showToast({
|
title: text,
|
icon: icon ? icon : 'none'
|
})
|
}
|
|
|
// 获取数据下标信息 (picker选择器数据回显)
|
export const getIndex = (arr, value, key, nameKey) => {
|
if (!key) {
|
for (let i = 0, ii = arr.length; i < ii; i++) {
|
if (arr[i] == value) {
|
return i;
|
}
|
}
|
} else {
|
for (let i = 0, ii = arr.length; i < ii; i++) {
|
if (arr[i][key] == value) {
|
return {
|
index: i,
|
name: arr[i][nameKey]
|
}
|
}
|
}
|
}
|
}
|
|
// 文件路径转字符串
|
export const formattingUrls = (urls) => {
|
if (!urls.length) {
|
return ""
|
} else {
|
let arr = [];
|
for (let i of urls) {
|
arr.push(i.name);
|
}
|
return arr.join(",")
|
}
|
|
}
|
|
//转换标签颜色
|
export const setLabelColor = (color) => {
|
let obj = {
|
'red': '#EA1F1F',
|
'yellow': '#FFB42B',
|
'green': '#30D17C'
|
}
|
for (let i in obj) {
|
if (color == i) {
|
return obj[i]
|
}
|
}
|
}
|
|
|
export const getTabbarList = (roleType = 1) => {
|
if (roleType == 1) { //居民
|
return [{
|
name: '首页',
|
iconPathSelected: '/static/img/tabbar-01-selected.png',
|
iconPath: '/static/img/tabbar-01.png',
|
url: '/pages/home/index'
|
},
|
{
|
name: '周边',
|
iconPathSelected: '/static/img/tabbar-09-selected.png',
|
iconPath: '/static/img/tabbar-09.png',
|
url: '/pages/myMap/myMap'
|
},
|
{
|
name: '邻里圈',
|
iconPathSelected: '/static/img/tabbar-02-selected.png',
|
iconPath: '/static/img/tabbar-02.png',
|
url: '/pages/circle/index'
|
},
|
{
|
name: '我的',
|
iconPathSelected: '/static/img/tabbar-03-selected.png',
|
iconPath: '/static/img/tabbar-03.png',
|
url: '/pages/user/center'
|
}
|
]
|
} else if (roleType == 2) { //民警
|
return [{
|
name: '首页',
|
iconPathSelected: '/static/img/tabbar-04-selected.png',
|
iconPath: '/static/img/tabbar-04.png',
|
url: '/pages/home/index'
|
},
|
{
|
name: '周边',
|
iconPathSelected: '/static/img/tabbar-09-selected.png',
|
iconPath: '/static/img/tabbar-09.png',
|
url: '/pages/myMap/myMap'
|
},
|
{
|
name: '协同圈',
|
iconPathSelected: '/static/img/tabbar-08-selected.png',
|
iconPath: '/static/img/tabbar-08.png',
|
url: '/pages/circle/index'
|
},
|
{
|
name: '驾驶舱',
|
iconPathSelected: '/static/img/tabbar-05-selected.png',
|
iconPath: '/static/img/tabbar-05.png',
|
url: '/pages/statistics/index'
|
},
|
|
|
{
|
name: '我的',
|
iconPathSelected: '/static/img/tabbar-06-selected.png',
|
iconPath: '/static/img/tabbar-06.png',
|
url: '/pages/user/center'
|
}
|
]
|
} else if (roleType == 3) { // 网格员
|
return [{
|
name: '首页',
|
iconPathSelected: '/static/img/tabbar-01-selected.png',
|
iconPath: '/static/img/tabbar-01.png',
|
url: '/pages/home/index'
|
},
|
{
|
name: '周边',
|
iconPathSelected: '/static/img/tabbar-09-selected.png',
|
iconPath: '/static/img/tabbar-09.png',
|
url: '/pages/myMap/myMap'
|
},
|
{
|
name: '协同圈',
|
iconPathSelected: '/static/img/tabbar-02-selected.png',
|
iconPath: '/static/img/tabbar-02.png',
|
url: '/pages/circle/index'
|
},
|
{
|
name: '驾驶舱',
|
iconPathSelected: '/static/img/tabbar-07-selected.png',
|
iconPath: '/static/img/tabbar-07.png',
|
url: '/pages/statistics/index'
|
},
|
|
{
|
name: '我的',
|
iconPathSelected: '/static/img/tabbar-03-selected.png',
|
iconPath: '/static/img/tabbar-03.png',
|
url: '/pages/user/center'
|
}
|
]
|
} else if (roleType == 4) { //系统管理员
|
return [{
|
name: '首页',
|
iconPathSelected: '/static/img/tabbar-01-selected.png',
|
iconPath: '/static/img/tabbar-01.png',
|
url: '/pages/home/index'
|
},
|
{
|
name: '周边',
|
iconPathSelected: '/static/img/tabbar-09-selected.png',
|
iconPath: '/static/img/tabbar-09.png',
|
url: '/pages/myMap/myMap'
|
},
|
{
|
name: '圈子',
|
iconPathSelected: '/static/img/tabbar-02-selected.png',
|
iconPath: '/static/img/tabbar-02.png',
|
url: '/pages/circle/index'
|
},
|
{
|
name: '驾驶舱',
|
iconPathSelected: '/static/img/tabbar-07-selected.png',
|
iconPath: '/static/img/tabbar-07.png',
|
url: '/pages/statistics/index'
|
},
|
{
|
name: '我的',
|
iconPathSelected: '/static/img/tabbar-03-selected.png',
|
iconPath: '/static/img/tabbar-03.png',
|
url: '/pages/user/center'
|
}
|
]
|
} else if (roleType == 5) { //校园主体和通用
|
return [{
|
name: '首页',
|
iconPathSelected: '/static/img/tabbar-01-selected.png',
|
iconPath: '/static/img/tabbar-01.png',
|
url: '/pages/home/index'
|
},
|
{
|
name: '周边',
|
iconPathSelected: '/static/img/tabbar-09-selected.png',
|
iconPath: '/static/img/tabbar-09.png',
|
url: '/pages/myMap/myMap'
|
},
|
{
|
name: '我的',
|
iconPathSelected: '/static/img/tabbar-03-selected.png',
|
iconPath: '/static/img/tabbar-03.png',
|
url: '/pages/user/center'
|
}
|
]
|
}
|
}
|