常用css
.back-bt {
font-size: 12px;
border: 1px rgba(255, 255, 255, 0.8) solid;
padding: 1px 7px;
border-radius: 10%;
cursor: pointer;
}
.dis-r {
display: flex;
flex-direction: row;
}
.dis-c {
display: flex;
flex-direction: column;
}
.ver-c {
align-items: center;
}
.base-line {
align-items: baseline;
}
.hor-c {
justify-content: center;
}
.jsb {
justify-content: space-between;
}
.wh50px {
width: 50px;
height: 50px;
}
.wh46px {
width: 46px;
height: 46px;
}
.wh64px {
width: 64px;
height: 64px;
}
.wh25px {
width: 25px;
height: 25px;
}
.wh20px {
width: 20px;
height: 20px;
}
.wh30px {
width: 30px;
height: 30px;
}
.wh80px {
width: 80px;
height: 80px;
}
.wh100px {
width: 100px;
height: 100px;
}
.wh140px {
width: 140px;
height: 140px;
}
.wh60px {
width: 60px;
height: 60px;
}
.f1 {
flex: 1;
}
.mt15 {
margin-top: 15px;
}
.mt1 {
margin-top: 1px;
}
.mt2 {
margin-top: 2px;
}
.mt3 {
margin-top: 3px;
}
.mt5 {
margin-top: 5px;
}
.mt6 {
margin-top: 6px;
}
.mt7 {
margin-top: 7px;
}
.mt8 {
margin-top: 8px;
}
.mt10 {
margin-top: 10px;
}
.mt25 {
margin-top: 25px;
}
.mt30 {
margin-top: 30px;
}
.mt40 {
margin-top: 40px;
}
.mt50 {
margin-top: 50px;
}
.ml5 {
margin-left: 5px;
}
.ml10 {
margin-left: 10px;
}
.ml15 {
margin-left: 15px;
}
.ml20 {
margin-left: 20px;
}
.ml30 {
margin-left: 30px;
}
.ml10 {
margin-left: 10px;
}
.p-ver-5 {
padding-top: 5px;
padding-bottom: 5px;
}
.right-radius {
border-radius: 0 3px 3px 0;
}
.over-txt-hide {
overflow: hidden;
text-overflow: ellipsis;
}
.p-hor-10 {
padding-left: 10px;
padding-right: 10px;
}
.w200 {
width: 200px;
}
.color-good1 {
color: skyblue;
}
.color-good2 {
color: #F29701;
}
.color-good3 {
color: #00fa9a;
}
.bg-good-checked {
background: darkseagreen;
}
.bg-good-normal {
background: #CCCCFF;
}
.bgc-white {
background-color: #fff !important;
}
.bgc-shadow {
background-color: #f4f4f4 !important;
}
.bgc-shadow2 {
background-color: rgba(255, 255, 255, 0.15) !important;
}
.only-one-line {
white-space: nowrap !important;
}
.only-tow-line {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.three-line {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
}
.cursor-p {
cursor: pointer;
}
.m20 {
margin: 20px;
}
.fs6 {
font-size: 6px !important;
font-size: 0.375rem !important;
}
.fs9 {
font-size: 9px !important;
font-size: 0.563rem !important;
}
.fs10 {
font-size: 10px;
font-size: 0.625rem;
}
.fs12 {
font-size: 12px;
font-size: 0.75rem;
}
.fs13 {
font-size: 13px;
font-size: 0.813rem;
}
.fs14 {
font-size: 14px !important;
font-size: 0.875rem !important;
}
.fs15 {
font-size: 15px;
font-size: 0.938rem;
}
.fs16 {
font-size: 16px;
font-size: 1rem;
}
.fs17 {
font-size: 17px;
font-size: 1.063rem;
}
.fs18 {
font-size: 18px;
font-size: 1.125rem;
}
.fs20 {
font-size: 20px;
font-size: 1.25rem;
}
.fs22 {
font-size: 22px;
font-size: 1.375rem;
}
.fs24 {
font-size: 24px;
font-size: 1.5rem;
}
.fs26 {
font-size: 26px;
font-size: 1.625rem;
}
.fs28 {
font-size: 28px;
font-size: 1.75rem;
}
.fs30 {
font-size: 30px;
font-size: 1.875rem;
}
.fs32 {
font-size: 32px;
font-size: 2rem;
}
.fs40 {
font-size: 40px;
font-size: 2.5rem;
}
js方法 uniapp的东西多
export const tokenKey = 'tokenKey'
export const loginInfo = 'LoginInfo'
export const clickTime = 'ClickTime'
export const listJSON = 'listJSON'
export const userNamePw = 'userNamePw'
export const isEnterPoupoKey = 'isEnterPoupoKey'
export const isTodayKey = 'isTodayKey'
export function getToken() {
return uni.getStorageSync(tokenKey)
}
export function setToken(token) {
uni.setStorageSync(tokenKey, token)
}
export function getDeviceListJSON() {
return uni.getStorageSync(listJSON)
}
export function setDeviceListJSON(json) {
uni.setStorageSync(listJSON, json)
}
export function setLoginInfo(data) {
uni.setStorageSync(loginInfo, data)
}
export function setClickTime(str) {
uni.setStorageSync(clickTime, str)
}
export function getClickTime() {
return uni.getStorageSync(clickTime)
}
export function getLoginInfo() {
return uni.getStorageSync(loginInfo)
}
export function getUserNamePassword() {
return uni.getStorageSync(userNamePw)
}
export function setUserNamePassword(str) {
return uni.setStorageSync(userNamePw, str)
}
export function showToast(str, shortOrLong) {
str = isEmpty(str) ? '错误!' : str
return new Promise((resolve, reject) => {
uni.showToast({
mask: true,
icon: "none",
title: str,
duration: shortOrLong ? shortOrLong : 1500,
success: () => {
resolve()
},
fail: () => {
reject()
}
})
})
}
export function showModalm(title, content, showCancel) {
return new Promise((resolve, reject) => {
uni.showModal({
icon: "none",
title: title ? title : '提示',
content: content ? content : '确定要提交吗?',
showCancel: showCancel ? showCancel : true,
success: (res) => {
if (res.confirm) {
resolve()
} else if (res.cancel) {
reject()
}
},
fail: (e) => {
reject()
}
})
})
}
export function requestM({
url,
method,
data,
isToken,
contentType,
addStr,
noHeader,
hideLoading,
}) {
return new Promise((resolve, reject) => {
if (!hideLoading) {
uni.showLoading({
title: "加载中...",
mask: true,
})
}
var header = {}
if (!noHeader) {
if (getToken()) header['Authorization'] = 'Bearer ' + getToken()
}
header['content-type'] = contentType ? contentType : "application/json;charset=UTF-8"
if (addStr) url = url + addStr
var tempData = {}
if (data && Object.keys(data).length > 0) {
for (let key in data) {
if (data[key] != null && data[key] != undefined) {
tempData[key] = data[key]
}
}
data = tempData
}
header['clientid'] = 'e5cd7e4891bf95d1d19206ce24a7b32e'
if (data) data['clientid'] = 'e5cd7e4891bf95d1d19206ce24a7b32e'
if (addStr) url = url + addStr
if (isEncrypt == true) {
const aesKey = generateAesKey();
header['encrypt-key'] = encrypt(encryptBase64(aesKey));
data = encryptWithAes(JSON.stringify(data), aesKey)
console.log(data, 'encryptWithAes');
}
uni.request({
url: url,
method: method ? method : 'GET',
timeout: 10000,
data: data ? data : {},
success: (e) => {
if (!hideLoading) uni.hideLoading()
if (e.data.code == 200) {
resolve(e.data || e.rows)
} else if (e.data.code == 401) {
setToken('')
uni.navigateTo({
url: '/pages/login/login',
success() {
showToast('令牌过期,请重新登录!')
}
})
reject(e)
} else {
console.log(e, 'requestM1');
setTimeout(() => {
showToast(e.data.msg)
}, 600)
reject(e)
}
},
header: header,
fail: (e) => {
if (!hideLoading) uni.hideLoading()
console.log(e, 'requestM2');
showToast(e.data.msg)
setToken('')
reject(e)
}
})
})
}
export function getLabelForCode(list, code, fledName, fledCode) {
if (!list || list.length == 0) return code;
var idx = list.findIndex(item => item[fledCode] == code)
if (idx > -1) {
return list[idx][fledName]
} else {
return code;
}
}
export function getPercentValue(arrList, index, precision) {
if (!arrList[index]) {
return 0
}
if (!precision) precision = 2
const sum = arrList.reduce(function(acc, val) {
return acc + (isNaN(val) ? 0 : val)
}, 0)
if (sum === 0) {
return 0
}
const digits = Math.pow(10, precision)
const votesPerQuota = arrList.map(function(val) {
return ((isNaN(val) ? 0 : val) / sum) * digits * 100
})
const targetSeats = digits * 100
const seats = votesPerQuota.map(function(votes) {
return Math.floor(votes)
})
let currentSum = seats.reduce(function(acc, val) {
return acc + val
}, 0)
const remainder = votesPerQuota.map(function(votes, idx) {
return votes - seats[idx]
})
while (currentSum < targetSeats) {
let max = Number.NEGATIVE_INFINITY
let maxId = null
for (let i = 0, len = remainder.length; i < len; ++i) {
if (remainder[i] > max) {
max = remainder[i]
maxId = i
}
}
++seats[maxId];
remainder[maxId] = 0;
++currentSum;
}
return seats[index] / digits
}
export function addZeroInFront(e) {
if (!e) return ''
return (e + '').length === 1 ? '0' + e : e;
}
export function isToday() {
var t = uni.getStorageSync(isTodayKey)
console.log(t, 'isTodayisToday');
if (isEmpty(t)) {
uni.setStorageSync(isTodayKey, mFormatTime(new Date(), 'yyyy-MM-dd'))
return false
} else {
return t == mFormatTime(new Date(), 'yyyy-MM-dd')
}
}
export function isEmpty(val) {
if (val == null) return true;
if (typeof val === 'boolean') return false;
if (typeof val === 'number') return !val;
if (val instanceof Error) return val.message === '';
switch (Object.prototype.toString.call(val)) {
case '[object String]':
case '[object Array]':
return !val.length;
case '[object File]':
case '[object Map]':
case '[object Set]': {
return !val.size;
}
case '[object Object]': {
return !Object.keys(val).length;
}
}
return false;
};
export function mFormatTime(date, type) {
var now = new Date(date);
var year = now.getFullYear();
var month = now.getMonth() + 1;
var day = now.getDate();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
if (month.toString().length === 1) {
month = '0' + month
}
if (day.toString().length === 1) {
day = '0' + day
}
if (type == 'yyyy') {
return year
} else if (type == 'yyyy-MM') {
return year + '-' + month
} else if (type == 'yyyy-MM-dd') {
return year + '-' + month + '-' + day
} else if (type == 'HH:mm') {
return addZeroInFront(hours) + ":" + addZeroInFront(minutes)
} else if (type == 'yyyy-MM-dd HH:mm') {
return year + '-' + month + '-' + day + " " + addZeroInFront(hours) + ":" + addZeroInFront(minutes)
} else if (type == 'yyyy-MM-dd HH:mm:ss') {
return year + '-' + month + '-' + day + " " + addZeroInFront(hours) + ":" + addZeroInFront(minutes) +
":" + addZeroInFront(seconds)
}
}