first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
import config from "../config"
import { Toast } from 'vant';
class Utils {
getApiurl () {
if (process.env.NODE_ENV === 'production') {
return config.apiUrl.prodUrl
} else {
return config.apiUrl.devUrl
}
}
/**
* 校验用户名是否合法
*/
checkUserName(username) {
if (!(username.length >= 6 && username.length < 20)) {
Toast({
message: '用户名长度应该6~20位'
});
return false
}
return true
}
/**
* 校验用户密码是否合法
* @param pwd
* @returns {boolean}
*/
checkUserPassword(pwd) {
if (!(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/.test(pwd))) {
Toast({
message: '密码8~16位,至少含1个大写字母,1个小写字母,1个数字'
});
return false
}
return true
}
/**
* 本地保存数据的方法
* @param key 名字
* @param value 值
* @constructor
*/
SetlocalStorage(key,value) {
typeof value == "string" || value == "number"
? localStorage.setItem('shop_' + key, value)
: localStorage.setItem('shop_' + key, JSON.stringify(value))
}
}
export default new Utils();

View File

@@ -0,0 +1,20 @@
import NodeRsa from "node-rsa";
import config from "../config";
class RSA {
constructor () {
this.public_key = config.rsa_public_key
}
// 公钥加密
PublicKeyEncryption(text) {
return (new NodeRsa(this.public_key)).encrypt(JSON.stringify(text), 'base64')
}
// 公钥解密
PublicKeyDecryption(text) {
return JSON.parse((new NodeRsa(this.public_key)).decryptPublic(text, 'utf8'))
}
}
export default new RSA();