Commit 81ea7e63 by 前端

Merge branch 'SAAS+V4.47.3' into 'master'

上线合并

See merge request !18
2 parents 29309f7d a56c2962
Showing 60 changed files with 1297 additions and 427 deletions
......@@ -2,19 +2,19 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-07 17:09:53
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-09-24 11:01:24
* @LastEditTime: 2024-10-31 11:01:19
* @FilePath: \gl_tape\App.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script>
const PATH = ['/pages/common/caseDetail']
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update-nvue.js'
import { mapState } from 'vuex'
import utils from '@/utils/utils'
import { Ws } from '@/ws/Ws.js'
export default {
computed: {
...mapState('audio', ['isEnd', 'isStart'])
},
onLoad() {},
onLaunch: async function () {
// this.init()
this.setAPPVersion()
......@@ -25,28 +25,9 @@ export default {
uni.setKeepScreenOn({
keepScreenOn: true
})
new Ws().connect()
},
methods: {
async handleCheck() {
const { textList, tempFileURL, version } = uni.$storage.get('mock_data')
const res = utils.compareVersions(plus?.runtime?.version, version)
if (res > -1) {
return
}
const e = {
result: {
is_silently: false,
is_mandatory: true,
name: '',
title: '',
contents: textList.join('\n'),
version: version,
url: tempFileURL,
stable_publish: true
}
}
checkUpdate(e)
},
init() {
uni.addInterceptor('navigateTo', {
//监听跳转
......@@ -100,7 +81,7 @@ export default {
},
onShow: async function () {
this.handleCheck()
uni.$logger.local.info('切回app')
// const systemInfo = await uni.$api.systemApi.getMockData();
// if (systemInfo.isCheckedUpdate) {
// checkUpdate();
......@@ -111,9 +92,15 @@ export default {
// this.$store.dispatch("openUpdateModal");
// });
},
onHide: function () {},
onHide: function () {
uni.$logger.local.info('切出app')
},
onError: function (e) {
this.$sendSentry(e)
try {
uni.$logger?.error({ msg: e.message || '捕获全局异常', extra: { error: typeof e == 'string' ? e : JSON.stringify(e) } })
} catch (error) {
console.log(error)
}
}
}
</script>
......
adb connect 127.0.0.1:16384
......@@ -98,15 +98,12 @@ export default {
mounted () {
},
methods: {
autoSelect (index = 0, autoHideLoading = true) {
autoSelect () {
const { carBrandList, boutiqueDefaultCarBrandId } = this
let carIndex = 0
if (boutiqueDefaultCarBrandId) {
carIndex = carBrandList.findIndex(e => e.id == boutiqueDefaultCarBrandId)
if (carIndex < 0) carIndex = 0
}
if (index < 0) index = 0
if (carBrandList.length) this.selectCar(carBrandList[carIndex], true, index, autoHideLoading)
if (boutiqueDefaultCarBrandId) carIndex = carBrandList.findIndex(e => e.id == boutiqueDefaultCarBrandId)
if (carIndex < 0) carIndex = 0
if (carBrandList.length) this.selectCar(carBrandList[carIndex], true)
},
open () {
const userInfo = uni.$storage.get("userInfo"),
......@@ -140,8 +137,13 @@ export default {
this.$refs.carBrandListVisible.open()
this.carBrandListOff = true
},
selectCar (e, auto = false, index, autoHideLoading = true) {
let { clickFlga } = this
selectCar (e, auto = false, carId) {
if (!e.brandId || !e.id) return uni.showToast({
title: "车型ID或品牌ID为空",
icon: "none",
});
let { clickFlga } = this,
index = 0
if (clickFlga) return
this.clickFlga = true
this.selectItem = {
......@@ -154,7 +156,11 @@ export default {
if (carList) {
this.clickFlga = false
this.carlist = carList
if (auto && carList.length) this.handleSelect(carList[index])
if (auto && carList.length) {
if (carId) index = carList.findIndex(i => i.id == carId)
if (index < 0) index = 0
this.handleSelect(carList[index])
}
else this.$refs.carBoxVisible.open()
} else {
if (!auto) uni.showLoading({
......@@ -165,11 +171,15 @@ export default {
brandId: e.brandId,
childBrandId: e.id
}).then(res => {
if (autoHideLoading) uni.hideLoading()
uni.hideLoading()
this.carlist = res
if (res) uni.setStorageSync(`${e.id}_${e.brandId}_carlist`, res)
if (!carList) {
if (auto && res.length) this.handleSelect(res[index])
if (auto && res.length) {
if (carId) index = res.findIndex(i => i.id == carId)
if (index < 0) index = 0
this.handleSelect(res[index])
}
else this.$refs.carBoxVisible.open()
}
this.clickFlga = false
......
......@@ -61,10 +61,26 @@
>{{ i.text }}</view>
</template>
</view>
<view
class="search-btn flex"
@click="$refs.customerTagstVisible.open()"
>标签筛选</view>
<view class="btn-list flex">
<view
class="merchant-btn flex"
@click="allMerchantSwitch"
>
<view :class="['check-box flex',{'checked':!allMerchantStatus}]">
<uni-icons
type="checkmarkempty"
:size="12"
color="#fff"
></uni-icons>
</view>
仅展示本店方案
</view>
<view
class="search-btn flex"
@click="$refs.customerTagstVisible.open()"
>标签筛选</view>
</view>
</view>
<scroll-view
......@@ -275,6 +291,7 @@ export default {
status: 1,
showChannel: 2,
},
allMerchantStatus: true
}
},
......@@ -463,7 +480,7 @@ export default {
mask: true
})
let { shopMerchantId } = uni.$storage.get("userInfo"),
{ pageSize, pageNum, caseParams, tagsList } = this,
{ pageSize, pageNum, caseParams, tagsList, allMerchantStatus } = this,
customerLabelList = []
tagsList.map(e => customerLabelList.push({
labelId: e.labelId
......@@ -472,9 +489,9 @@ export default {
currentPage: pageNum,
pageSize,
customerLabelList,
merchantId: shopMerchantId,
...caseParams
}
if (!allMerchantStatus) params.merchantId = shopMerchantId
const { list, total } = await uni.$api.customerApi.getMaterialResponsePage(params)
uni.hideLoading()
list.map(e => {
......@@ -502,6 +519,10 @@ export default {
handleSelect (list) {
this.tagsList = list
this.refresh()
},
allMerchantSwitch () {
this.allMerchantStatus = !this.allMerchantStatus
this.refresh()
}
}
}
......@@ -834,15 +855,37 @@ export default {
background: #2d66f71a;
}
}
.search-btn {
.btn-list {
margin-left: auto;
&::after {
content: '';
border: 12rpx solid transparent;
border-left-color: #000;
margin-left: 12rpx;
gap: 0 48rpx;
line-height: 48rpx;
.search-btn {
&::after {
content: '';
border: 12rpx solid transparent;
border-left-color: #000;
margin-left: 12rpx;
transform: translateY(-2rpx);
}
}
.check-box {
width: 32rpx;
height: 32rpx;
background: #ffffff;
border: 1.5px solid #999;
border-radius: 6rpx;
box-sizing: border-box;
margin-right: 16rpx;
justify-content: center;
overflow: hidden;
transition: all 0.25s;
flex-shrink: 0;
transform: translateY(-2rpx);
}
.checked {
background: #2c66f7;
border-color: #2c66f7;
}
}
}
......
......@@ -100,7 +100,7 @@ import dayjs from 'dayjs'
const dayImgUrl = require('@/assets/images/common/day.webp')
const weekImgUrl = require('@/assets/images/common/week.webp')
const monthImgUrl = require('@/assets/images/common/month.webp')
import { STORAGE_OBJECTkEY } from '@/utils/cache/constantData'
import { STORAGE_OBJECTKEY } from '@/utils/cache/constantData'
import interruptRecord from '@/utils/recordManager/interruptRecord'
import saveRecord from './saveRecord.vue'
export default {
......@@ -182,6 +182,7 @@ export default {
async handleSubmit(val ){
this.showRecord = true;
uni.$recordManager.addRecord(val)
uni.$logger.local.info(`添加记录${JSON.stringify(val)}`)
interruptRecord.removePreRecord(val.id)
this.getRecordNum()
this.getPreRecordFail()
......@@ -245,7 +246,7 @@ export default {
},
getPreRecordNum() {
const preRecordList = uni.$storage.get(STORAGE_OBJECTkEY.preRecordList)||[]
const preRecordList = uni.$storage.get(STORAGE_OBJECTKEY.preRecordList)||[]
console.log(preRecordList)
this.preRecordFailList = preRecordList.reverse()
},
......
......@@ -81,6 +81,7 @@ export default {
const userInfo = uni.$storage.get('userInfo') || {}
this.userInfo = userInfo
},
computed: {
previewRef() {
return this.$refs.previewRef
......
module.exports = {
// 请求域名 格式:https://xxx.xxx.com
HTTP_REQUEST_URL: "http://127.0.0.1:8000/api",
HTTP_REQUEST_URL: 'http://127.0.0.1:8000/api',
// 阿里云oss域名 格式:https://xxx.oss-cn-xxx.aliyuncs.com
OSS_DOMAIN: "https://glsk-oss.oss-cn-shenzhen.aliyuncs.com",
OSS_DOMAIN: 'https://glsk-oss.oss-cn-shenzhen.aliyuncs.com',
// 文件直传到阿里云oss时需用到
ACCESSKEYID: "LTAI5tCRcCUgd7bt1J7JY596",
ACCESSKEYSECRET: "kJos9mgylkR5ztosnDt8Asrc3ulgqy",
BUKET_NAME: "glsk-oss",
FOLDER: "quality/",
ACCESSKEYID: 'LTAI5tCRcCUgd7bt1J7JY596',
ACCESSKEYSECRET: 'kJos9mgylkR5ztosnDt8Asrc3ulgqy',
BUKET_NAME: 'glsk-oss',
FOLDER: 'quality/',
// 与后端约定的token字段名
TOKEN_NAME: "glsk-oss",
};
TOKEN_NAME: 'glsk-oss',
// PROTOCAL: 'http',
// SERVER: 'app-admin-server.test.glsx.com.cn',
// SOCKET_PORT: '9081',
// HTTP_PORT: '3000',
HTTP_SERVER: 'http://app-admin-server.glsx.com.cn',
SOCKET_SERVER: 'http://app-admin-server.glsx.com.cn',
FILE_UPLOAD_URL: 'file/upload'
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title>
</head>
<style>
body,
html {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
background: rgb(0, 0, 0, 0.5);
}
.loading {
width: 50px;
height: 50px;
border: 3px solid #666;
border-radius: 50%;
border-top-color: #fff;
animation: spin 1s linear infinite;
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title>
</head>
<style>
body,
html {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
background: rgb(0, 0, 0, 0.5);
}
.loading {
width: 50px;
height: 50px;
border: 3px solid #666;
border-radius: 50%;
border-top-color: #fff;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
100% {
transform: rotate(360deg);
}
</style>
}
</style>
</head>
<body>
<div class="loading"></div>
<script src="js/uni.webview.1.5.5.js"></script>
<script src="js/aliyun-oss-sdk-6.18.1.min.js"></script>
<script src="js/OSSUpLoader.js"></script>
<script>
// document.addEventListener('UniAppJSBridgeReady', function(){
/**
* 该函数用于接收来自 UniApp 的消息,它包含了文件上传所需的所有信息
* @param {string} accessKeyId - OSS 访问密钥 ID
* @param {string} accessKeySecret - OSS 访问密钥 secret
* @param {string} stsToken - 安全令牌服务(STS)令牌,用于临时访问 OSS 存储桶
* @param {string} fileName - 要上传的文件名
* @param {string} filePath - 要上传的文件所在路径
* @param {Object} options - (可选)包含上传器配置的对象,如 region
* @throws {Error} 如果缺少必要的参数,将抛出错误
*/
window.msgFromUniapp = function (
accessKeyId,
accessKeySecret,
stsToken,
<script src="js/uni.webview.1.5.5.js"></script>
<script src="js/aliyun-oss-sdk-6.18.1.min.js"></script>
<script src="js/OSSUpLoader.js"></script>
<script>
// document.addEventListener('UniAppJSBridgeReady', function(){
/**
* 该函数用于接收来自 UniApp 的消息,它包含了文件上传所需的所有信息
* @param {string} accessKeyId - OSS 访问密钥 ID
* @param {string} accessKeySecret - OSS 访问密钥 secret
* @param {string} stsToken - 安全令牌服务(STS)令牌,用于临时访问 OSS 存储桶
* @param {string} fileName - 要上传的文件名
* @param {string} filePath - 要上传的文件所在路径
* @param {string} recordId - 与上传文件相关联的记录ID
* @param {Object} options - (可选)包含上传器配置的对象,如 region
* @throws {Error} 如果缺少必要的参数,将抛出错误
*/
window.msgFromUniapp = function (accessKeyId, accessKeySecret, stsToken, fileName, filePath, recordId, options = {}) {
console.log(fileName, filePath)
if (!accessKeyId || !accessKeySecret || !stsToken || !fileName || !filePath) {
throw new Error('accessKeyId,accessKeySecret,stsToken,fileName,filePath is required')
}
try {
// 使用 Object.assign 合并默认配置参数和传入的 options 参数
const opt = Object.assign({ accessKeyId, accessKeySecret, stsToken, filePath, recordId }, options)
// 创建 OSSUpLoader 实例,传入配置对象
let uploader = new OSSUpLoader(opt)
// 调用 upload 方法上传文件,并在完成后处理结果
uploader.upload(fileName, function (result) {
// 通过 uni.postMessage 将上传结果作为数据发送
uni.postMessage({
data: {
...result,
fileName,
recordId,
filePath
}
})
// 调用 destroy 方法,这将重置上传器的状态,释放资源
uploader.destroy()
// 将 uploader 置为 null,释放内存
uploader = null
})
} catch (e) {
// 如果发生错误,将错误信息作为数据发送
uni.postMessage({
data: {
code: 1,
fileName,
filePath,
recordId,
options = {}
) {
console.log(fileName, filePath);
if (
!accessKeyId ||
!accessKeySecret ||
!stsToken ||
!fileName ||
!filePath
) {
throw new Error(
"accessKeyId,accessKeySecret,stsToken,fileName,filePath is required"
);
}
try {
// 使用 Object.assign 合并默认配置参数和传入的 options 参数
const opt = Object.assign(
{ accessKeyId, accessKeySecret, stsToken, filePath, recordId },
options
);
// 创建 OSSUpLoader 实例,传入配置对象
let uploader = new OSSUpLoader(opt);
// 调用 upload 方法上传文件,并在完成后处理结果
uploader.upload(fileName, function (result) {
// 通过 uni.postMessage 将上传结果作为数据发送
uni.postMessage({
data: {
...result,
fileName,
recordId,
filePath,
},
});
// 调用 destroy 方法,这将重置上传器的状态,释放资源
uploader.destroy();
// 将 uploader 置为 null,释放内存
uploader = null;
});
} catch (e) {
// 如果发生错误,将错误信息作为数据发送
uni.postMessage({
data: {
code: 1,
fileName,
recordId,
filePath,
error: e.message,
},
});
}
};
// }, false);
</script>
</body>
</html>
filePath,
error: e.message
}
})
}
}
// }, false);
</script>
</body>
</html>
\ No newline at end of file
......@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-07 17:09:53
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-08-30 14:49:02
* @LastEditTime: 2024-10-30 16:16:48
* @FilePath: \gl_tape\main.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -18,6 +18,7 @@ import wnCanvas from './components/Canvas/wn-canvas'
import UpdateBox from './components/UpdateBox'
import webView from './components/WebView'
import utils from './utils/utils'
import logger from './utils/logger'
Vue.use(webView)
Vue.component('GlsxImage', GlsxImage)
Vue.component('MessageBox', MessageBox)
......@@ -32,11 +33,12 @@ uni.$lock = false
uni.$storage = new Storage()
uni.$throttle = utils.throttle
uni.$isNetWork = utils.isNetWork
uni.$logger = logger
Vue.config.productionTip = false
App.mpType = 'app'
Vue.prototype.$ossDomain = config.OSS_DOMAIN
import permision from '@/js_sdk/wa-permission/permission.js'
import { index } from './env'
// import { index } from "./env";
// switch (uni.getSystemInfoSync().platform) {
// case "android":
// permision.requestAndroidPermission("android.permission.RECORD_AUDIO");
......@@ -48,15 +50,16 @@ import { index } from './env'
// break;
// }
Vue.prototype.$permision = permision
import sentryInit from '@/utils/sentryConfig/sentryInit'
if (index == 3 || index == 2) {
const sentry = sentryInit()
Vue.prototype.$sendSentry = function (e) {
sentry.captureException(e)
}
} else {
Vue.prototype.$sendSentry = function () {}
}
// import sentryInit from "@/utils/sentryConfig/sentryInit";
// if (index == 3) {
// const sentry = sentryInit();
// Vue.prototype.$sendSentry = function (e) {
// sentry.captureException(e);
// };
// } else {
// Vue.prototype.$sendSentry = function () {};
// }
const app = new Vue({
store,
......
{
"name" : "展业助手",
"appid" : "__UNI__D3BD3DF",
"description" : "",
"versionName" : "1.9.1",
"versionCode" : "100",
"transformPx" : false,
"name": "展业助手",
"appid": "__UNI__D3BD3DF",
"description": "",
"versionName": "2.1.0",
"versionCode": "100",
"transformPx": false,
/* 5+App特有相关 */
"app-plus" : {
"bounce" : "none",
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"screenOrientation" : "landscape",
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
"app-plus": {
"bounce": "none",
"usingComponents": true,
"nvueStyleCompiler": "uni-app",
"compilerVersion": 3,
"screenOrientation": "landscape",
"splashscreen": {
"alwaysShowBeforeRender": true,
"waiting": true,
"autoclose": true,
"delay": 0
},
/* 模块配置 */
"modules" : {
"Camera" : {},
"Record" : {},
"VideoPlayer" : {},
"AudioPlayer" : {}
"modules": {
"Camera": {},
"Record": {},
"VideoPlayer": {},
"AudioPlayer": {}
},
/* 应用发布信息 */
"distribute" : {
"distribute": {
/* android打包配置 */
"android" : {
"permissions" : [
"android": {
"permissions": [
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
......@@ -44,55 +44,59 @@
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ],
"targetSdkVersion" : 30
"abiFilters": [
"armeabi-v7a",
"arm64-v8a",
"x86"
],
"targetSdkVersion": 30
},
/* ios打包配置 */
"ios" : {
"dSYMs" : false,
"UIBackgroundModes" : "audio"
"ios": {
"dSYMs": false,
"UIBackgroundModes": "audio"
},
/* SDK配置 */
"sdkConfigs" : {
"ad" : {},
"speech" : {}
"sdkConfigs": {
"ad": {},
"speech": {}
},
"icons" : {
"android" : {
"hdpi" : "static/72.png",
"xhdpi" : "static/96.png",
"xxhdpi" : "static/144.png"
"icons": {
"android": {
"hdpi": "static/72.png",
"xhdpi": "static/96.png",
"xxhdpi": "static/144.png"
}
}
}
},
/* 快应用特有相关 */
"quickapp" : {},
"quickapp": {},
/* 小程序特有相关 */
"mp-weixin" : {
"appid" : "wx79d1ff39bee3d047",
"setting" : {
"urlCheck" : false
"mp-weixin": {
"appid": "wx79d1ff39bee3d047",
"setting": {
"urlCheck": false
},
"usingComponents" : true
"usingComponents": true
},
"mp-alipay" : {
"usingComponents" : true
"mp-alipay": {
"usingComponents": true
},
"mp-baidu" : {
"usingComponents" : true
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao" : {
"usingComponents" : true
"mp-toutiao": {
"usingComponents": true
},
"uniStatistics" : {
"enable" : false
"uniStatistics": {
"enable": false
},
"vueVersion" : "2",
"h5" : {
"devServer" : {
"port" : 8080,
"https" : false
"vueVersion": "2",
"h5": {
"devServer": {
"port": 8080,
"https": false
}
}
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"hammerjs": "^2.0.8",
"lodash": "^4.17.21",
"number-precision": "^1.6.0",
"prettier": "^3.3.2",
"webpack-spritesmith": "^1.1.0"
......
......@@ -175,7 +175,6 @@ export default {
watchStatus: {
handler (val) {
this.selectIndex = '全部'
// console.log(val)
// this.name = '';
// this.isSearch = false
// this.list = this.views
......@@ -232,7 +231,6 @@ export default {
this.isSelect = false
},
chooseType (val) {
console.log(val)
this.selectIndex = val.value
this.isSelect = false
this.getCaseList(this.selectIndex == '全部' ? '' : this.selectIndex, this.name)
......@@ -244,7 +242,6 @@ export default {
const params = { merchantId: shopMerchantId, category }
if (name) params.materialName = name
const res = await uni.$api.boutiqueApi.getCaseList(params)
console.log(res)
this.list = res.list
this.searchList = res.list
this.scrollTop = 1
......@@ -256,7 +253,6 @@ export default {
const userInfo = uni.$storage.get("userInfo"),
{ shopMerchantId } = userInfo;
const res = await uni.$api.boutiqueApi.getCategory({ merchantId: shopMerchantId })
console.log(res)
const _list = res.map(item => {
return {
label: item,
......@@ -265,7 +261,7 @@ export default {
})
this.selectList = [...this.selectList, ..._list]
},
clearCanvas () {
clearCanvas () {
this.$refs.caseCanvas.clearBoard()
},
},
......@@ -314,6 +310,7 @@ export default {
background: #ffffff;
border-radius: 16rpx;
padding: 16rpx 0;
animation: show-view-opacity 0.15s forwards;
.type-item {
padding: 0 24rpx;
margin-bottom: 8rpx;
......
......@@ -83,7 +83,7 @@
import NP from 'number-precision'
export default {
props: {
currentCar: String,
currentCar: [Number, String],
show: Boolean
},
data () {
......@@ -103,7 +103,6 @@ export default {
currentCar: {
immediate: true,
handler (newval) {
console.log(newval)
this.optionalsList = []
this.init()
}
......
......@@ -8,16 +8,29 @@
ref="receptionCanvas"
>
<template slot="customContent">
<view class="tab-box flex">
<template v-for="(item, index) in carList">
<view class="select-box flex">
<view
class="select flex"
@click.stop="showSelect"
>
{{currentCarString}}
<view
:key="index"
:class="['tab',`${currentIndex == index ? 'active' : ''}`]"
@click="changeCar(item)"
>
{{item}}
</view>
</template>
class="sprite-icon icon-arrow-bottom"
v-if="carList.length > 1 && !change_disabled"
></view>
</view>
<view
class="pop-box"
v-show="isSelect"
>
<template v-for="(i,index) in carList">
<view
:key="i.carModelId"
:class="['type-item flex',{active:i.carModelId == currentCarId},{'has-line':showLine(i,index)},{'is-first':index == 0}]"
@click="changeCar(i)"
>{{i.carModelName}}</view>
</template>
</view>
</view>
<view
class="risk-informed flex"
......@@ -46,18 +59,10 @@
>* 点击图片查看详情 &gt;</view>
</view>
</template>
<template v-else>
<view class="left-content">
<image
class="default"
:src="defaultImg"
/>
</view>
</template>
<view class="right-content">
<view :class="['sku-box',isPreview ? 'preview' : '']">
<sku-box
:currentCar="currentCarString"
:currentCar="currentCarId"
:defaultTabId="tabId"
:show="show && tabIndex == 0"
@changePreView="changePreView"
......@@ -73,7 +78,7 @@
</view>
<optional-table
v-show="tabIndex == 1"
:currentCar="currentCarString"
:currentCar="currentCarId"
:show="show && tabIndex == 1"
></optional-table>
<template v-if="hasOptionals">
......@@ -114,9 +119,6 @@ import CarBrands from '@/components/CarBrands.vue'
import CouponPop from './CouponPop.vue'
import RiskInformedBox from './RiskInformedBox.vue'
import OptionalTable from './OptionalTable.vue'
const m5 = require("@/assets/images/boutique/index/m5.png")
const m7 = require("@/assets/images/boutique/index/m7.png")
const m9 = require("@/assets/images/boutique/index/m9.png")
export default {
name: 'Reception',
components: { SkuBox, CarBrands, CouponPop, RiskInformedBox, OptionalTable },
......@@ -124,7 +126,7 @@ export default {
customerType: Number,
show: Boolean,
tabId: Number,
currentCar: String,
propCarId: [Number, String],
type: String,
popupImg: String,
madiaId: Number,
......@@ -132,7 +134,6 @@ export default {
},
data () {
return {
carList: ['M5', 'M7', 'M9'],
currentCarString: '',
customerInfo: {},
updateViewKey: Date.now(),
......@@ -140,7 +141,9 @@ export default {
currentImgUrl: '',
currentItem: null,
tabs: ['加装', '选装'],
tabIndex: 0
tabIndex: 0,
isSelect: false,
currentCarId: ''
}
},
watch: {
......@@ -150,26 +153,23 @@ export default {
this.customerInfo = newval
}
},
currentCar: {
propCarId: {
immediate: true,
handler (newval) {
this.currentCarString = newval
this.currentCarId = newval
this.currentCarString = this.carList.find(e => e.carModelId == newval)?.carModelName || ''
}
},
currentCarString: {
currentCarId: {
immediate: true,
handler (newval) {
if (!this.hasOptionals && this.tabIndex == 1) this.tabIndex = 0
this.defaultImg = {
'M5': m5,
'M7': m7,
'M9': m9,
}[newval]
if (this.show && newval && !this.isPreview && this.customerType == 1) {
uni.showLoading({
mask: true
})
this.$refs.carBrandRef.autoSelect(this.carList.findIndex(e => e == newval), false)
let item = this.carList.find(e => e.carModelId == newval)
this.$refs.carBrandRef.selectCar(item, true, newval)
}
}
},
......@@ -185,6 +185,7 @@ export default {
immediate: true,
handler (newval) {
if (newval) {
this.isSelect = false
if (newval && this.currentItem && this.tabIndex == 0) this.changePreView(this.currentItem, false, false)
}
}
......@@ -198,21 +199,18 @@ export default {
watchCustomerInfo () {
return this.$store.state.user.customerInfo
},
currentIndex () {
return this.carList.findIndex(e => e == this.currentCarString)
},
isPreview () {
return this.type == 'preview'
},
couponText () {
return this.customerType == 0 ? '查看客户券码' : '为客户发券'
},
change_disabled () {
return this.customerType == 0 || this.couponPopupRef.pageParams.QRURL
},
couponPopupRef () {
return this.$refs.couponPopup
},
change_disabled () {
return this.customerType == 0 || this.$refs?.couponPopup?.pageParams.QRURL
},
receptionTrack () {
return this.$store.state.user.receptionTrack
},
......@@ -221,16 +219,20 @@ export default {
},
hasOptionals () {
let flag = false
if (this.show) flag = this.boutiqueMediaConfig[this.currentCarString].optionals && this.boutiqueMediaConfig[this.currentCarString].optionals.length
if (this.show) flag = this.boutiqueMediaConfig[this.currentCarId].optionals && this.boutiqueMediaConfig[this.currentCarId].optionals.length
return flag
},
carList () {
return this.$store.state.user.boutiqueCarList
}
},
methods: {
changeCar (item) {
if (this.change_disabled || this.currentCarString == item) return uni.hideLoading()
this.currentCarString = item
if (this.change_disabled || this.currentCarId == item.carModelId) return uni.hideLoading()
this.currentCarString = item.carModelName
this.currentCarId = item.carModelId
this.isSelect = false
this.updateViewKey = Date.now()
this.clearCanvas()
},
......@@ -274,7 +276,7 @@ export default {
this.$emit('reception', e)
},
clearCustomerReceivedTimer () {
if (this.couponPopupRef.pageParams.qrTimer) {
if (this.couponPopupRef?.pageParams?.qrTimer) {
clearInterval(this.couponPopupRef.pageParams.qrTimer)
this.couponPopupRef.pageParams.qrTimer = null
}
......@@ -300,8 +302,18 @@ export default {
if (this.tabIndex == index) return
this.tabIndex = index
if (index == 1) this.previewLeave(this.currentItem)
else this.$refs.sku.changeCar(this.currentCarString)
else this.$refs.sku.changeCar(this.currentCarId)
this.clearCanvas()
},
showSelect () {
if (this.carList.length == 1 || this.change_disabled) return
this.isSelect = !this.isSelect
},
showLine (item, index) {
let result = true,
{ carList } = this
if (index != 0 && item.id == carList[index - 1].id) result = false
return result
}
}
}
......@@ -327,44 +339,64 @@ export default {
margin-left: 8rpx;
}
}
.tab-box {
.select-box {
padding-top: 66rpx;
position: fixed;
left: 0;
top: 0;
width: 100%;
justify-content: center;
.tab {
padding: 0 32rpx;
font-weight: 500;
z-index: 2;
.select {
color: #333333;
font-size: 36rpx;
color: #333333b3;
font-weight: 500;
line-height: 44rpx;
width: 130rpx;
text-align: center;
position: relative;
}
.active {
font-weight: 700;
color: #333333;
transition: all 1s;
&::after {
content: '';
position: absolute;
left: 50%;
width: 8rpx;
height: 8rpx;
background: #333333;
border-radius: 100%;
transform: translateX(-50%);
animation: show-dot 0.15s forwards;
.pop-box {
width: 272rpx;
border-radius: 16rpx;
background: #ffffff;
box-shadow: 0 0 16rpx 0 #99999933;
position: absolute;
top: 122rpx;
left: 50%;
transform: translateX(-50%);
padding: 12rpx 0;
animation: show-view-opacity 0.15s forwards;
.type-item {
padding: 0 24rpx;
margin: 8rpx 0;
height: 56rpx;
color: #292d33;
font-size: 28rpx;
position: relative;
&:first-child {
margin-top: 0;
}
&:last-child {
margin-bottom: 0;
}
&.active {
background-color: #ecf1ff;
}
}
@keyframes show-dot {
0% {
bottom: 16rpx;
.has-line {
margin-top: 18rpx;
&::after {
content: '';
width: calc(100% - 48rpx);
height: 2rpx;
background: #f5f5f5;
position: absolute;
left: 50%;
top: -10rpx;
transform: translateX(-50%);
}
100% {
bottom: -16rpx;
}
.is-first {
&::after {
display: none;
}
}
}
......
......@@ -87,7 +87,7 @@ export default {
name: 'SkuBox',
props: {
defaultTabId: Number,
currentCar: String,
currentCar: [Number,String],
show: Boolean
},
......
......@@ -42,7 +42,7 @@
:show="id == item.id"
@reception="reception"
:tabId="tabId"
:currentCar="currentCar"
:propCarId="currentCarId"
:type="type"
:popupImg="item.popupImg"
@preview="onPreview"
......@@ -118,7 +118,7 @@ export default {
customerType: Number,
toolList: Array,
tabId: Number,
currentCar: String
currentCarId: [Number, String]
},
mixins: [receptionTrackMixin],
data () {
......@@ -210,7 +210,8 @@ export default {
salesUuid: item.userId,
staffName: item.employeeName,
receiveCouponDate: item.receiveCouponDate,
customerCouponId: item.customerCouponId
customerCouponId: item.customerCouponId,
carSeriesId: item.carSeriesId
}
let [reception] = this.$refs.media1
reception?.clearCustomerReceivedTimer()
......
......@@ -127,7 +127,11 @@ export default {
watch: {
show: {
handler (val) {
if (val) this.init()
if (val) {
this.flag = false
this.list = []
this.init()
}
this.$refs.receptionTips?.close()
},
immediate: true
......@@ -137,7 +141,6 @@ export default {
methods: {
init () {
this.customerNameOrPhone = '';
console.log('init')
setTimeout(() => {
this.isSearch = false
this.pageNum = 1
......
<template>
<view
class="box"
:key="selectedUuid"
v-if="flag"
>
<view class="box" :key="selectedUuid" v-if="flag">
<template v-if="loginUserInfoList.length">
<template v-for="(item,index) in loginUserInfoList">
<view
:key="index"
:class="['items', `${item.active ? 'active' : ''}` ]"
@click="chooseAccount(item)"
>
<template v-for="(item, index) in loginUserInfoList">
<view :key="index" :class="['items', `${item.active ? 'active' : ''}`]" @click="chooseAccount(item)">
<view class="right">
<view :class="['midle', midle(item)]">
{{item.isSuper==true?'超管':item.userType==1?'商户':(item.loginRole == 3 ? '督导' : item.loginRole == 4 ? '驻店' : '员工')}}
{{ item.isSuper == true ? '超管' : item.userType == 1 ? '商户' : item.loginRole == 3 ? '督导' : item.loginRole == 4 ? '驻店' : '员工' }}
</view>
</view>
<view class="left">
<view class="name">
{{item.merchantName}}
</view>
<view class="shop_no">
商户号:{{item.merchantId}}
{{ item.merchantName }}
</view>
<view class="shop_no">商户号:{{ item.merchantId }}</view>
</view>
</view>
</template>
......@@ -33,7 +23,7 @@
</view>
</template>
<script type='text/ecmascript-6'>
<script type="text/ecmascript-6">
import { loginMixin } from '@/mixin/index'
import NoData from './NoData.vue'
export default {
......@@ -57,6 +47,7 @@ export default {
},
mounted () {
this.getListSelectAccount()
uni.$logger.local.info(`进入选择账号页面!`)
},
methods: {
getListSelectAccount (autoLogin = false) {
......@@ -99,10 +90,14 @@ export default {
},
async choiceAccountLogin () {
let { loginUserInfoList } = this,
id = null
id = null,
merchantName = null
console.log(loginUserInfoList,'loginUserInfoList')
loginUserInfoList.map(e => {
if (e.active) id = e.uuid
if (e.active) {
id = e.uuid
merchantName = e.merchantName
}
})
if (!id) {
......@@ -114,9 +109,10 @@ export default {
}
// 清空4s店数据
// app.globalData.storeListRange = []
this.selectAccountLogin(id)
this.selectAccountLogin(id,merchantName)
},
selectAccountLogin (id) {
selectAccountLogin (id,merchantName) {
uni.$logger.local.info(`选择账号${merchantName}登录!`)
uni.showLoading({
mask: true
})
......@@ -128,7 +124,8 @@ export default {
title: '获取4S店列表失败',
icon: 'none',
})
}).catch(() => {
}).catch((err) => {
uni.$logger.local.error(`获取4S店列表失败${err}!`)
uni.hideLoading()
})
},
......@@ -151,7 +148,7 @@ export default {
}
</script>
<style scoped lang='scss'>
<style scoped lang="scss">
.box {
display: flex;
align-items: center;
......@@ -239,4 +236,4 @@ export default {
border: 4rpx solid #347bff;
}
}
</style>
\ No newline at end of file
</style>
<template>
<view
class="box"
:key="selectMerchantId"
>
<view class="box" :key="selectMerchantId">
<template v-if="flag">
<template v-if="loginUserInfoList.length">
<template v-for="(item,index) in loginUserInfoList">
<view
:key="index"
:class="['items' ,{active:item.active}]"
@click="chooseAccount(item)"
>
<template v-for="(item, index) in loginUserInfoList">
<view :key="index" :class="['items', { active: item.active }]" @click="chooseAccount(item)">
<view class="right">
<view class="sprite-icon icon-store"></view>
</view>
<view class="left">
<view class="text_box">
<view class="name">{{item.merchantName}}</view>
<view class="text_no">商户号:{{item.merchantId}}</view>
<view class="name">{{ item.merchantName }}</view>
<view class="text_no">商户号:{{ item.merchantId }}</view>
</view>
</view>
</view>
</template>
</template>
......@@ -31,7 +23,7 @@
</view>
</template>
<script type='text/ecmascript-6'>
<script type="text/ecmascript-6">
import NoData from './NoData.vue'
export default {
......@@ -52,6 +44,7 @@ export default {
},
methods: {
init (userInfo) {
uni.$logger.info(`进入选择4s店页面!`)
this.userInfo = userInfo
this.getSceneArr()
},
......@@ -95,6 +88,7 @@ export default {
})
},
chooseAccount (item) {
uni.$logger.info(`选择4s店${item.merchantName}!`)
uni.showLoading({
mask: true
})
......@@ -158,7 +152,7 @@ export default {
}
</script>
<style scoped lang='scss'>
<style scoped lang="scss">
.box {
display: flex;
align-items: center;
......@@ -197,4 +191,4 @@ export default {
border: 4rpx solid #347bff;
}
}
</style>
\ No newline at end of file
</style>
<template>
<view class="box">
<template v-for="(item,index) in sceneList">
<view
:key="index"
:class="['items', `${item.actived ? 'active' : ''}` ]"
@click="selectScene(item,index)"
>
<template v-for="(item, index) in sceneList">
<view :key="index" :class="['items', `${item.actived ? 'active' : ''}`]" @click="selectScene(item, index)">
<view class="left">
<view :class="['sprite-icon', `icon-scene-${item.sceneType}`]"></view>
</view>
<view class="right">
<view class="name">
{{item.sceneName}}
{{ item.sceneName }}
</view>
<view class="shop_no">
{{item.sceneDesc}}
{{ item.sceneDesc }}
</view>
</view>
</view>
......@@ -22,7 +18,7 @@
</view>
</template>
<script type='text/ecmascript-6'>
<script type="text/ecmascript-6">
export default {
name: '',
data () {
......@@ -51,6 +47,7 @@ export default {
init (userInfo) {
this.userInfo = userInfo
this.getSceneArr()
uni.$logger.local.info(`进入选择场景页!`)
},
getSceneArr () {
uni.showLoading({
......@@ -72,6 +69,7 @@ export default {
},
// 选择场景
async selectScene ({ sceneType }, index) {
uni.$logger.local.info(`选择场景${sceneType}!`)
let { sceneList, openSceneArr, userInfo } = this
try {
if (!openSceneArr.includes(sceneType) && !userInfo?.isSuper) return uni.showToast({
......@@ -94,21 +92,21 @@ export default {
})
if (data) this.jump(userInfo, data)
else {
this.$sendSentry(`选择场景异常:merchantId:${userInfo.shopMerchantId},merchantName:${userInfo.shopMerchantName},sceneType:${sceneType},接口返回:${JSON.stringify(data || '')}`)
uni.$logger.local.error(`选择场景异常:merchantId:${userInfo.shopMerchantId},merchantName:${userInfo.shopMerchantName},sceneType:${sceneType},接口返回:${JSON.stringify(data || '')}`)
}
}
} catch (error) {
uni.hideLoading()
uni.showToast({
title: typeof error == "string" ? error : error.toString(),
icon: 'none'
})
console.log(error)
this.$sendSentry(`选择场景异常:merchantId:${userInfo?.shopMerchantId},merchantName:${userInfo?.shopMerchantName},sceneType:${sceneType},失败原因:${typeof error == "string" ? error : error.toString()}`)
uni.$logger.local.error(`选择场景异常:merchantId:${userInfo?.shopMerchantId},merchantName:${userInfo?.shopMerchantName},sceneType:${sceneType},失败原因:${typeof error == "string" ? error : error.toString()}`)
}
},
async jump (userInfo, data) {
uni.$logger.local.info(`跳转进入首页!`)
try {
uni.hideLoading()
if (data) userInfo.loginRoleOnSelectMerchant = data?.loginRoleOnSelectMerchant
......@@ -132,7 +130,7 @@ export default {
url
})
} catch (error) {
this.$sendSentry(`选择场景后跳转异常:${error}`)
uni.$logger.local.error(`选择场景后跳转异常:${error}!`)
uni.hideLoading()
uni.showToast({
title: error,
......@@ -144,7 +142,7 @@ export default {
}
</script>
<style scoped lang='scss'>
<style scoped lang="scss">
.box {
display: flex;
align-items: center;
......@@ -183,4 +181,4 @@ export default {
border: 4rpx solid #347bff;
}
}
</style>
\ No newline at end of file
</style>
......@@ -99,6 +99,7 @@ export default {
const { code, message } = await uni.$api.userApi.getSmsCode({ mobile });
uni.hideLoading();
if (code == '0') {
uni.$logger.local.info(`${mobile}发送验证码成功`)
uni.showToast({
title: '验证码已发送',
icon: 'none',
......@@ -106,6 +107,7 @@ export default {
this.countDown(60);
} else throw message || '发送验证码失败';
} catch (error) {
uni.$logger.local.info(`${mobile}发送验证码失败,失败原因:${error}`)
uni.hideLoading();
uni.showToast({
title: error,
......@@ -141,8 +143,11 @@ export default {
const { code, data, message } = await uni.$api.userApi.smsLogin(params);
console.log(code, data, message);
uni.hideLoading();
if (code == 0) this.jump(data, noSignIn)
else
if (code == 0) {
this.jump(data, noSignIn);
uni.$logger.local.info(`${mobile}登录`)
}
else {
uni.showModal({
title: '温馨提示',
content: message,
......@@ -150,7 +155,11 @@ export default {
confirmText: '知道了',
confirmColor: '#347BFF',
});
uni.$logger.local.info(`${mobile}登录失败,失败原因:${message}`)
}
} catch (error) {
uni.$logger.local.info(`${mobile}登录失败,失败原因:${error}`)
uni.hideLoading();
uni.showToast({
title: error,
......
......@@ -6,7 +6,10 @@
* @LastEditTime: 2024-04-18 11:24:22
-->
<template>
<view class="information-entry" v-if="showPayPage">
<view
class="information-entry"
v-if="showPayPage"
>
<view class="nav-bar">
<view
class="back"
......@@ -71,7 +74,7 @@
</view>
</template>
<script>
import {uploadFile} from "@/utils/ossUploadFile/uploadFile.js";
import { uploadFile } from "@/utils/ossUploadFile/uploadFile.js";
import utils from "@/utils/utils";
const INFO_LIST = [
{
......@@ -133,6 +136,7 @@ export default {
success: async (res) => {
// await upload(res.tempFilePath)
let url = await uploadFile(res.tempFilePaths[0])
uni.$logger.local.info(`上传付款凭证:${res.tempFilePaths[0]}`)
// this.$set(
// this.infoList[index],
// "imgUrl",
......@@ -142,6 +146,7 @@ export default {
this.setBooks(utils.deepClone(this.infoList))
},
fail: (err) => {
uni.$logger.local.error(`上传付款凭证失败:${typeof err == 'string' ? err : err.toString()}`)
console.log(err);
},
});
......
......@@ -137,22 +137,24 @@ export default {
if (newval.length) {
this.payInfo = newval.find(i => i.paymentType == 1) || {}
this.accountInfo = newval.find(i => i.paymentType == 2) || {}
this.handleSwitchTab(newval[0])
this.handleSwitchTab(newval[0], false)
}
}
},
},
methods: {
// 切换tab
handleSwitchTab (item) {
handleSwitchTab (item, isClick = true) {
this.payActive = item.type;
this.title = item.title
if (isClick) uni.$logger.local.info(`付款方式:${item.title}`)
},
// 显示弹窗
show () {
// this.payActive = 1
// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ,type 属性将失效 ,仅支持 ['top','left','bottom','right','center']
this.$refs.popup.open("bottom");
if(this.title) uni.$logger.local.info(`付款方式:${this.title}`)
},
close () {
this.$refs.popup.close();
......
......@@ -91,7 +91,7 @@ import FinishStep from '@/components/FinishStep.vue';
import { mapMutations } from "vuex";
import informationEntry from './components/informationEntry.vue'
import insurance from '@/components/Insurance/Insurance.vue'
import {receptionTrackMixin} from '@/mixin/index.js'
import { receptionTrackMixin } from '@/mixin/index.js'
export default {
components: {
ToolBox,
......@@ -152,10 +152,10 @@ export default {
const { channelType } = uni.$storage.get("userInfo")
return channelType == 2
},
isPreview(){
isPreview () {
return this.type == 'preview'
}
},
watch: {
watchStatus: {
......@@ -185,6 +185,7 @@ export default {
})
this.receptionTrackLeave()
this.$emit('update:id', e.id)
uni.$logger.local.info(`预览${e.title}`)
},
back () {
this.$refs?.toolRef?.hide()
......@@ -221,10 +222,11 @@ export default {
if (Math.abs(this.startY - touch.pageY) > 100) return
if (!scaleValueObject[id]) scaleValueObject[id] = 1
if (isDistanceSignificant && index != -1 && scaleValueObject[id] == 1 && !productModelStatus) {
const { nextId, modeName } = this.getNextId(index, toolList, startX, halfScreenWidth)
const { nextId, modeName, title } = this.getNextId(index, toolList, startX, halfScreenWidth)
this.modeName = modeName
this.receptionTrackLeave()
this.$emit('update:id', nextId)
uni.$logger.local.info(`预览${title}`)
setTimeout(() => {
this.modeName = ''
}, 500)
......@@ -234,25 +236,26 @@ export default {
}
},
getNextId (index, toolList, startX, halfScreenWidth) {
let nextId = '',
let nextItem = {},
modeName = ''
if (startX > halfScreenWidth) {
nextId = index === toolList.length - 1 ? toolList[0].id : toolList[index + 1].id;
nextItem = index === toolList.length - 1 ? toolList[0] : toolList[index + 1];
modeName = 'to-right'
} else {
nextId = index === 0 ? toolList[toolList.length - 1].id : toolList[index - 1].id;
nextItem = index === 0 ? toolList[toolList.length - 1] : toolList[index - 1];
modeName = 'to-left'
}
return {
nextId,
modeName
nextId: nextItem.id,
modeName,
title: nextItem.title
}
},
scale (e) {
let { id } = this
this.scaleValueObject[id] = e
},
},
};
......
......@@ -24,11 +24,8 @@ export default {
employeeList: [],
paymentType: [],
haveCustomerAccess: false,
boutiqueMediaConfig: {
M5: [],
M7: [],
M9: []
},
boutiqueMediaConfig: {},
boutiqueCarList:[],
receptionTrack: {}, //接待记录埋点
boutiqueDefaultCarBrandId: ''
};
......@@ -81,7 +78,7 @@ export default {
},
setReceptionTrack ({ state }, { key, value }) {
state.receptionTrack[key] = value
console.log(JSON.parse(JSON.stringify(state.receptionTrack)))
// console.log(JSON.parse(JSON.stringify(state.receptionTrack)))
},
clearReceptionTrack ({ state }) {
state.receptionTrack = {}
......
{
"id": "hyoga-uni-socket_io",
"name": "socket.io ui-app版",
"displayName": "socket.io ui-app版",
"version": "3.0.4",
"description": "适用于uni-app的socket.io封装,可用于uni-app、微信小程序",
"keywords": [
"socket.io",
"微信小程序"
],
"dcloudext": {
"category": [
"JS SDK",
"通用 SDK"
]
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/app-tape/'
export const DEFAULT_GET_STORAGEKEY = ['sessionId', 'merchantId', 'userInfo']
// 缓存get方法key的对应才映射值
export const STORAGE_OBJECTkEY = {
export const STORAGE_OBJECTKEY = {
DEFAULT_GET_STORAGEKEY,
mock_data: 'mock_data',
storageFile: 'storageFile',
......@@ -20,6 +20,7 @@ export const STORAGE_OBJECTkEY = {
recordList: 'recordList',
preRecordList: 'preRecordList',
preRecordId: 'preRecordId',
preAudioList: 'preAudioList',
recordSuccessList: 'recordSuccessList',
historyList: 'historyList',
storageVersion: 'storageVersion',
......
import Storage from './storage'
import storageApi from './storageApi'
module.exports = { Storage, storageApi }
\ No newline at end of file
import * as constData from './constantData'
module.exports = { Storage, storageApi,constData }
\ No newline at end of file
......@@ -2,7 +2,7 @@
* 微信小程序标准版:统一封装的 storage 操作类
*/
import { DEFAULT_GET_STORAGEKEY, STORAGE_OBJECTkEY } from './constantData'
import { DEFAULT_GET_STORAGEKEY, STORAGE_OBJECTKEY } from './constantData'
class Storage {
types = {
1: 'get', // get
......@@ -36,7 +36,7 @@ class Storage {
throw new Error(`Storage ${this.types[type]} func: key can not be empty`)
return false
}
// if STORAGE_OBJECTkEY[key]
// if STORAGE_OBJECTKEY[key]
return tmpKey
}
return key
......@@ -52,7 +52,7 @@ class Storage {
if (key) {
// 判断值是否是指定的对象值
let tmpKey = this.checkKeyType(key, 1)
let isObjectKey = STORAGE_OBJECTkEY[tmpKey]
let isObjectKey = STORAGE_OBJECTKEY[tmpKey]
// console.log(key)
// console.log(isObjectKey)
if (isObjectKey) {
......
......@@ -2,11 +2,11 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-16 09:55:40
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-10-16 13:51:15
* @LastEditTime: 2024-10-31 11:09:20
* @FilePath: \gl-tape\utils\cache\storageApi.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { STORAGE_OBJECTkEY } from './constantData'
import { STORAGE_OBJECTKEY } from './constantData'
// console.log(storage)
/** */
// 实例化对象存储
......@@ -68,13 +68,13 @@ export function setSystem_info(that) {
}
export function getRecords(record = 'recordList') {
return storage.get(STORAGE_OBJECTkEY[record])
return storage.get(STORAGE_OBJECTKEY[record])
}
export function setRecords(data, record = 'recordList') {
storage.set(STORAGE_OBJECTkEY[record], data)
storage.set(STORAGE_OBJECTKEY[record], data)
}
export function removeRecords(record = 'recordList') {
storage.rm(STORAGE_OBJECTkEY[record])
storage.rm(STORAGE_OBJECTKEY[record])
}
export default {
getSessionId,
......
const WsTyps = {
MessageTypes: {
Private: 'private',
System: 'system'
},
Connected:'connect',
Eroor:'error',
Disconnected:'disconnect'
}
export {
WsTyps
}
export * from './constants'
import LogCat from './LogCat'
import { LogLevel } from './constants'
import { getTime, withinSpliter, daysBetween } from './util'
class LocalLog {
logger = null
constructor() {
this.logger = new LogCat()
// this.logger = { }
}
debug(msg) {
this.logger.writeLog(LogLevel.DEBUG, msg)
}
info(msg) {
this.logger.writeLog(LogLevel.INFO, msg)
}
warn(msg) {
this.logger.writeLog(LogLevel.WARN, msg)
}
error(msg) {
this.logger.writeLog(LogLevel.ERROR, msg)
}
getFiles(beginDate, endDate) {
const logFiles = this.logger.getLogFileList()
if ((!beginDate && !endDate) || !logFiles.length) return logFiles
beginDate = +withinSpliter(beginDate)
endDate = +withinSpliter(endDate)
// prettier-ignore
const fileList = logFiles.reduce((list,{name,path}) => {
const fileDate= +withinSpliter(name.split('.').shift())
if(fileDate>=beginDate && fileDate<=endDate){
list.push(path)
}
return list
},[]);
// console.log('fileList', fileList)
// this.logger.zip(fileList)
return fileList
}
removeOverDays(day = 7) {
const logFiles = this.logger.getLogFileList()
if (!logFiles.length) return
const today = getTime('YYYY-MM-DD')
logFiles.forEach(({ name, path }) => {
const fileDate = name.split('.').shift()
if (daysBetween(fileDate, today) > day) {
this.logger.removeLogFile(path)
}
})
}
}
export default LocalLog
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-11-01 15:06:40
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-11-19 09:25:11
* @FilePath: \gl-tape\utils\logger\LogCat.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { getTime } from './util'
class LogCat {
main = plus.android.runtimeMainActivity()
File = plus.android.importClass('java.io.File')
Environment = plus.android.importClass('android.os.Environment')
BufferedWriter = plus.android.importClass('java.io.BufferedWriter')
FileOutputStream = plus.android.importClass('java.io.FileOutputStream')
OutputStreamWriter = plus.android.importClass('java.io.OutputStreamWriter')
// BufferedReader = plus.android.importClass('java.io.BufferedReader')
// FileInputStream = plus.android.importClass('java.io.FileInputStream')
// InputStreamReader = plus.android.importClass('java.io.InputStreamReader')
LogPath = ''
constructor(folderName = '_zyzs_log') {
if (this.Environment.MEDIA_MOUNTED || !this.Environment.isExternalStorageRemovable()) {
this.LogPath = this.main.getExternalFilesDir(null).getPath() + folderName
} else {
this.LogPath = this.main.getFilesDir().getPath() + folderName
}
console.log('日志文件存放路径->', this.LogPath)
}
writeLog(tag, msg) {
let date = getTime('YYYY-MM-DD')
let datetime = getTime()
//文件名
let fileName = this.LogPath + '/' + date + '.txt'
//写入的内容
if (typeof msg == 'object') {
msg = JSON.stringify(msg)
}
let content = `${datetime} [${tag}] : ${msg}\n`
console.log(content.replace(/\n/g, ''))
let path = new this.File(this.LogPath)
if (!path.exists()) {
path.mkdirs() //创建父路径
}
let fos = null
let bw = null
try {
fos = new this.FileOutputStream(fileName, true)
bw = new this.BufferedWriter(new this.OutputStreamWriter(fos))
//bw.write(log);
bw.append(content)
} catch (e) {
console.log('e->', e)
} finally {
try {
if (bw != null) {
bw.close() //关闭缓冲流
fos.close() //关闭文件输出流
}
} catch (closeEx) {
console.log('closeEx->', closeEx)
}
}
}
// 删除日志
removeLogFile(fileName) {
let file = new this.File(fileName)
let fos = new this.FileOutputStream(fileName, true)
fos.close()
file.delete()
console.log('删除------' + fileName)
}
// 获取所有日志文件列表
getLogFileList() {
let file = new this.File(this.LogPath)
let tempList = file.listFiles()
if (!tempList || tempList.length === 0) return []
const list = tempList.map(file => {
return {
name: file.getName(),
path: file.getPath()
}
})
return list
}
}
export default LogCat
import sentryInit from '@/utils/sentryConfig/sentryInit'
import { LogLevel , RemoteExtraDataKey} from './constants'
class RemoteLog {
sentry = null
constructor(user) {
this.sentry = sentryInit()
this.sentry.setUser(user)
}
debug(info) {
this.send(LogLevel.DEBUG, info)
}
info(info) {
this.send(LogLevel.INFO, info)
}
warn(info) {
this.send(LogLevel.WARN, info)
}
error(info) {
this.send(LogLevel.ERROR, info)
}
send(level, { extra = {}, msg, tag = { key: '', value: '' } }) {
this.sentry.withScope(scope => {
scope.setTags(tag.key, tag.value)
scope.setExtra(RemoteExtraDataKey, extra)
scope.setLevel(level)
this.sentry.captureException(new Error(msg))
})
}
}
export default RemoteLog
export const LogLevel = {
DEBUG: 'debug',
INFO: 'info',
WARN: 'warn',
ERROR: 'error'
}
export const RemoteExtraDataKey = 'data'
// import { index } from './env'
import RemoteLog from './RemoteLog'
import LocalLog from './LocalLog'
import { LogLevel } from './constants'
import { storageApi } from '../cache'
import { getIp } from './util'
class Logger {
remote = null
local = null
fields = []
constructor(fields = []) {
this.fields = fields
this.init()
}
init() {
const user = this.getUserInfo()
this.remote = new RemoteLog(user)
this.local = new LocalLog()
}
debug(info) {
this.write(LogLevel.DEBUG, info)
}
info(info) {
this.write(LogLevel.INFO, info)
}
warn(info) {
this.write(LogLevel.WARN, info)
}
error(info) {
this.write(LogLevel.ERROR, info)
}
write(level, info) {
this.remote[level](info)
this.local[level](info)
}
getUserInfo() {
const userInfo = storageApi.getUserInfo()
// const ip = await getIp()
const user = this.fields.reduce((pre, cur) => {
pre[cur] = userInfo[cur]
return pre
}, {})
user.name = userInfo.name
user.merchantName = userInfo.merchantName
// user.ip = ip
return user
}
}
export default new Logger()
/**
*获取各种时间格式
* @style 1. hh:mm:ss 时:分:秒
* 2.YYYY-MM-DD 年-月-日
* 3.YYYYMMDD 年月日
* 4.YYYY-MM-DD hh:mm:ss 年-月-日 时:分:秒
* 5.YYYYMMDDhhmmss 年月日时分秒
* 6.DD 日
* 7.getDay 获取当前星期几
* 8.hhmmss 时分秒
* */
const getTime = style => {
let time = new Date()
let times = ''
//获取年月日
let yyyy = time.getFullYear()
let mm = time.getMonth()
mm = mm >= 9 ? mm + 1 : '0' + (mm + 1)
let dd = time.getDate()
dd = dd >= 10 ? dd : '0' + dd
//获取时分秒
let h = time.getHours()
h = h >= 10 ? h : '0' + h
let m = time.getMinutes()
m = m >= 10 ? m : '0' + m
let s = time.getSeconds()
s = s >= 10 ? s : '0' + s
// 获取星期
let z = time.getDay()
z = '0' + z
if (style === 'YYYY-MM-DD') {
times = yyyy + '-' + mm + '-' + dd
}
if (style === 'hh:mm:ss') {
times = h + ':' + m + ':' + s
}
if (style === 'YYYYMMDD') {
times = yyyy + '' + mm + '' + dd
}
if (style === 'YYYY') {
times = yyyy + ''
}
if (style === 'MM') {
times = mm + ''
}
if (style === 'DD') {
times = dd + ''
}
if (style === 'YYYY-MM-DD hh:mm:ss' || !style) {
times = yyyy + '-' + mm + '-' + dd + ' ' + h + ':' + m + ':' + s
}
if (style === 'YYYYMMDDhhmmss') {
times = yyyy + '' + mm + '' + dd + '' + h + '' + m + '' + s
}
if (style === 'DD') {
times = dd + ''
}
if (style === 'getDay') {
times = z + ''
}
return times
}
const getIp = () => {
return new Promise((resolve, reject) => {
uni.request({
url: 'https://api.ipify.org', // 这是一个提供获取客户端公网IP服务的简单API
method: 'GET',
success: res => {
const ip = res.data
resolve(ip)
},
fail: err => {
reject(err)
}
})
})
}
const withinSpliter = (dateStr) => {
return dateStr.replace(/[-\/]/g, '')
}
const daysBetween = (startDate, endDate) => {
const start = new Date(startDate)
const end = new Date(endDate)
const days = (end - start) / (1000 * 60 * 60 * 24)
return Math.floor(days)
}
export { getTime, getIp, withinSpliter, daysBetween }
......@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-10-14 17:38:35
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-10-18 18:09:15
* @LastEditTime: 2024-11-20 17:27:29
* @FilePath: \gl-tape\utils\recordManager\interruptRecord.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -10,6 +10,7 @@ import RecordManager from '../RecordManager.js'
import utils from '@/utils/utils.js'
import { storageApi } from '../cache'
import store from '@/store'
let Interval = null
class InterruptRecord extends RecordManager {
constructor() {
super()
......@@ -22,6 +23,7 @@ class InterruptRecord extends RecordManager {
}
records = {}
pathName = null
audioPath = null
/**
* 获取记录列表
*
......@@ -47,8 +49,10 @@ class InterruptRecord extends RecordManager {
*
*/
removePreRecord(id) {
uni.$logger.local.info(`删除待提交的记录${id}`)
this.removeRecord(id)
storageApi.setRecords('', 'preRecordId')
clearInterval(Interval)
}
/**
* 初始化保存记录
......@@ -57,15 +61,14 @@ class InterruptRecord extends RecordManager {
* @returns {void} - 此函数不返回任何值
*/
async addPreRecords(params) {
console.log(storageApi.getRecords('preRecordId'), 6666)
if (storageApi.getRecords('preRecordId')) {
uni.$logger.local.info(`添加录音${storageApi.getRecords('preRecordId')}`)
this.addPreAudio()
return
}
console.log('pathName')
const pathName = await this.getAudioPathName()
const audioPath = await this.getAudioPath(pathName)
this.audioPath = audioPath
const id = utils.uuid()
storageApi.setRecords(id, 'preRecordId')
const ids = storageApi.getRecords('preRecordId')
......@@ -75,22 +78,63 @@ class InterruptRecord extends RecordManager {
...params,
audioPath: [audioPath]
}
uni.$logger.local.info(`开始保存记录${id}`)
const records = this.getRecords() || []
records.push(this.records)
this.setRecords(records)
this.setLoopAudio()
storageApi.setRecords('', 'preAudioList')
}
/**
* 30s保存录音文件
*
*/
setLoopAudio() {
Interval = setInterval(() => {
this.updateAudio()
}, 1000 * 30)
}
async updateAudio() {
const len = this.records.audioPath.length - 1
const saveResult = await uni.saveFile({
tempFilePath: this.audioPath
})
const preAudioList = storageApi.getRecords('preAudioList') || []
const filePath = preAudioList[len]
const savedFilePath = saveResult[1].savedFilePath
if (filePath) {
uni.removeSavedFile({
filePath: filePath,
complete: () => {
console.log('complete')
}
})
}
preAudioList[len] = savedFilePath
console.log(preAudioList, 'preAudioList')
storageApi.setRecords(preAudioList, 'preAudioList')
}
get getPreAudioList() {
return storageApi.getRecords('preAudioList')
}
/**
* 添加录音文件
*
* @returns {void} - 此函数不返回任何值
*/
async addPreAudio() {
clearInterval(Interval)
this.updateAudio()
const pathName = await this.getAudioPathName()
const audioPath = await this.getAudioPath(pathName)
this.audioPath = audioPath
const addAudioPath = [...this.records.audioPath, audioPath]
this.records.audioPath.push(audioPath)
const records = this.getPreRecord()
const params = { ...records, ...this.records }
const params = { ...records, audioPath: addAudioPath }
this.updateRecord(params)
this.setLoopAudio()
}
/**
* 更新参数
......@@ -99,7 +143,9 @@ class InterruptRecord extends RecordManager {
*/
updatePreRecords(params, isRemoveId) {
if (isRemoveId) {
uni.$logger.local.info(`清除正在接待记录的id`)
storageApi.setRecords('', 'preRecordId')
clearInterval(Interval)
}
const updateParams = { ...this.records, ...params }
console.log(updateParams, 'updateParams')
......@@ -174,17 +220,39 @@ class InterruptRecord extends RecordManager {
var dirR = e.createReader()
dirR.readEntries(
function (er) {
for (var i = 0; i < er.length; i++) {
if (er[i].name.startsWith('uniapp_temp')) {
resolve(er[i].name)
}
// er[i].getMetadata(function (metadata) {
// console.log(metadata.modificationTime, '修改时间')
// })
}
Promise.all(
er.map((item, index) => {
console.log(item, 'item')
return new Promise(resolve => {
item.getMetadata(metadata => {
resolve({
index: index,
name: item.name,
modificationTime: new Date(metadata.modificationTime).getTime()
})
})
})
})
).then(results => {
console.log(results, 'results')
results = results.filter(i => i.name.startsWith('uniapp_temp'))
// 找到修改时间最晚的文件
const latest = results.reduce(
(acc, current) => {
if (current.modificationTime > acc.modificationTime) {
return current
}
return acc
},
{ modificationTime: 0 }
)
// 修改时间最晚的文件名
resolve(latest.name)
})
},
err => {
console.log(err)
reject(err)
}
)
},
......
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 17:16:46
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-09-23 17:40:40
* @LastEditors: limin
* @LastEditTime: 2024-11-07 15:56:05
* @FilePath: \gl_tape\utils\utils.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -17,7 +17,7 @@ function convertDateTimeFormat(dateTimeStr, separator = '-') {
return `${year}${separator}${month}${separator}${day} ${hours}:${minutes}:${seconds}`
}
function deepClone(value) {
export function deepClone(value) {
// 排除原始类型的情况,函数时也满足此条件
if (typeof value !== 'object' || value === null) {
return value
......@@ -174,6 +174,17 @@ async function getAudioFilePath(path = '') {
const rootPath = await getFilePath()
return `file://${rootPath}${path}`
}
export function serializeIfObject(msg) {
return typeof msg === 'object' ? JSON.stringify(msg) : msg.toString()
}
export function isInteger(value) {
if (typeof value === 'number') {
return Number.isInteger(value);
} else if (typeof value === 'string') {
return /^-?\d+$/.test(value);
}
return false;
}
export default {
compareVersions,
convertDateTimeFormat,
......@@ -185,5 +196,6 @@ export default {
uuid,
getFilePath,
getFileSaveFolderOnClient,
serializeIfObject,
getAudioFilePath
}
import WorkerFactory from './WorkerFactory'
export default class CommandFactory {
store = new Map()
static instance = null
constructor() {
if (this.instance) {
return this.instance
}
this.instance = this
}
static getInstance() {
if (!CommandFactory.instance) {
CommandFactory.instance = new CommandFactory()
}
return CommandFactory.instance
}
dispatch(cmd) {
const Worker = WorkerFactory.create(cmd)
if (!Worker) {
throw new Error('未找到对应的Worker')
}
// if (!this.store.has(Worker.name)) {
// this.store.set(Worker.name, new Worker())
// }
// return this.store.get(Worker.name)
return new Worker()
}
clear() {
this.store.clear()
this.instance = null
}
}
import LogsWorker from './workers/LogsWorker'
import CommonWorker from './workers/CommonWorker'
import MessageWorker from './workers/MessageWorker'
import StorageWorker from './workers/StorageWorker'
import RemoveLogWorker from './workers/RemoveLogWorker'
import GetLogListWorker from './workers/GetLogListWorker'
import StopPollingWorker from './workers/StopPollingWorker'
import RemoveRecordWorker from './workers/RemoveRecordWorker'
import StartPollingWorker from './workers/StartPollingWorker'
import SetPollingIntervalWorker from './workers/SetPollingIntervalWorker'
import { Command } from './constants'
const Workers = {
[Command.GetLog]: LogsWorker,
[Command.Message]: MessageWorker,
[Command.RemoveLog]: RemoveLogWorker,
[Command.GetStorage]: StorageWorker,
[Command.GetLogList]: GetLogListWorker,
[Command.StopPolling]: StopPollingWorker,
[Command.RemoveRecord]: RemoveRecordWorker,
[Command.StartPolling]: StartPollingWorker,
[Command.SetPollingInterval]: SetPollingIntervalWorker
}
export default {
create: cmd => Workers[cmd] || CommonWorker
}
import io from '@/uni_modules/hyoga-uni-socket_io/uni-socket.io.js'
import { WsTyps } from '../utils/common'
import CommandFactory from './CommandFactory'
import config from '@/config.js'
import { serializeIfObject,deepClone } from '@/utils/utils.js'
// const WsTyps = common.constants.WsTyps
export class Ws {
wsAddress
loginAddress
token
deviceId
onMessage
ws
constructor() {
this.wsAddress = config.SOCKET_SERVER
this.loginAddress =`${config.HTTP_SERVER}/login`
}
async connect() {
const { code, data, ...o } = await this.login()
if (code == 200) {
this.deviceId = data.id
this.token = data.token
this.ws = io(this.wsAddress, {
path:'/websocket/',
auth: { token: this.token, deviceId: this.deviceId },
transports: ['websocket'],
timeout: 5000
})
this.subscribe()
} else {
uni.$logger.local.error(`登录失败 -> ${serializeIfObject({ code, data, o })}`)
}
}
async login() {
const sysInfo = uni.getSystemInfoSync()
// const userInfo = uni.$storage.get('userInfo')
// ;(userInfo.name = '胡悦'), (userInfo.phone = '18754575574')
if (!sysInfo?.deviceId) return uni.$logger.local.error('未获取到系统设备信息')
// sysInfo.deviceId='4DF8801064461802495A2452CCD04EE4'
// const { name: user, phone: mobile, merchantName } = userInfo
uni.$logger.local.info(`========WS,用户登录 ${JSON.stringify({deviceId:sysInfo.deviceId})}========`)
console.log(this.loginAddress)
return new Promise((resolve, reject) => {
uni.request({
url: this.loginAddress,
data: { sn: sysInfo.deviceId },
method: 'POST',
dataType: 'json',
success(response) {
resolve(response.data)
},
fail(err) {
uni.$logger.local.error(`登录失败, 请检查网络或联系管理员! err->${serializeIfObject(err)}`)
}
})
})
}
subscribe() {
this.ws.on(WsTyps.Connected, () => {
uni.$logger.local.info('========WebSocket 连接成功========')
})
this.ws.on(
WsTyps.MessageTypes.Private,
function (data) {
uni.$logger.local.info(`WebSocket 收到消息 -> ${JSON.stringify(data)}`)
if (data.errorCode && data.errorCode == 907) return this.connect()
const _data = deepClone(data)
const worker = CommandFactory.getInstance().dispatch(_data.command)
worker.work(this.deviceId, _data, this)
this.onMessage && this.onMessage(_data)
}.bind(this)
)
this.ws.on(WsTyps.MessageTypes.System, function (data) {
uni.$logger.local.info(`========WebSocket 收到系统消息 ${serializeIfObject(data)}========`)
})
this.ws.on(WsTyps.Disconnected, () => {
CommandFactory.getInstance().clear()
uni.$logger.local.info(`========WebSocket 断开连接 device_id->${this.deviceId}========`)
})
this.ws.on(WsTyps.Eroor, msg => {
CommandFactory.getInstance().clear()
uni.$logger.error(`========WebSocket 异常 device_id->${this.deviceId} msg ->${serializeIfObject(msg)}========`)
})
}
send(data, type = WsTyps.MessageTypes.Private) {
this.ws.emit(type, { device_id: this.deviceId, ...data })
}
}
const Command = {
GetLog: 'getLog',
GetStorage: 'getStorage',
Message: 'message',
GetLogList: 'getLogList',
RemoveLog:'removeLog',
RemoveRecord:'removeRecord',
StopPolling:'stopPolling',
StartPolling:'startPolling',
SetPollingInterval:'setPollingInterval'
}
export { Command }
import { serializeIfObject } from '@/utils/utils.js'
export default class CommonWorker {
constructor() {}
work(deviceId, data) {
uni.$logger.local.info(`收到WebSocket 消息: deviceId->${deviceId}, data->${serializeIfObject(data)}`)
// console.log(`收到WebSocket 消息: deviceId->${deviceId}, data->${typeof data ==='[object Object]'?JSON.stringify(data):data}`)
}
}
import { serializeIfObject } from '@/utils/utils.js'
export default class GetLogListWorker {
constructor() {}
work(deviceId, data, ws) {
try {
const beginDate = data.beginDate
const endDate = data.endDate
const LogList = uni.$logger.local.getFiles(beginDate, endDate)
uni.$logger.local.info(`获取日志列表成功! beginDate ->${beginDate} endDate-> ${endDate} res->${serializeIfObject(LogList)}`)
ws.send({ LogList })
} catch (error) {
uni.$logger.local.error(`获取日志列表失败! beginDate ->${beginDate} endDate-> ${endDate} error->${serializeIfObject(error)}`)
}
}
}
import config from '@/config.js'
import { serializeIfObject,deepClone } from '@/utils/utils.js'
export default class LogsWorker {
logFile = null
constructor() {
this.logFile = uni.$logger.local.logger
this.isUploading = false
this.files = []
}
getLogFileList() {
return this.logFile.getLogFileList()
}
upload(deviceId, data) {
if (this.isUploading) {
const msg = `日志上传中,请稍后再试!`
uni.$logger.local.info(msg)
this.ws.send(msg)
return
}
this.isUploading = true
const files = this.getLogFileList()
this.files = JSON.stringify(files)
if (files?.length) {
files.sort((a, b) => a.name.localeCompare(b.name))
this.process(files, deviceId)
}
}
async process(files, deviceId) {
if (files.length > 0) {
const file = files.shift()
await this.post(file, deviceId)
setTimeout(() => this.process(files, deviceId), 500)
} else {
this.ws.send({ code: 200, msg: `日志上传完成 logs -> ${this.files}`})
this.isUploading = false
this.files=[]
}
}
post({ name, path }, deviceId) {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: `${config.HTTP_SERVER}/${config.FILE_UPLOAD_URL}`,
filePath: path,
name: 'file',
header: {
'Content-Type': 'multipart/form-data'
},
formData: {
deviceId,
type: 'log'
},
success: res => {
uni.$logger.local.info(`文件上传成功! res->${serializeIfObject(res)} filePath->${path}`)
resolve()
},
fail: res => {
uni.$logger.local.error(`文件上传失败! res->${serializeIfObject(res)} filePath->${path} .`)
resolve()
}
})
})
}
work(deviceId, data, ws) {
this.ws = ws
this.upload(deviceId, data)
}
}
import { serializeIfObject } from '@/utils/utils.js'
export default class MessageWorker {
constructor() {}
work(deviceId, data) {
uni.$logger.local.info(`收到WebSocket 消息: deviceId->${deviceId}, data->${serializeIfObject(data)}`)
// console.log(`收到WebSocket 消息: deviceId->${deviceId}, data->${typeof data ==='[object Object]'?JSON.stringify(data):data}`)
}
}
import { isInteger } from '@/utils/utils.js'
export default class RemoveLogWorker {
constructor() {}
work(deviceId, data, ws) {
//参数可以不传,默认7天
const days = data.days
if (!isInteger(days) || days==0) {
const error = `RemoveLogWorker -> 删除日志: 参数错误!days 必需为数字! days -> ${days} `
ws.send({ error, data })
uni.$logger.local.error(error)
return
}
uni.$logger.local.removeOverDays(days)
const msg = `删除${days}天前的日志成功!`
uni.$logger.local.info(msg)
ws.send({ code: 200, msg: msg, data })
}
}
import { serializeIfObject } from '@/utils/utils.js'
export default class RemoveRecordWorker {
constructor() {}
async work(deviceId, data, ws) {
const recordId = data.id
if (!recordId) {
const msg = `删除接待记录,缺少记录id`
uni.$logger.local.info(msg)
ws.send({ error: msg })
return
}
const unlock = await uni.$recordManager.lock()
try {
const records = uni.$recordManager.getRecords()
const record = records.find(item => item.id === recordId)
if (!record) {
const msg = `记录不存在 id -> ${recordId}`
uni.$logger.local.info(msg)
ws.send({ error: msg })
return
}
uni.$recordManager.removeRecord(recordId)
const msg = `记录删除成功 id -> ${recordId}`
uni.$logger.local.info(msg)
ws.send({ code: 200, msg })
} catch (error) {
const msg = `记录删除异常 id -> ${recordId} error -> ${serializeIfObject(error)}`
uni.$logger.local.error(msg)
ws.send({ error: error,recordId })
} finally {
unlock()
}
}
}
import { isInteger } from '@/utils/utils.js'
export default class SetPollingIntervalWorker {
constructor() {}
work(deviceId, data, ws) {
const interval = data.interval
const isForce = !!data.force
if (!isInteger(interval)) {
const error = `SetPollingIntervalWorker -> 设置轮询时间间隔: 参数错误!interval 必需为数字! interval -> ${interval} `
ws.send({ error, data })
uni.$logger.local.error(error)
return
}
uni.$emit(data.command, interval,isForce)
ws.send({ code: 200, msg: `设置轮询间隔时间成功!当前间隔时间为 -> ${interval} s`, data })
}
}
export default class StartPollingWorker {
constructor() {}
work(deviceId, data, ws) {
const isForce = !!data.force
uni.$emit(data.command, isForce)
const msg = `启动轮询指令下发并执行成功!`
ws.send({ code: 200, msg, data })
}
}
export default class StopPollingWorker {
constructor() {}
work(deviceId, data, ws) {
uni.$emit(data.command)
const msg = `终止轮询指令下发并执行成功!`
ws.send({ code: 200, msg, data })
}
}
import { constData } from '../../utils/cache'
import { serializeIfObject } from '@/utils/utils.js'
export default class StorageWorker {
constructor() {}
work(deviceId, data, ws) {
let key = data.key
if (!constData.STORAGE_OBJECTKEY[key]) {
uni.$logger.local.error(`不存在的 Storage Key->${key}. data->${serializeIfObject(data)}`)
console.log(`不存在的 Storage Key->${key}.`)
return
}
const value = uni.$storage.get(key)
const msg = `获取本地缓存! key->${key} value->${serializeIfObject(value)}`
uni.$logger.local.info(msg)
ws.send({ [key]: value })
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!