源文件

This commit is contained in:
gyq
2024-05-23 14:39:33 +08:00
commit a1128dd791
2997 changed files with 500069 additions and 0 deletions

View File

View File

@@ -0,0 +1,15 @@
/***
* 单位换算 分转元
* data, 原始数据
* list 需要装换的 数组 object的 key
* */
function yuan(data, list = []) {
const obj = data
list.forEach((v) => {
obj[v] = (obj[v] / 100).toFixed(2)
})
return obj
}
export default { yuan }

View File

@@ -0,0 +1,49 @@
const payModel = {
WECHAT: {
title: '微信',
imgUrl: '/static/orderImg/wechat.svg', //微信
bgColor: '#09BB07',
rgba: 'rgba(9,187,7,0.8)'
},
ALIPAY: {
title: '支付宝',
imgUrl: '/static/orderImg/zfb.svg', //支付宝
bgColor: '#458FFF',
rgba: 'rgba(69,143,255,0.8)'
},
YSFPAY: {
title: '云闪付',
imgUrl: '/static/orderImg/ysf.svg', // 云闪付
bgColor: '#FF5B4C',
rgba: 'rgba(255,91,76,0.8)'
},
UNIONPAY: {
title: '银联',
imgUrl: '/static/orderImg/union-pay.svg', // 银联
bgColor: '#0D131A',
rgba: 'rgba(13,19,26,0.8)'
},
OTHER: {
title: '其他',
imgUrl: '/static/orderImg/default-pay.svg', //其他
bgColor: '#5F36C4',
rgba: 'rgba(95,54,196,0.8)'
},
}
const payState = {
0: { text: '订单生成', color: '#2980FD' },
1: { text: '支付中', color: '#FFAA33' },
2: { text: '支付成功', color: '#09BB07' },
3: { text: '支付失败', color: '#CB2972' },
4: { text: '已撤销', color: '#808080' },
5: { text: '已退款', color: '#FF5B4C' },
6: { text: '订单关闭', color: '#D9D9D9' },
}
const payImg = (key) => payModel[key] || {}
const payStateMap = (key) => payState[key] || {}
export default {
payImg,
payStateMap,
}

View File

@@ -0,0 +1,72 @@
/**
* 加解密工具包
*
* @author terrfly
* @site https://www.jeepay.vip
* @date 2021/5/16 17:35
*/
import { SM4 } from 'gm-crypto'
import appConfig from '@/config/appConfig.js'
let HEX_KEY = null
// 字符串转16进制
function str2hex(str) {
var val = ''
for (var i = 0; i < str.length; i++) {
if (val == '')
val = str.charCodeAt(i).toString(16)
else
val += str.charCodeAt(i).toString(16)
}
val += ''
return val
}
// 获取hex秘钥
function getHexKey(){
if(!HEX_KEY){
HEX_KEY = str2hex(appConfig.encryptKey)
}
return HEX_KEY
}
// 解密 (http响应数据 做通用处理)
export function sm4DecryptByResData(data){
if(!data){
return data
}
let res = SM4.decrypt(data, getHexKey(), {
inputEncoding: 'base64',
outputEncoding: 'utf8'
})
if(!res){
return res
}
return JSON.parse(res)['originData']
}
// 加密 (http响应数据 做通用处理)
export function sm4EncryptByReqData(data){
if(!data){
return data
}
// 加密处理
let encryptData = SM4.encrypt(JSON.stringify(data), getHexKey(), {
inputEncoding: 'utf8',
outputEncoding: 'base64'
})
return {encryptData : encryptData}
}

View File

