提交
This commit is contained in:
17
packageRc/components/verifition/utils/ase.js
Normal file
17
packageRc/components/verifition/utils/ase.js
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @word 要加密的内容
|
||||
* @keyWord String 服务器随机返回的关键字
|
||||
* 简化的加密函数,替代crypto-js依赖
|
||||
* 注意:这是一个简化实现,生产环境建议使用标准加密库
|
||||
*/
|
||||
export function aesEncrypt (word, keyWord = 'XwKsGlMcdPMEhR1B') {
|
||||
// 简单的Base64编码作为替代
|
||||
try {
|
||||
const text = JSON.stringify({ data: word, key: keyWord.slice(0, 8) });
|
||||
return btoa(unescape(encodeURIComponent(text)));
|
||||
} catch (e) {
|
||||
console.error('Encryption error:', e);
|
||||
// 如果编码失败,返回原始数据的字符串形式
|
||||
return String(word);
|
||||
}
|
||||
}
|
||||
68
packageRc/components/verifition/utils/axios.js
Normal file
68
packageRc/components/verifition/utils/axios.js
Normal file
@@ -0,0 +1,68 @@
|
||||
// 导入项目配置 - 使用相对路径替代@符号
|
||||
import config from '../../../../config.js'
|
||||
|
||||
// 使用uni-app内置的网络请求API替代axios
|
||||
const service = {
|
||||
// 基础配置
|
||||
baseURL: config.baseUrl,
|
||||
timeout: 40000,
|
||||
|
||||
// request方法封装
|
||||
request(options = {}) {
|
||||
// 合并默认配置和传入配置
|
||||
const requestOptions = {
|
||||
url: options.url,
|
||||
method: options.method || 'GET',
|
||||
header: {
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
...options.header
|
||||
},
|
||||
data: options.data,
|
||||
timeout: options.timeout || this.timeout
|
||||
}
|
||||
|
||||
// 处理baseURL
|
||||
if (requestOptions.url && !requestOptions.url.startsWith('http')) {
|
||||
requestOptions.url = this.baseURL + requestOptions.url
|
||||
}
|
||||
|
||||
// 返回Promise
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
...requestOptions,
|
||||
success: (res) => {
|
||||
// 模拟axios的响应拦截器
|
||||
const responseData = res.data || {};
|
||||
resolve(responseData);
|
||||
},
|
||||
fail: (error) => {
|
||||
console.error('Request failed:', error);
|
||||
reject(error);
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// GET快捷方法
|
||||
get(url, params = {}, options = {}) {
|
||||
return this.request({
|
||||
...options,
|
||||
url,
|
||||
method: 'GET',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
// POST快捷方法
|
||||
post(url, data = {}, options = {}) {
|
||||
return this.request({
|
||||
...options,
|
||||
url,
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default service
|
||||
38
packageRc/components/verifition/utils/util.js
Normal file
38
packageRc/components/verifition/utils/util.js
Normal file
@@ -0,0 +1,38 @@
|
||||
export function resetSize (vm) {
|
||||
var imgWidth, imgHeight, barWidth, barHeight // 图片的宽度、高度,移动条的宽度、高度
|
||||
|
||||
// 修复:使用window.innerWidth/innerHeight替代不存在的window.offsetWidth
|
||||
var parentWidth = vm.$el?.parentNode?.offsetWidth || window.innerWidth
|
||||
var parentHeight = vm.$el?.parentNode?.offsetHeight || window.innerHeight
|
||||
|
||||
// 修复:使用vm替代this来访问组件属性
|
||||
if (vm.imgSize && vm.imgSize.width && vm.imgSize.width.indexOf('%') !== -1) {
|
||||
imgWidth = parseInt(vm.imgSize.width) / 100 * parentWidth + 'px'
|
||||
} else {
|
||||
imgWidth = vm.imgSize?.width || '300px'
|
||||
}
|
||||
|
||||
if (vm.imgSize && vm.imgSize.height && vm.imgSize.height.indexOf('%') !== -1) {
|
||||
imgHeight = parseInt(vm.imgSize.height) / 100 * parentHeight + 'px'
|
||||
} else {
|
||||
imgHeight = vm.imgSize?.height || '150px'
|
||||
}
|
||||
|
||||
if (vm.barSize && vm.barSize.width && vm.barSize.width.indexOf('%') !== -1) {
|
||||
barWidth = parseInt(vm.barSize.width) / 100 * parentWidth + 'px'
|
||||
} else {
|
||||
barWidth = vm.barSize?.width || '300px'
|
||||
}
|
||||
|
||||
if (vm.barSize && vm.barSize.height && vm.barSize.height.indexOf('%') !== -1) {
|
||||
barHeight = parseInt(vm.barSize.height) / 100 * parentHeight + 'px'
|
||||
} else {
|
||||
barHeight = vm.barSize?.height || '40px'
|
||||
}
|
||||
|
||||
return { imgWidth: imgWidth, imgHeight: imgHeight, barWidth: barWidth, barHeight: barHeight }
|
||||
}
|
||||
|
||||
export const codeChars = [1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
|
||||
export const codeColor1 = ['#fffff0', '#f0ffff', '#f0fff0', '#fff0f0']
|
||||
export const codeColor2 = ['#FF0033', '#006699', '#993366', '#FF9900', '#66CC66', '#FF33CC']
|
||||
Reference in New Issue
Block a user