mirror of
http://36.133.248.69:3088/admin/RentWeAppFront.git
synced 2026-03-07 17:32:25 +08:00
完成大体功能和样式
This commit is contained in:
38
common/utils/auth.js
Normal file
38
common/utils/auth.js
Normal file
@@ -0,0 +1,38 @@
|
||||
export function getToken() {
|
||||
const lifeData = uni.getStorageSync('lifeData') || {}
|
||||
const token = lifeData.vuex_token
|
||||
return token;
|
||||
}
|
||||
|
||||
export function checkToken(token) {
|
||||
if (!token || (typeof token === 'object' && Object.keys(token).length === 0)) {
|
||||
uni.reLaunch({
|
||||
url: '/pages-biz/login/login'
|
||||
})
|
||||
return Promise.reject('no token')
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.$u.get('/login/checkExpiration', {}, {
|
||||
WT: token
|
||||
}).then(res => {
|
||||
if (res.data) {
|
||||
uni.reLaunch({
|
||||
url: '/pages-biz/login/login'
|
||||
})
|
||||
reject('token expired')
|
||||
} else {
|
||||
resolve(true)
|
||||
}
|
||||
}).catch(err => {
|
||||
uni.reLaunch({
|
||||
url: '/pages-biz/login/login'
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getUserType(){
|
||||
let userInfo = uni.getStorageSync('userInfo')
|
||||
return userInfo.userType
|
||||
}
|
||||
13
common/utils/ras.js
Normal file
13
common/utils/ras.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import JSEncrypt from 'jsencrypt'
|
||||
|
||||
const PUBLIC_KEY = `
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk6Kvq4tCfQJFO3xqMN86ra6YPKEGgDJGVNAo8HAb9ZxL8fgckaHN4wpI8D8D0HDP/Xn8ZrS7wZFSAecUmWBtyBjZdMOdSMZm1LdX036+XpyGVktsrE15n85KG9+P4H4he9ZbiPPMGYvmkn/zaxMxUagSHhPpvrwRMovA8onKzSL67CFOWl95HXxhJ1GhlKIQVBz9R5OsHhwZFfPu2xtajCtiGtF2zjF3ojwpLNca+ADC6mZufRV/MD1+gMMS5GcwG5xALDyG+Aqv4xHto30SGks3FJ9k9bAwA8vyOU8SBeG8fW8lbO9XrtbupmxUm5RnSEtNUy/iUuO1hEmpSqQfBQIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
`
|
||||
|
||||
export function rsaEncrypt(text) {
|
||||
const encryptor = new JSEncrypt()
|
||||
encryptor.setPublicKey(PUBLIC_KEY)
|
||||
return encryptor.encrypt(text)
|
||||
}
|
||||
@@ -16,6 +16,16 @@ export default [{
|
||||
"value": ""
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": '街道',
|
||||
"type": 'hierarchy',
|
||||
"submenu": [
|
||||
{
|
||||
"name": "不限",
|
||||
"value": ""
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": '方式',
|
||||
|
||||
16
common/utils/text.js
Normal file
16
common/utils/text.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 文本省略处理
|
||||
* @param {String} text 原始文本
|
||||
* @param {Number} maxLen 最大显示字数
|
||||
* @param {String} suffix 省略后缀,默认 ...
|
||||
* @returns {String}
|
||||
*/
|
||||
function ellipsisText(text, maxLen = 20, suffix = '...') {
|
||||
if (!text) return '';
|
||||
if (text.length <= maxLen) return text;
|
||||
return text.slice(0, maxLen) + suffix;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ellipsisText
|
||||
};
|
||||
Reference in New Issue
Block a user