@@ -0,0 +1,62 @@
/**
* 提示信息公共文件
*
* @author terrfly
* @site https://www.jeequan.com
* @date 2022/11/14 15:29
*/
const model = {
// uni.showToast的封装
// 参数: 标题、 显示时长(单位: 秒) 扩展参数
// 返回: promise对象 当提示消失后调用 resolve()
showToast: (title, duration = 1.5, extObject) => {
return new Promise((resolve, reject) => {
uni.showToast(Object.assign({ title: title, icon: 'none', mask: true, duration: (duration * 1000) }, extObject))
setTimeout(resolve, (duration * 1000));
})
},
// success类型的提示
showSuccessToast: (title, duration) => {
return model.showToast(title, duration, {icon: 'success'})
},
// error类型的提示
showErrorToast: (title, duration) => {
return model.showToast(title, duration, {icon: 'error'})
},
showLoading: (title = '请稍后' ) => {
return uni.showLoading({ title: title, mask: true })
},
hideLoading: () => {
return uni.hideLoading()
},
// 返回 Promise 点击确定和取消
// APP安卓原生提示比较丑 APP 不推荐使用该函数 。
showModal: (title, confirmText = '确定', cancalText = '取消', extObject) => {
return new Promise((resolve, reject) => {
uni.showModal( Object.assign({
title: title,
confirmText: confirmText,
showCancel: cancalText ? true : false,
cancelText: cancalText,
success: function(r) {
if (r.confirm) {
resolve()
}else if (r.cancel) {
reject()
}
}
}, extObject ));
});
},
}
export default model

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,164 @@
/**
* 存储管理对象
* 目标:将现有系统的所有需要存储的数据,统一管理
*
* @author terrfly
* @site https://www.jeequan.com
* @date 2022/04/13 07:18
*/
import appConfig from '@/config/appConfig.js'
// 应用级vue级别缓存 当存在时则读取此值, 否则读取storage中的值。 vue线程内的缓存不必要每次读取应用数据影响性能
const appCache = {
tokenVal: null, // token取值
currentUser: null, // 当前商户信息
}
const model = {
// 退出清空所有的缓存数据。 (不包含 环境相关)
cleanByLogout: () => {
// 1. 清空app级别缓存。
Object.keys(appCache).forEach((k) => (appCache[k] = null))
let envName = model.env() // 获取到当前的环境变量
uni.clearStorageSync() // 清除所有的缓存信息
model.env(envName) // 重置env
},
// 获取和放置token
token: (val, isDelete = false) => {
if (isDelete) {
appCache.tokenVal = ''
return uni.removeStorageSync(appConfig.tokenKey)
}
if (val) {
// 有值,为放置
appCache.tokenVal = val
uni.setStorageSync(appConfig.tokenKey, val)
} else {
// 否则为获取
if (!appCache.tokenVal) {
//缓存取不到,获取应用本地信息
appCache.tokenVal = uni.getStorageSync(appConfig.tokenKey)
}
return appCache.tokenVal
}
},
// 已经登录的用户记录
loggedInUser: (addUserName = null, removeUserName = null) => {
let key = 'loggedInUserList'
// 删除
if (removeUserName) {
let nameList = uni.getStorageSync(key) || []
if (nameList.length <= 0) {
//不存在数据
return false
}
let hasUserIndex = nameList.indexOf(removeUserName)
if (hasUserIndex >= 0) {
nameList.splice(hasUserIndex, 1) //删除
uni.setStorageSync(key, nameList)
}
return false
}
// 有新插入的记录
if (addUserName) {
let nameList = uni.getStorageSync(key) || []
let hasUser = false
for (let i = 0; i < nameList.length; i++) {
if (nameList[i] == addUserName) {
hasUser = true
}
}
// 包含记录
if (hasUser) {
return false
}
// 最多存储 5 个
if (nameList.length >= 5) {
nameList.splice(0, 1) //删除第一个
}
nameList.push(addUserName)
uni.setStorageSync(key, nameList)
//获取
} else {
return uni.getStorageSync(key) || [] //默认空数组
}
},
// 用户信息
userInfo: (currentUserInfo) => {
if (currentUserInfo) {
// 仅保存基础数据
let saveUser = {
sysUserId: currentUserInfo.sysUserId, // 用户ID
realname: currentUserInfo.realname, // 用户姓名
avatarUrl: currentUserInfo.avatarUrl, // 头像
telphone: currentUserInfo.telphone, // 手机号
userType: currentUserInfo.userType, // 用户类型
workState: currentUserInfo.workState, // 用户上班状态
mchNo: currentUserInfo.sysUserId, // 商户No
mchShortName: currentUserInfo.shortName, // 商户简称
mchType: currentUserInfo.mchType, // 商户类型
mchLevel: currentUserInfo.mchLevel, // 商户级别
entIdList: currentUserInfo.entIdList, // 权限集合List
}
uni.setStorageSync('currentUserInfo', saveUser) // 改变存储
appCache.currentUser = null
}
if (!appCache.currentUser) {
// 获取缓存数据
appCache.currentUser = uni.getStorageSync('currentUserInfo')
}
return appCache.currentUser
},
// 项目环境变量:(测试、 生产的切换)
env: (envMode) => {
if (envMode) {
uni.setStorageSync(appConfig.storeEnvEnumKey, envMode) // 改变存储
}
return uni.getStorageSync(appConfig.storeEnvEnumKey)
},
// 网站信息
siteInfos: (siteInfos) => {
if (siteInfos) {
uni.setStorageSync('siteInfos', siteInfos) // 改变存储
}
return uni.getStorageSync('siteInfos')
},
// unipush2 cid
uniPush2Cid: (uniPush2Cid) => {
if (uniPush2Cid) {
uni.setStorageSync('uniPush2Cid', uniPush2Cid) // 改变存储
}
return uni.getStorageSync('uniPush2Cid')
},
faceModel: (faceM) => {
if (faceM) return uni.setStorageSync('faceModel', faceM) //写入数据
return uni.getStorageSync('faceModel') //读取数据
},
deviceNo: (deviceNo) => {
if (deviceNo) return uni.setStorageSync('deviceNo', deviceNo) //写入设备号
return uni.getStorageSync('deviceNo') //读取设备号
},
}
export default model

View File

@@ -0,0 +1,19 @@
import dayjs from 'dayjs' //时间格式库
// 时间校验 用于筛选 开始 时间不能大于结束 开始结束时间必选 时间 返回值 true 和 false
export const startAndEndTime = (start, end) => {
if (!start || !end) {
uni.showToast({
title: '请选择开始或结束时间',
icon: 'none',
})
return false
}
if (dayjs(start).isAfter(end)) {
uni.showToast({
title: '开始时间不能大于结束时间',
icon: 'none',
})
return false
}
return true
}

View File

@@ -0,0 +1,54 @@
/**
* 任务执行器
*
* @author terrfly
* @site https://www.jeepay.vip
* @date 2022/11/15 16:30
*/
const model = {
// 任务启动工具, 每 xxs调用一次 知道多次x次为止。
// 注意: 启动后将立马调用一次, 而不是1s后再调用。
// 参数:
// allCount: 全部的次数 支持promise 并不一定是 秒)
// stepSecond 步伐(单位: 秒)
// callbackFunc 回调函数, 支持返回 boolean 或者 promise ,
// 注意: boolean类型 true 进入下一次循环, false: 停止任务。
// promise类型 then 进入下一次循环, catch 停止任务。
startTimeoutTask: (stepSecond, allCount, callbackFunc) => {
// 不存在回调函数
if(!callbackFunc){
return false;
}
let callbackResult = callbackFunc(allCount)
// 明确返回false, 说明不再循环
if(callbackResult === false){
return false
}
// 不包含剩余次数了。
if(allCount <= 0){
return false
}
// promise
if(typeof callbackResult == 'object'){
callbackResult.then(() => {
setTimeout(() => model.startTimeoutTask(stepSecond, --allCount, callbackFunc), (stepSecond * 1000) )
})
}else{ // 其他boolean类型 或返回不明确, 继续下一次任务。
setTimeout(() => model.startTimeoutTask(stepSecond, --allCount, callbackFunc), (stepSecond * 1000) )
}
}
}
export default model

View File

@@ -0,0 +1,25 @@
var plugin = requirePlugin("WechatSI")
const innerAudioContext = wx.createInnerAudioContext({ useWebAudioImplement: true })
innerAudioContext.onError(function (res) {
console.log(res);
console.log("语音播放失败");
})
export default function(message) {
plugin.textToSpeech({
lang: "zh_CN",
tts: true,
content: message,
success: function(res) {
console.log("succ tts", res.filename)
innerAudioContext.src = res.filename;
innerAudioContext.play();
},
fail: function(res) {
console.log("fail tts", res)
}
})
}