Commit 81ea7e63 by 前端

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

上线合并

See merge request !18
2 parents 29309f7d a56c2962
Showing 60 changed files with 1205 additions and 335 deletions
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-07 17:09:53 * @Date: 2024-04-07 17:09:53
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-09-24 11:01:24 * @LastEditTime: 2024-10-31 11:01:19
* @FilePath: \gl_tape\App.vue * @FilePath: \gl_tape\App.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
--> -->
<script> <script>
const PATH = ['/pages/common/caseDetail'] const PATH = ['/pages/common/caseDetail']
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update-nvue.js'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import utils from '@/utils/utils' import { Ws } from '@/ws/Ws.js'
export default { export default {
computed: { computed: {
...mapState('audio', ['isEnd', 'isStart']) ...mapState('audio', ['isEnd', 'isStart'])
}, },
onLoad() {},
onLaunch: async function () { onLaunch: async function () {
// this.init() // this.init()
this.setAPPVersion() this.setAPPVersion()
...@@ -25,28 +25,9 @@ export default { ...@@ -25,28 +25,9 @@ export default {
uni.setKeepScreenOn({ uni.setKeepScreenOn({
keepScreenOn: true keepScreenOn: true
}) })
new Ws().connect()
}, },
methods: { 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() { init() {
uni.addInterceptor('navigateTo', { uni.addInterceptor('navigateTo', {
//监听跳转 //监听跳转
...@@ -100,7 +81,7 @@ export default { ...@@ -100,7 +81,7 @@ export default {
}, },
onShow: async function () { onShow: async function () {
this.handleCheck() uni.$logger.local.info('切回app')
// const systemInfo = await uni.$api.systemApi.getMockData(); // const systemInfo = await uni.$api.systemApi.getMockData();
// if (systemInfo.isCheckedUpdate) { // if (systemInfo.isCheckedUpdate) {
// checkUpdate(); // checkUpdate();
...@@ -111,9 +92,15 @@ export default { ...@@ -111,9 +92,15 @@ export default {
// this.$store.dispatch("openUpdateModal"); // this.$store.dispatch("openUpdateModal");
// }); // });
}, },
onHide: function () {}, onHide: function () {
uni.$logger.local.info('切出app')
},
onError: function (e) { 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> </script>
......
adb connect 127.0.0.1:16384
...@@ -98,15 +98,12 @@ export default { ...@@ -98,15 +98,12 @@ export default {
mounted () { mounted () {
}, },
methods: { methods: {
autoSelect (index = 0, autoHideLoading = true) { autoSelect () {
const { carBrandList, boutiqueDefaultCarBrandId } = this const { carBrandList, boutiqueDefaultCarBrandId } = this
let carIndex = 0 let carIndex = 0
if (boutiqueDefaultCarBrandId) { if (boutiqueDefaultCarBrandId) carIndex = carBrandList.findIndex(e => e.id == boutiqueDefaultCarBrandId)
carIndex = carBrandList.findIndex(e => e.id == boutiqueDefaultCarBrandId)
if (carIndex < 0) carIndex = 0 if (carIndex < 0) carIndex = 0
} if (carBrandList.length) this.selectCar(carBrandList[carIndex], true)
if (index < 0) index = 0
if (carBrandList.length) this.selectCar(carBrandList[carIndex], true, index, autoHideLoading)
}, },
open () { open () {
const userInfo = uni.$storage.get("userInfo"), const userInfo = uni.$storage.get("userInfo"),
...@@ -140,8 +137,13 @@ export default { ...@@ -140,8 +137,13 @@ export default {
this.$refs.carBrandListVisible.open() this.$refs.carBrandListVisible.open()
this.carBrandListOff = true this.carBrandListOff = true
}, },
selectCar (e, auto = false, index, autoHideLoading = true) { selectCar (e, auto = false, carId) {
let { clickFlga } = this if (!e.brandId || !e.id) return uni.showToast({
title: "车型ID或品牌ID为空",
icon: "none",
});
let { clickFlga } = this,
index = 0
if (clickFlga) return if (clickFlga) return
this.clickFlga = true this.clickFlga = true
this.selectItem = { this.selectItem = {
...@@ -154,7 +156,11 @@ export default { ...@@ -154,7 +156,11 @@ export default {
if (carList) { if (carList) {
this.clickFlga = false this.clickFlga = false
this.carlist = carList 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 this.$refs.carBoxVisible.open()
} else { } else {
if (!auto) uni.showLoading({ if (!auto) uni.showLoading({
...@@ -165,11 +171,15 @@ export default { ...@@ -165,11 +171,15 @@ export default {
brandId: e.brandId, brandId: e.brandId,
childBrandId: e.id childBrandId: e.id
}).then(res => { }).then(res => {
if (autoHideLoading) uni.hideLoading() uni.hideLoading()
this.carlist = res this.carlist = res
if (res) uni.setStorageSync(`${e.id}_${e.brandId}_carlist`, res) if (res) uni.setStorageSync(`${e.id}_${e.brandId}_carlist`, res)
if (!carList) { 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() else this.$refs.carBoxVisible.open()
} }
this.clickFlga = false this.clickFlga = false
......
...@@ -61,12 +61,28 @@ ...@@ -61,12 +61,28 @@
>{{ i.text }}</view> >{{ i.text }}</view>
</template> </template>
</view> </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 <view
class="search-btn flex" class="search-btn flex"
@click="$refs.customerTagstVisible.open()" @click="$refs.customerTagstVisible.open()"
>标签筛选</view> >标签筛选</view>
</view> </view>
</view>
<scroll-view <scroll-view
:class="['record-list', recordClass]" :class="['record-list', recordClass]"
scroll-y scroll-y
...@@ -275,6 +291,7 @@ export default { ...@@ -275,6 +291,7 @@ export default {
status: 1, status: 1,
showChannel: 2, showChannel: 2,
}, },
allMerchantStatus: true
} }
}, },
...@@ -463,7 +480,7 @@ export default { ...@@ -463,7 +480,7 @@ export default {
mask: true mask: true
}) })
let { shopMerchantId } = uni.$storage.get("userInfo"), let { shopMerchantId } = uni.$storage.get("userInfo"),
{ pageSize, pageNum, caseParams, tagsList } = this, { pageSize, pageNum, caseParams, tagsList, allMerchantStatus } = this,
customerLabelList = [] customerLabelList = []
tagsList.map(e => customerLabelList.push({ tagsList.map(e => customerLabelList.push({
labelId: e.labelId labelId: e.labelId
...@@ -472,9 +489,9 @@ export default { ...@@ -472,9 +489,9 @@ export default {
currentPage: pageNum, currentPage: pageNum,
pageSize, pageSize,
customerLabelList, customerLabelList,
merchantId: shopMerchantId,
...caseParams ...caseParams
} }
if (!allMerchantStatus) params.merchantId = shopMerchantId
const { list, total } = await uni.$api.customerApi.getMaterialResponsePage(params) const { list, total } = await uni.$api.customerApi.getMaterialResponsePage(params)
uni.hideLoading() uni.hideLoading()
list.map(e => { list.map(e => {
...@@ -502,6 +519,10 @@ export default { ...@@ -502,6 +519,10 @@ export default {
handleSelect (list) { handleSelect (list) {
this.tagsList = list this.tagsList = list
this.refresh() this.refresh()
},
allMerchantSwitch () {
this.allMerchantStatus = !this.allMerchantStatus
this.refresh()
} }
} }
} }
...@@ -834,8 +855,11 @@ export default { ...@@ -834,8 +855,11 @@ export default {
background: #2d66f71a; background: #2d66f71a;
} }
} }
.search-btn { .btn-list {
margin-left: auto; margin-left: auto;
gap: 0 48rpx;
line-height: 48rpx;
.search-btn {
&::after { &::after {
content: ''; content: '';
border: 12rpx solid transparent; border: 12rpx solid transparent;
...@@ -844,6 +868,25 @@ export default { ...@@ -844,6 +868,25 @@ export default {
transform: translateY(-2rpx); 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;
}
}
} }
.nothing { .nothing {
......
...@@ -100,7 +100,7 @@ import dayjs from 'dayjs' ...@@ -100,7 +100,7 @@ import dayjs from 'dayjs'
const dayImgUrl = require('@/assets/images/common/day.webp') const dayImgUrl = require('@/assets/images/common/day.webp')
const weekImgUrl = require('@/assets/images/common/week.webp') const weekImgUrl = require('@/assets/images/common/week.webp')
const monthImgUrl = require('@/assets/images/common/month.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 interruptRecord from '@/utils/recordManager/interruptRecord'
import saveRecord from './saveRecord.vue' import saveRecord from './saveRecord.vue'
export default { export default {
...@@ -182,6 +182,7 @@ export default { ...@@ -182,6 +182,7 @@ export default {
async handleSubmit(val ){ async handleSubmit(val ){
this.showRecord = true; this.showRecord = true;
uni.$recordManager.addRecord(val) uni.$recordManager.addRecord(val)
uni.$logger.local.info(`添加记录${JSON.stringify(val)}`)
interruptRecord.removePreRecord(val.id) interruptRecord.removePreRecord(val.id)
this.getRecordNum() this.getRecordNum()
this.getPreRecordFail() this.getPreRecordFail()
...@@ -245,7 +246,7 @@ export default { ...@@ -245,7 +246,7 @@ export default {
}, },
getPreRecordNum() { getPreRecordNum() {
const preRecordList = uni.$storage.get(STORAGE_OBJECTkEY.preRecordList)||[] const preRecordList = uni.$storage.get(STORAGE_OBJECTKEY.preRecordList)||[]
console.log(preRecordList) console.log(preRecordList)
this.preRecordFailList = preRecordList.reverse() this.preRecordFailList = preRecordList.reverse()
}, },
......
...@@ -81,6 +81,7 @@ export default { ...@@ -81,6 +81,7 @@ export default {
const userInfo = uni.$storage.get('userInfo') || {} const userInfo = uni.$storage.get('userInfo') || {}
this.userInfo = userInfo this.userInfo = userInfo
}, },
computed: { computed: {
previewRef() { previewRef() {
return this.$refs.previewRef return this.$refs.previewRef
......
module.exports = { module.exports = {
// 请求域名 格式:https://xxx.xxx.com // 请求域名 格式: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域名 格式: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时需用到 // 文件直传到阿里云oss时需用到
ACCESSKEYID: "LTAI5tCRcCUgd7bt1J7JY596", ACCESSKEYID: 'LTAI5tCRcCUgd7bt1J7JY596',
ACCESSKEYSECRET: "kJos9mgylkR5ztosnDt8Asrc3ulgqy", ACCESSKEYSECRET: 'kJos9mgylkR5ztosnDt8Asrc3ulgqy',
BUKET_NAME: "glsk-oss", BUKET_NAME: 'glsk-oss',
FOLDER: "quality/", FOLDER: 'quality/',
// 与后端约定的token字段名 // 与后端约定的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> <!DOCTYPE html>
<html> <html>
<head>
<head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title> <title></title>
</head> </head>
<style> <style>
body, body,
html { html {
margin: 0; margin: 0;
...@@ -31,12 +32,14 @@ ...@@ -31,12 +32,14 @@
0% { 0% {
transform: rotate(0deg); transform: rotate(0deg);
} }
100% { 100% {
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
</style> </style>
</head> </head>
<body> <body>
<div class="loading"></div> <div class="loading"></div>
<script src="js/uni.webview.1.5.5.js"></script> <script src="js/uni.webview.1.5.5.js"></script>
...@@ -44,45 +47,27 @@ ...@@ -44,45 +47,27 @@
<script src="js/OSSUpLoader.js"></script> <script src="js/OSSUpLoader.js"></script>
<script> <script>
// document.addEventListener('UniAppJSBridgeReady', function(){ // document.addEventListener('UniAppJSBridgeReady', function(){
/** /**
* 该函数用于接收来自 UniApp 的消息,它包含了文件上传所需的所有信息 * 该函数用于接收来自 UniApp 的消息,它包含了文件上传所需的所有信息
* @param {string} accessKeyId - OSS 访问密钥 ID * @param {string} accessKeyId - OSS 访问密钥 ID
* @param {string} accessKeySecret - OSS 访问密钥 secret * @param {string} accessKeySecret - OSS 访问密钥 secret
* @param {string} stsToken - 安全令牌服务(STS)令牌,用于临时访问 OSS 存储桶 * @param {string} stsToken - 安全令牌服务(STS)令牌,用于临时访问 OSS 存储桶
* @param {string} fileName - 要上传的文件名 * @param {string} fileName - 要上传的文件名
* @param {string} filePath - 要上传的文件所在路径 * @param {string} filePath - 要上传的文件所在路径
* @param {string} recordId - 与上传文件相关联的记录ID
* @param {Object} options - (可选)包含上传器配置的对象,如 region * @param {Object} options - (可选)包含上传器配置的对象,如 region
* @throws {Error} 如果缺少必要的参数,将抛出错误 * @throws {Error} 如果缺少必要的参数,将抛出错误
*/ */
window.msgFromUniapp = function ( window.msgFromUniapp = function (accessKeyId, accessKeySecret, stsToken, fileName, filePath, recordId, options = {}) {
accessKeyId, console.log(fileName, filePath)
accessKeySecret, if (!accessKeyId || !accessKeySecret || !stsToken || !fileName || !filePath) {
stsToken, throw new Error('accessKeyId,accessKeySecret,stsToken,fileName,filePath is required')
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 { try {
// 使用 Object.assign 合并默认配置参数和传入的 options 参数 // 使用 Object.assign 合并默认配置参数和传入的 options 参数
const opt = Object.assign( const opt = Object.assign({ accessKeyId, accessKeySecret, stsToken, filePath, recordId }, options)
{ accessKeyId, accessKeySecret, stsToken, filePath, recordId },
options
);
// 创建 OSSUpLoader 实例,传入配置对象 // 创建 OSSUpLoader 实例,传入配置对象
let uploader = new OSSUpLoader(opt); let uploader = new OSSUpLoader(opt)
// 调用 upload 方法上传文件,并在完成后处理结果 // 调用 upload 方法上传文件,并在完成后处理结果
uploader.upload(fileName, function (result) { uploader.upload(fileName, function (result) {
// 通过 uni.postMessage 将上传结果作为数据发送 // 通过 uni.postMessage 将上传结果作为数据发送
...@@ -91,14 +76,14 @@ ...@@ -91,14 +76,14 @@
...result, ...result,
fileName, fileName,
recordId, recordId,
filePath, filePath
}, }
}); })
// 调用 destroy 方法,这将重置上传器的状态,释放资源 // 调用 destroy 方法,这将重置上传器的状态,释放资源
uploader.destroy(); uploader.destroy()
// 将 uploader 置为 null,释放内存 // 将 uploader 置为 null,释放内存
uploader = null; uploader = null
}); })
} catch (e) { } catch (e) {
// 如果发生错误,将错误信息作为数据发送 // 如果发生错误,将错误信息作为数据发送
uni.postMessage({ uni.postMessage({
...@@ -107,12 +92,13 @@ ...@@ -107,12 +92,13 @@
fileName, fileName,
recordId, recordId,
filePath, filePath,
error: e.message, error: e.message
},
});
} }
}; })
// }, false); }
}
// }, false);
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-07 17:09:53 * @Date: 2024-04-07 17:09:53
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-08-30 14:49:02 * @LastEditTime: 2024-10-30 16:16:48
* @FilePath: \gl_tape\main.js * @FilePath: \gl_tape\main.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @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' ...@@ -18,6 +18,7 @@ import wnCanvas from './components/Canvas/wn-canvas'
import UpdateBox from './components/UpdateBox' import UpdateBox from './components/UpdateBox'
import webView from './components/WebView' import webView from './components/WebView'
import utils from './utils/utils' import utils from './utils/utils'
import logger from './utils/logger'
Vue.use(webView) Vue.use(webView)
Vue.component('GlsxImage', GlsxImage) Vue.component('GlsxImage', GlsxImage)
Vue.component('MessageBox', MessageBox) Vue.component('MessageBox', MessageBox)
...@@ -32,11 +33,12 @@ uni.$lock = false ...@@ -32,11 +33,12 @@ uni.$lock = false
uni.$storage = new Storage() uni.$storage = new Storage()
uni.$throttle = utils.throttle uni.$throttle = utils.throttle
uni.$isNetWork = utils.isNetWork uni.$isNetWork = utils.isNetWork
uni.$logger = logger
Vue.config.productionTip = false Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
Vue.prototype.$ossDomain = config.OSS_DOMAIN Vue.prototype.$ossDomain = config.OSS_DOMAIN
import permision from '@/js_sdk/wa-permission/permission.js' import permision from '@/js_sdk/wa-permission/permission.js'
import { index } from './env' // import { index } from "./env";
// switch (uni.getSystemInfoSync().platform) { // switch (uni.getSystemInfoSync().platform) {
// case "android": // case "android":
// permision.requestAndroidPermission("android.permission.RECORD_AUDIO"); // permision.requestAndroidPermission("android.permission.RECORD_AUDIO");
...@@ -48,15 +50,16 @@ import { index } from './env' ...@@ -48,15 +50,16 @@ import { index } from './env'
// break; // break;
// } // }
Vue.prototype.$permision = permision Vue.prototype.$permision = permision
import sentryInit from '@/utils/sentryConfig/sentryInit'
if (index == 3 || index == 2) { // import sentryInit from "@/utils/sentryConfig/sentryInit";
const sentry = sentryInit() // if (index == 3) {
Vue.prototype.$sendSentry = function (e) { // const sentry = sentryInit();
sentry.captureException(e) // Vue.prototype.$sendSentry = function (e) {
} // sentry.captureException(e);
} else { // };
Vue.prototype.$sendSentry = function () {} // } else {
} // Vue.prototype.$sendSentry = function () {};
// }
const app = new Vue({ const app = new Vue({
store, store,
......
{ {
"name" : "展业助手", "name": "展业助手",
"appid" : "__UNI__D3BD3DF", "appid": "__UNI__D3BD3DF",
"description" : "", "description": "",
"versionName" : "1.9.1", "versionName": "2.1.0",
"versionCode" : "100", "versionCode": "100",
"transformPx" : false, "transformPx": false,
/* 5+App特有相关 */ /* 5+App特有相关 */
"app-plus" : { "app-plus": {
"bounce" : "none", "bounce": "none",
"usingComponents" : true, "usingComponents": true,
"nvueStyleCompiler" : "uni-app", "nvueStyleCompiler": "uni-app",
"compilerVersion" : 3, "compilerVersion": 3,
"screenOrientation" : "landscape", "screenOrientation": "landscape",
"splashscreen" : { "splashscreen": {
"alwaysShowBeforeRender" : true, "alwaysShowBeforeRender": true,
"waiting" : true, "waiting": true,
"autoclose" : true, "autoclose": true,
"delay" : 0 "delay": 0
}, },
/* 模块配置 */ /* 模块配置 */
"modules" : { "modules": {
"Camera" : {}, "Camera": {},
"Record" : {}, "Record": {},
"VideoPlayer" : {}, "VideoPlayer": {},
"AudioPlayer" : {} "AudioPlayer": {}
}, },
/* 应用发布信息 */ /* 应用发布信息 */
"distribute" : { "distribute": {
/* android打包配置 */ /* android打包配置 */
"android" : { "android": {
"permissions" : [ "permissions": [
"<uses-feature android:name=\"android.hardware.camera\"/>", "<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>", "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
...@@ -44,55 +44,59 @@ ...@@ -44,55 +44,59 @@
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
], ],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ], "abiFilters": [
"targetSdkVersion" : 30 "armeabi-v7a",
"arm64-v8a",
"x86"
],
"targetSdkVersion": 30
}, },
/* ios打包配置 */ /* ios打包配置 */
"ios" : { "ios": {
"dSYMs" : false, "dSYMs": false,
"UIBackgroundModes" : "audio" "UIBackgroundModes": "audio"
}, },
/* SDK配置 */ /* SDK配置 */
"sdkConfigs" : { "sdkConfigs": {
"ad" : {}, "ad": {},
"speech" : {} "speech": {}
}, },
"icons" : { "icons": {
"android" : { "android": {
"hdpi" : "static/72.png", "hdpi": "static/72.png",
"xhdpi" : "static/96.png", "xhdpi": "static/96.png",
"xxhdpi" : "static/144.png" "xxhdpi": "static/144.png"
} }
} }
} }
}, },
/* 快应用特有相关 */ /* 快应用特有相关 */
"quickapp" : {}, "quickapp": {},
/* 小程序特有相关 */ /* 小程序特有相关 */
"mp-weixin" : { "mp-weixin": {
"appid" : "wx79d1ff39bee3d047", "appid": "wx79d1ff39bee3d047",
"setting" : { "setting": {
"urlCheck" : false "urlCheck": false
}, },
"usingComponents" : true "usingComponents": true
}, },
"mp-alipay" : { "mp-alipay": {
"usingComponents" : true "usingComponents": true
}, },
"mp-baidu" : { "mp-baidu": {
"usingComponents" : true "usingComponents": true
}, },
"mp-toutiao" : { "mp-toutiao": {
"usingComponents" : true "usingComponents": true
}, },
"uniStatistics" : { "uniStatistics": {
"enable" : false "enable": false
}, },
"vueVersion" : "2", "vueVersion": "2",
"h5" : { "h5": {
"devServer" : { "devServer": {
"port" : 8080, "port": 8080,
"https" : false "https": false
} }
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3", "eslint-plugin-prettier": "^5.1.3",
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",
"lodash": "^4.17.21",
"number-precision": "^1.6.0", "number-precision": "^1.6.0",
"prettier": "^3.3.2", "prettier": "^3.3.2",
"webpack-spritesmith": "^1.1.0" "webpack-spritesmith": "^1.1.0"
......
...@@ -175,7 +175,6 @@ export default { ...@@ -175,7 +175,6 @@ export default {
watchStatus: { watchStatus: {
handler (val) { handler (val) {
this.selectIndex = '全部' this.selectIndex = '全部'
// console.log(val)
// this.name = ''; // this.name = '';
// this.isSearch = false // this.isSearch = false
// this.list = this.views // this.list = this.views
...@@ -232,7 +231,6 @@ export default { ...@@ -232,7 +231,6 @@ export default {
this.isSelect = false this.isSelect = false
}, },
chooseType (val) { chooseType (val) {
console.log(val)
this.selectIndex = val.value this.selectIndex = val.value
this.isSelect = false this.isSelect = false
this.getCaseList(this.selectIndex == '全部' ? '' : this.selectIndex, this.name) this.getCaseList(this.selectIndex == '全部' ? '' : this.selectIndex, this.name)
...@@ -244,7 +242,6 @@ export default { ...@@ -244,7 +242,6 @@ export default {
const params = { merchantId: shopMerchantId, category } const params = { merchantId: shopMerchantId, category }
if (name) params.materialName = name if (name) params.materialName = name
const res = await uni.$api.boutiqueApi.getCaseList(params) const res = await uni.$api.boutiqueApi.getCaseList(params)
console.log(res)
this.list = res.list this.list = res.list
this.searchList = res.list this.searchList = res.list
this.scrollTop = 1 this.scrollTop = 1
...@@ -256,7 +253,6 @@ export default { ...@@ -256,7 +253,6 @@ export default {
const userInfo = uni.$storage.get("userInfo"), const userInfo = uni.$storage.get("userInfo"),
{ shopMerchantId } = userInfo; { shopMerchantId } = userInfo;
const res = await uni.$api.boutiqueApi.getCategory({ merchantId: shopMerchantId }) const res = await uni.$api.boutiqueApi.getCategory({ merchantId: shopMerchantId })
console.log(res)
const _list = res.map(item => { const _list = res.map(item => {
return { return {
label: item, label: item,
...@@ -314,6 +310,7 @@ export default { ...@@ -314,6 +310,7 @@ export default {
background: #ffffff; background: #ffffff;
border-radius: 16rpx; border-radius: 16rpx;
padding: 16rpx 0; padding: 16rpx 0;
animation: show-view-opacity 0.15s forwards;
.type-item { .type-item {
padding: 0 24rpx; padding: 0 24rpx;
margin-bottom: 8rpx; margin-bottom: 8rpx;
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
import NP from 'number-precision' import NP from 'number-precision'
export default { export default {
props: { props: {
currentCar: String, currentCar: [Number, String],
show: Boolean show: Boolean
}, },
data () { data () {
...@@ -103,7 +103,6 @@ export default { ...@@ -103,7 +103,6 @@ export default {
currentCar: { currentCar: {
immediate: true, immediate: true,
handler (newval) { handler (newval) {
console.log(newval)
this.optionalsList = [] this.optionalsList = []
this.init() this.init()
} }
......
...@@ -8,17 +8,30 @@ ...@@ -8,17 +8,30 @@
ref="receptionCanvas" ref="receptionCanvas"
> >
<template slot="customContent"> <template slot="customContent">
<view class="tab-box flex"> <view class="select-box flex">
<template v-for="(item, index) in carList">
<view <view
:key="index" class="select flex"
:class="['tab',`${currentIndex == index ? 'active' : ''}`]" @click.stop="showSelect"
@click="changeCar(item)"
> >
{{item}} {{currentCarString}}
<view
class="sprite-icon icon-arrow-bottom"
v-if="carList.length > 1 && !change_disabled"
></view>
</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> </template>
</view> </view>
</view>
<view <view
class="risk-informed flex" class="risk-informed flex"
@click="$refs.riskInformedPop.open()" @click="$refs.riskInformedPop.open()"
...@@ -46,18 +59,10 @@ ...@@ -46,18 +59,10 @@
>* 点击图片查看详情 &gt;</view> >* 点击图片查看详情 &gt;</view>
</view> </view>
</template> </template>
<template v-else>
<view class="left-content">
<image
class="default"
:src="defaultImg"
/>
</view>
</template>
<view class="right-content"> <view class="right-content">
<view :class="['sku-box',isPreview ? 'preview' : '']"> <view :class="['sku-box',isPreview ? 'preview' : '']">
<sku-box <sku-box
:currentCar="currentCarString" :currentCar="currentCarId"
:defaultTabId="tabId" :defaultTabId="tabId"
:show="show && tabIndex == 0" :show="show && tabIndex == 0"
@changePreView="changePreView" @changePreView="changePreView"
...@@ -73,7 +78,7 @@ ...@@ -73,7 +78,7 @@
</view> </view>
<optional-table <optional-table
v-show="tabIndex == 1" v-show="tabIndex == 1"
:currentCar="currentCarString" :currentCar="currentCarId"
:show="show && tabIndex == 1" :show="show && tabIndex == 1"
></optional-table> ></optional-table>
<template v-if="hasOptionals"> <template v-if="hasOptionals">
...@@ -114,9 +119,6 @@ import CarBrands from '@/components/CarBrands.vue' ...@@ -114,9 +119,6 @@ import CarBrands from '@/components/CarBrands.vue'
import CouponPop from './CouponPop.vue' import CouponPop from './CouponPop.vue'
import RiskInformedBox from './RiskInformedBox.vue' import RiskInformedBox from './RiskInformedBox.vue'
import OptionalTable from './OptionalTable.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 { export default {
name: 'Reception', name: 'Reception',
components: { SkuBox, CarBrands, CouponPop, RiskInformedBox, OptionalTable }, components: { SkuBox, CarBrands, CouponPop, RiskInformedBox, OptionalTable },
...@@ -124,7 +126,7 @@ export default { ...@@ -124,7 +126,7 @@ export default {
customerType: Number, customerType: Number,
show: Boolean, show: Boolean,
tabId: Number, tabId: Number,
currentCar: String, propCarId: [Number, String],
type: String, type: String,
popupImg: String, popupImg: String,
madiaId: Number, madiaId: Number,
...@@ -132,7 +134,6 @@ export default { ...@@ -132,7 +134,6 @@ export default {
}, },
data () { data () {
return { return {
carList: ['M5', 'M7', 'M9'],
currentCarString: '', currentCarString: '',
customerInfo: {}, customerInfo: {},
updateViewKey: Date.now(), updateViewKey: Date.now(),
...@@ -140,7 +141,9 @@ export default { ...@@ -140,7 +141,9 @@ export default {
currentImgUrl: '', currentImgUrl: '',
currentItem: null, currentItem: null,
tabs: ['加装', '选装'], tabs: ['加装', '选装'],
tabIndex: 0 tabIndex: 0,
isSelect: false,
currentCarId: ''
} }
}, },
watch: { watch: {
...@@ -150,26 +153,23 @@ export default { ...@@ -150,26 +153,23 @@ export default {
this.customerInfo = newval this.customerInfo = newval
} }
}, },
currentCar: { propCarId: {
immediate: true, immediate: true,
handler (newval) { handler (newval) {
this.currentCarString = newval this.currentCarId = newval
this.currentCarString = this.carList.find(e => e.carModelId == newval)?.carModelName || ''
} }
}, },
currentCarString: { currentCarId: {
immediate: true, immediate: true,
handler (newval) { handler (newval) {
if (!this.hasOptionals && this.tabIndex == 1) this.tabIndex = 0 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) { if (this.show && newval && !this.isPreview && this.customerType == 1) {
uni.showLoading({ uni.showLoading({
mask: true 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 { ...@@ -185,6 +185,7 @@ export default {
immediate: true, immediate: true,
handler (newval) { handler (newval) {
if (newval) { if (newval) {
this.isSelect = false
if (newval && this.currentItem && this.tabIndex == 0) this.changePreView(this.currentItem, false, false) if (newval && this.currentItem && this.tabIndex == 0) this.changePreView(this.currentItem, false, false)
} }
} }
...@@ -198,21 +199,18 @@ export default { ...@@ -198,21 +199,18 @@ export default {
watchCustomerInfo () { watchCustomerInfo () {
return this.$store.state.user.customerInfo return this.$store.state.user.customerInfo
}, },
currentIndex () {
return this.carList.findIndex(e => e == this.currentCarString)
},
isPreview () { isPreview () {
return this.type == 'preview' return this.type == 'preview'
}, },
couponText () { couponText () {
return this.customerType == 0 ? '查看客户券码' : '为客户发券' return this.customerType == 0 ? '查看客户券码' : '为客户发券'
}, },
change_disabled () {
return this.customerType == 0 || this.couponPopupRef.pageParams.QRURL
},
couponPopupRef () { couponPopupRef () {
return this.$refs.couponPopup return this.$refs.couponPopup
}, },
change_disabled () {
return this.customerType == 0 || this.$refs?.couponPopup?.pageParams.QRURL
},
receptionTrack () { receptionTrack () {
return this.$store.state.user.receptionTrack return this.$store.state.user.receptionTrack
}, },
...@@ -221,16 +219,20 @@ export default { ...@@ -221,16 +219,20 @@ export default {
}, },
hasOptionals () { hasOptionals () {
let flag = false 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 return flag
},
carList () {
return this.$store.state.user.boutiqueCarList
} }
}, },
methods: { methods: {
changeCar (item) { changeCar (item) {
if (this.change_disabled || this.currentCarString == item) return uni.hideLoading() if (this.change_disabled || this.currentCarId == item.carModelId) return uni.hideLoading()
this.currentCarString = item this.currentCarString = item.carModelName
this.currentCarId = item.carModelId
this.isSelect = false
this.updateViewKey = Date.now() this.updateViewKey = Date.now()
this.clearCanvas() this.clearCanvas()
}, },
...@@ -274,7 +276,7 @@ export default { ...@@ -274,7 +276,7 @@ export default {
this.$emit('reception', e) this.$emit('reception', e)
}, },
clearCustomerReceivedTimer () { clearCustomerReceivedTimer () {
if (this.couponPopupRef.pageParams.qrTimer) { if (this.couponPopupRef?.pageParams?.qrTimer) {
clearInterval(this.couponPopupRef.pageParams.qrTimer) clearInterval(this.couponPopupRef.pageParams.qrTimer)
this.couponPopupRef.pageParams.qrTimer = null this.couponPopupRef.pageParams.qrTimer = null
} }
...@@ -300,8 +302,18 @@ export default { ...@@ -300,8 +302,18 @@ export default {
if (this.tabIndex == index) return if (this.tabIndex == index) return
this.tabIndex = index this.tabIndex = index
if (index == 1) this.previewLeave(this.currentItem) if (index == 1) this.previewLeave(this.currentItem)
else this.$refs.sku.changeCar(this.currentCarString) else this.$refs.sku.changeCar(this.currentCarId)
this.clearCanvas() 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 { ...@@ -327,44 +339,64 @@ export default {
margin-left: 8rpx; margin-left: 8rpx;
} }
} }
.tab-box { .select-box {
padding-top: 66rpx; padding-top: 66rpx;
position: fixed; position: fixed;
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
justify-content: center; justify-content: center;
.tab { z-index: 2;
padding: 0 32rpx; .select {
font-weight: 500; color: #333333;
font-size: 36rpx; font-size: 36rpx;
color: #333333b3; font-weight: 500;
line-height: 44rpx; line-height: 44rpx;
width: 130rpx; }
text-align: center; .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; position: relative;
&:first-child {
margin-top: 0;
} }
.active { &:last-child {
font-weight: 700; margin-bottom: 0;
color: #333333; }
transition: all 1s; &.active {
background-color: #ecf1ff;
}
}
.has-line {
margin-top: 18rpx;
&::after { &::after {
content: ''; content: '';
width: calc(100% - 48rpx);
height: 2rpx;
background: #f5f5f5;
position: absolute; position: absolute;
left: 50%; left: 50%;
width: 8rpx; top: -10rpx;
height: 8rpx;
background: #333333;
border-radius: 100%;
transform: translateX(-50%); transform: translateX(-50%);
animation: show-dot 0.15s forwards;
} }
@keyframes show-dot {
0% {
bottom: 16rpx;
} }
100% { .is-first {
bottom: -16rpx; &::after {
display: none;
} }
} }
} }
......
...@@ -87,7 +87,7 @@ export default { ...@@ -87,7 +87,7 @@ export default {
name: 'SkuBox', name: 'SkuBox',
props: { props: {
defaultTabId: Number, defaultTabId: Number,
currentCar: String, currentCar: [Number,String],
show: Boolean show: Boolean
}, },
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
:show="id == item.id" :show="id == item.id"
@reception="reception" @reception="reception"
:tabId="tabId" :tabId="tabId"
:currentCar="currentCar" :propCarId="currentCarId"
:type="type" :type="type"
:popupImg="item.popupImg" :popupImg="item.popupImg"
@preview="onPreview" @preview="onPreview"
...@@ -118,7 +118,7 @@ export default { ...@@ -118,7 +118,7 @@ export default {
customerType: Number, customerType: Number,
toolList: Array, toolList: Array,
tabId: Number, tabId: Number,
currentCar: String currentCarId: [Number, String]
}, },
mixins: [receptionTrackMixin], mixins: [receptionTrackMixin],
data () { data () {
...@@ -210,7 +210,8 @@ export default { ...@@ -210,7 +210,8 @@ export default {
salesUuid: item.userId, salesUuid: item.userId,
staffName: item.employeeName, staffName: item.employeeName,
receiveCouponDate: item.receiveCouponDate, receiveCouponDate: item.receiveCouponDate,
customerCouponId: item.customerCouponId customerCouponId: item.customerCouponId,
carSeriesId: item.carSeriesId
} }
let [reception] = this.$refs.media1 let [reception] = this.$refs.media1
reception?.clearCustomerReceivedTimer() reception?.clearCustomerReceivedTimer()
......
...@@ -127,7 +127,11 @@ export default { ...@@ -127,7 +127,11 @@ export default {
watch: { watch: {
show: { show: {
handler (val) { handler (val) {
if (val) this.init() if (val) {
this.flag = false
this.list = []
this.init()
}
this.$refs.receptionTips?.close() this.$refs.receptionTips?.close()
}, },
immediate: true immediate: true
...@@ -137,7 +141,6 @@ export default { ...@@ -137,7 +141,6 @@ export default {
methods: { methods: {
init () { init () {
this.customerNameOrPhone = ''; this.customerNameOrPhone = '';
console.log('init')
setTimeout(() => { setTimeout(() => {
this.isSearch = false this.isSearch = false
this.pageNum = 1 this.pageNum = 1
......
<template> <template>
<view <view class="box" :key="selectedUuid" v-if="flag">
class="box"
:key="selectedUuid"
v-if="flag"
>
<template v-if="loginUserInfoList.length"> <template v-if="loginUserInfoList.length">
<template v-for="(item,index) in loginUserInfoList"> <template v-for="(item, index) in loginUserInfoList">
<view <view :key="index" :class="['items', `${item.active ? 'active' : ''}`]" @click="chooseAccount(item)">
:key="index"
:class="['items', `${item.active ? 'active' : ''}` ]"
@click="chooseAccount(item)"
>
<view class="right"> <view class="right">
<view :class="['midle', midle(item)]"> <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> </view>
<view class="left"> <view class="left">
<view class="name"> <view class="name">
{{item.merchantName}} {{ item.merchantName }}
</view>
<view class="shop_no">
商户号:{{item.merchantId}}
</view> </view>
<view class="shop_no">商户号:{{ item.merchantId }}</view>
</view> </view>
</view> </view>
</template> </template>
...@@ -33,7 +23,7 @@ ...@@ -33,7 +23,7 @@
</view> </view>
</template> </template>
<script type='text/ecmascript-6'> <script type="text/ecmascript-6">
import { loginMixin } from '@/mixin/index' import { loginMixin } from '@/mixin/index'
import NoData from './NoData.vue' import NoData from './NoData.vue'
export default { export default {
...@@ -57,6 +47,7 @@ export default { ...@@ -57,6 +47,7 @@ export default {
}, },
mounted () { mounted () {
this.getListSelectAccount() this.getListSelectAccount()
uni.$logger.local.info(`进入选择账号页面!`)
}, },
methods: { methods: {
getListSelectAccount (autoLogin = false) { getListSelectAccount (autoLogin = false) {
...@@ -99,10 +90,14 @@ export default { ...@@ -99,10 +90,14 @@ export default {
}, },
async choiceAccountLogin () { async choiceAccountLogin () {
let { loginUserInfoList } = this, let { loginUserInfoList } = this,
id = null id = null,
merchantName = null
console.log(loginUserInfoList,'loginUserInfoList')
loginUserInfoList.map(e => { loginUserInfoList.map(e => {
if (e.active) id = e.uuid if (e.active) {
id = e.uuid
merchantName = e.merchantName
}
}) })
if (!id) { if (!id) {
...@@ -114,9 +109,10 @@ export default { ...@@ -114,9 +109,10 @@ export default {
} }
// 清空4s店数据 // 清空4s店数据
// app.globalData.storeListRange = [] // app.globalData.storeListRange = []
this.selectAccountLogin(id) this.selectAccountLogin(id,merchantName)
}, },
selectAccountLogin (id) { selectAccountLogin (id,merchantName) {
uni.$logger.local.info(`选择账号${merchantName}登录!`)
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
...@@ -128,7 +124,8 @@ export default { ...@@ -128,7 +124,8 @@ export default {
title: '获取4S店列表失败', title: '获取4S店列表失败',
icon: 'none', icon: 'none',
}) })
}).catch(() => { }).catch((err) => {
uni.$logger.local.error(`获取4S店列表失败${err}!`)
uni.hideLoading() uni.hideLoading()
}) })
}, },
...@@ -151,7 +148,7 @@ export default { ...@@ -151,7 +148,7 @@ export default {
} }
</script> </script>
<style scoped lang='scss'> <style scoped lang="scss">
.box { .box {
display: flex; display: flex;
align-items: center; align-items: center;
......
<template> <template>
<view <view class="box" :key="selectMerchantId">
class="box"
:key="selectMerchantId"
>
<template v-if="flag"> <template v-if="flag">
<template v-if="loginUserInfoList.length"> <template v-if="loginUserInfoList.length">
<template v-for="(item,index) in loginUserInfoList"> <template v-for="(item, index) in loginUserInfoList">
<view <view :key="index" :class="['items', { active: item.active }]" @click="chooseAccount(item)">
:key="index"
:class="['items' ,{active:item.active}]"
@click="chooseAccount(item)"
>
<view class="right"> <view class="right">
<view class="sprite-icon icon-store"></view> <view class="sprite-icon icon-store"></view>
</view> </view>
<view class="left"> <view class="left">
<view class="text_box"> <view class="text_box">
<view class="name">{{item.merchantName}}</view> <view class="name">{{ item.merchantName }}</view>
<view class="text_no">商户号:{{item.merchantId}}</view> <view class="text_no">商户号:{{ item.merchantId }}</view>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
</template> </template>
...@@ -31,7 +23,7 @@ ...@@ -31,7 +23,7 @@
</view> </view>
</template> </template>
<script type='text/ecmascript-6'> <script type="text/ecmascript-6">
import NoData from './NoData.vue' import NoData from './NoData.vue'
export default { export default {
...@@ -52,6 +44,7 @@ export default { ...@@ -52,6 +44,7 @@ export default {
}, },
methods: { methods: {
init (userInfo) { init (userInfo) {
uni.$logger.info(`进入选择4s店页面!`)
this.userInfo = userInfo this.userInfo = userInfo
this.getSceneArr() this.getSceneArr()
}, },
...@@ -95,6 +88,7 @@ export default { ...@@ -95,6 +88,7 @@ export default {
}) })
}, },
chooseAccount (item) { chooseAccount (item) {
uni.$logger.info(`选择4s店${item.merchantName}!`)
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
...@@ -158,7 +152,7 @@ export default { ...@@ -158,7 +152,7 @@ export default {
} }
</script> </script>
<style scoped lang='scss'> <style scoped lang="scss">
.box { .box {
display: flex; display: flex;
align-items: center; align-items: center;
......
<template> <template>
<view class="box"> <view class="box">
<template v-for="(item,index) in sceneList"> <template v-for="(item, index) in sceneList">
<view <view :key="index" :class="['items', `${item.actived ? 'active' : ''}`]" @click="selectScene(item, index)">
:key="index"
:class="['items', `${item.actived ? 'active' : ''}` ]"
@click="selectScene(item,index)"
>
<view class="left"> <view class="left">
<view :class="['sprite-icon', `icon-scene-${item.sceneType}`]"></view> <view :class="['sprite-icon', `icon-scene-${item.sceneType}`]"></view>
</view> </view>
<view class="right"> <view class="right">
<view class="name"> <view class="name">
{{item.sceneName}} {{ item.sceneName }}
</view> </view>
<view class="shop_no"> <view class="shop_no">
{{item.sceneDesc}} {{ item.sceneDesc }}
</view> </view>
</view> </view>
</view> </view>
...@@ -22,7 +18,7 @@ ...@@ -22,7 +18,7 @@
</view> </view>
</template> </template>
<script type='text/ecmascript-6'> <script type="text/ecmascript-6">
export default { export default {
name: '', name: '',
data () { data () {
...@@ -51,6 +47,7 @@ export default { ...@@ -51,6 +47,7 @@ export default {
init (userInfo) { init (userInfo) {
this.userInfo = userInfo this.userInfo = userInfo
this.getSceneArr() this.getSceneArr()
uni.$logger.local.info(`进入选择场景页!`)
}, },
getSceneArr () { getSceneArr () {
uni.showLoading({ uni.showLoading({
...@@ -72,6 +69,7 @@ export default { ...@@ -72,6 +69,7 @@ export default {
}, },
// 选择场景 // 选择场景
async selectScene ({ sceneType }, index) { async selectScene ({ sceneType }, index) {
uni.$logger.local.info(`选择场景${sceneType}!`)
let { sceneList, openSceneArr, userInfo } = this let { sceneList, openSceneArr, userInfo } = this
try { try {
if (!openSceneArr.includes(sceneType) && !userInfo?.isSuper) return uni.showToast({ if (!openSceneArr.includes(sceneType) && !userInfo?.isSuper) return uni.showToast({
...@@ -94,21 +92,21 @@ export default { ...@@ -94,21 +92,21 @@ export default {
}) })
if (data) this.jump(userInfo, data) if (data) this.jump(userInfo, data)
else { 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) { } catch (error) {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
title: typeof error == "string" ? error : error.toString(), title: typeof error == "string" ? error : error.toString(),
icon: 'none' icon: 'none'
}) })
console.log(error) 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) { async jump (userInfo, data) {
uni.$logger.local.info(`跳转进入首页!`)
try { try {
uni.hideLoading() uni.hideLoading()
if (data) userInfo.loginRoleOnSelectMerchant = data?.loginRoleOnSelectMerchant if (data) userInfo.loginRoleOnSelectMerchant = data?.loginRoleOnSelectMerchant
...@@ -132,7 +130,7 @@ export default { ...@@ -132,7 +130,7 @@ export default {
url url
}) })
} catch (error) { } catch (error) {
this.$sendSentry(`选择场景后跳转异常:${error}`) uni.$logger.local.error(`选择场景后跳转异常:${error}!`)
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
title: error, title: error,
...@@ -144,7 +142,7 @@ export default { ...@@ -144,7 +142,7 @@ export default {
} }
</script> </script>
<style scoped lang='scss'> <style scoped lang="scss">
.box { .box {
display: flex; display: flex;
align-items: center; align-items: center;
......
...@@ -99,6 +99,7 @@ export default { ...@@ -99,6 +99,7 @@ export default {
const { code, message } = await uni.$api.userApi.getSmsCode({ mobile }); const { code, message } = await uni.$api.userApi.getSmsCode({ mobile });
uni.hideLoading(); uni.hideLoading();
if (code == '0') { if (code == '0') {
uni.$logger.local.info(`${mobile}发送验证码成功`)
uni.showToast({ uni.showToast({
title: '验证码已发送', title: '验证码已发送',
icon: 'none', icon: 'none',
...@@ -106,6 +107,7 @@ export default { ...@@ -106,6 +107,7 @@ export default {
this.countDown(60); this.countDown(60);
} else throw message || '发送验证码失败'; } else throw message || '发送验证码失败';
} catch (error) { } catch (error) {
uni.$logger.local.info(`${mobile}发送验证码失败,失败原因:${error}`)
uni.hideLoading(); uni.hideLoading();
uni.showToast({ uni.showToast({
title: error, title: error,
...@@ -141,8 +143,11 @@ export default { ...@@ -141,8 +143,11 @@ export default {
const { code, data, message } = await uni.$api.userApi.smsLogin(params); const { code, data, message } = await uni.$api.userApi.smsLogin(params);
console.log(code, data, message); console.log(code, data, message);
uni.hideLoading(); uni.hideLoading();
if (code == 0) this.jump(data, noSignIn) if (code == 0) {
else this.jump(data, noSignIn);
uni.$logger.local.info(`${mobile}登录`)
}
else {
uni.showModal({ uni.showModal({
title: '温馨提示', title: '温馨提示',
content: message, content: message,
...@@ -150,7 +155,11 @@ export default { ...@@ -150,7 +155,11 @@ export default {
confirmText: '知道了', confirmText: '知道了',
confirmColor: '#347BFF', confirmColor: '#347BFF',
}); });
uni.$logger.local.info(`${mobile}登录失败,失败原因:${message}`)
}
} catch (error) { } catch (error) {
uni.$logger.local.info(`${mobile}登录失败,失败原因:${error}`)
uni.hideLoading(); uni.hideLoading();
uni.showToast({ uni.showToast({
title: error, title: error,
......
...@@ -6,7 +6,10 @@ ...@@ -6,7 +6,10 @@
* @LastEditTime: 2024-04-18 11:24:22 * @LastEditTime: 2024-04-18 11:24:22
--> -->
<template> <template>
<view class="information-entry" v-if="showPayPage"> <view
class="information-entry"
v-if="showPayPage"
>
<view class="nav-bar"> <view class="nav-bar">
<view <view
class="back" class="back"
...@@ -71,7 +74,7 @@ ...@@ -71,7 +74,7 @@
</view> </view>
</template> </template>
<script> <script>
import {uploadFile} from "@/utils/ossUploadFile/uploadFile.js"; import { uploadFile } from "@/utils/ossUploadFile/uploadFile.js";
import utils from "@/utils/utils"; import utils from "@/utils/utils";
const INFO_LIST = [ const INFO_LIST = [
{ {
...@@ -133,6 +136,7 @@ export default { ...@@ -133,6 +136,7 @@ export default {
success: async (res) => { success: async (res) => {
// await upload(res.tempFilePath) // await upload(res.tempFilePath)
let url = await uploadFile(res.tempFilePaths[0]) let url = await uploadFile(res.tempFilePaths[0])
uni.$logger.local.info(`上传付款凭证:${res.tempFilePaths[0]}`)
// this.$set( // this.$set(
// this.infoList[index], // this.infoList[index],
// "imgUrl", // "imgUrl",
...@@ -142,6 +146,7 @@ export default { ...@@ -142,6 +146,7 @@ export default {
this.setBooks(utils.deepClone(this.infoList)) this.setBooks(utils.deepClone(this.infoList))
}, },
fail: (err) => { fail: (err) => {
uni.$logger.local.error(`上传付款凭证失败:${typeof err == 'string' ? err : err.toString()}`)
console.log(err); console.log(err);
}, },
}); });
......
...@@ -137,22 +137,24 @@ export default { ...@@ -137,22 +137,24 @@ export default {
if (newval.length) { if (newval.length) {
this.payInfo = newval.find(i => i.paymentType == 1) || {} this.payInfo = newval.find(i => i.paymentType == 1) || {}
this.accountInfo = newval.find(i => i.paymentType == 2) || {} this.accountInfo = newval.find(i => i.paymentType == 2) || {}
this.handleSwitchTab(newval[0]) this.handleSwitchTab(newval[0], false)
} }
} }
}, },
}, },
methods: { methods: {
// 切换tab // 切换tab
handleSwitchTab (item) { handleSwitchTab (item, isClick = true) {
this.payActive = item.type; this.payActive = item.type;
this.title = item.title this.title = item.title
if (isClick) uni.$logger.local.info(`付款方式:${item.title}`)
}, },
// 显示弹窗 // 显示弹窗
show () { show () {
// this.payActive = 1 // this.payActive = 1
// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ,type 属性将失效 ,仅支持 ['top','left','bottom','right','center'] // 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ,type 属性将失效 ,仅支持 ['top','left','bottom','right','center']
this.$refs.popup.open("bottom"); this.$refs.popup.open("bottom");
if(this.title) uni.$logger.local.info(`付款方式:${this.title}`)
}, },
close () { close () {
this.$refs.popup.close(); this.$refs.popup.close();
......
...@@ -91,7 +91,7 @@ import FinishStep from '@/components/FinishStep.vue'; ...@@ -91,7 +91,7 @@ import FinishStep from '@/components/FinishStep.vue';
import { mapMutations } from "vuex"; import { mapMutations } from "vuex";
import informationEntry from './components/informationEntry.vue' import informationEntry from './components/informationEntry.vue'
import insurance from '@/components/Insurance/Insurance.vue' import insurance from '@/components/Insurance/Insurance.vue'
import {receptionTrackMixin} from '@/mixin/index.js' import { receptionTrackMixin } from '@/mixin/index.js'
export default { export default {
components: { components: {
ToolBox, ToolBox,
...@@ -152,7 +152,7 @@ export default { ...@@ -152,7 +152,7 @@ export default {
const { channelType } = uni.$storage.get("userInfo") const { channelType } = uni.$storage.get("userInfo")
return channelType == 2 return channelType == 2
}, },
isPreview(){ isPreview () {
return this.type == 'preview' return this.type == 'preview'
} }
...@@ -185,6 +185,7 @@ export default { ...@@ -185,6 +185,7 @@ export default {
}) })
this.receptionTrackLeave() this.receptionTrackLeave()
this.$emit('update:id', e.id) this.$emit('update:id', e.id)
uni.$logger.local.info(`预览${e.title}`)
}, },
back () { back () {
this.$refs?.toolRef?.hide() this.$refs?.toolRef?.hide()
...@@ -221,10 +222,11 @@ export default { ...@@ -221,10 +222,11 @@ export default {
if (Math.abs(this.startY - touch.pageY) > 100) return if (Math.abs(this.startY - touch.pageY) > 100) return
if (!scaleValueObject[id]) scaleValueObject[id] = 1 if (!scaleValueObject[id]) scaleValueObject[id] = 1
if (isDistanceSignificant && index != -1 && scaleValueObject[id] == 1 && !productModelStatus) { 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.modeName = modeName
this.receptionTrackLeave() this.receptionTrackLeave()
this.$emit('update:id', nextId) this.$emit('update:id', nextId)
uni.$logger.local.info(`预览${title}`)
setTimeout(() => { setTimeout(() => {
this.modeName = '' this.modeName = ''
}, 500) }, 500)
...@@ -234,18 +236,19 @@ export default { ...@@ -234,18 +236,19 @@ export default {
} }
}, },
getNextId (index, toolList, startX, halfScreenWidth) { getNextId (index, toolList, startX, halfScreenWidth) {
let nextId = '', let nextItem = {},
modeName = '' modeName = ''
if (startX > halfScreenWidth) { 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' modeName = 'to-right'
} else { } 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' modeName = 'to-left'
} }
return { return {
nextId, nextId: nextItem.id,
modeName modeName,
title: nextItem.title
} }
}, },
scale (e) { scale (e) {
......
...@@ -24,11 +24,8 @@ export default { ...@@ -24,11 +24,8 @@ export default {
employeeList: [], employeeList: [],
paymentType: [], paymentType: [],
haveCustomerAccess: false, haveCustomerAccess: false,
boutiqueMediaConfig: { boutiqueMediaConfig: {},
M5: [], boutiqueCarList:[],
M7: [],
M9: []
},
receptionTrack: {}, //接待记录埋点 receptionTrack: {}, //接待记录埋点
boutiqueDefaultCarBrandId: '' boutiqueDefaultCarBrandId: ''
}; };
...@@ -81,7 +78,7 @@ export default { ...@@ -81,7 +78,7 @@ export default {
}, },
setReceptionTrack ({ state }, { key, value }) { setReceptionTrack ({ state }, { key, value }) {
state.receptionTrack[key] = value state.receptionTrack[key] = value
console.log(JSON.parse(JSON.stringify(state.receptionTrack))) // console.log(JSON.parse(JSON.stringify(state.receptionTrack)))
}, },
clearReceptionTrack ({ state }) { clearReceptionTrack ({ state }) {
state.receptionTrack = {} 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 \ No newline at end of file
...@@ -7,7 +7,7 @@ export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/app-tape/' ...@@ -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'] export const DEFAULT_GET_STORAGEKEY = ['sessionId', 'merchantId', 'userInfo']
// 缓存get方法key的对应才映射值 // 缓存get方法key的对应才映射值
export const STORAGE_OBJECTkEY = { export const STORAGE_OBJECTKEY = {
DEFAULT_GET_STORAGEKEY, DEFAULT_GET_STORAGEKEY,
mock_data: 'mock_data', mock_data: 'mock_data',
storageFile: 'storageFile', storageFile: 'storageFile',
...@@ -20,6 +20,7 @@ export const STORAGE_OBJECTkEY = { ...@@ -20,6 +20,7 @@ export const STORAGE_OBJECTkEY = {
recordList: 'recordList', recordList: 'recordList',
preRecordList: 'preRecordList', preRecordList: 'preRecordList',
preRecordId: 'preRecordId', preRecordId: 'preRecordId',
preAudioList: 'preAudioList',
recordSuccessList: 'recordSuccessList', recordSuccessList: 'recordSuccessList',
historyList: 'historyList', historyList: 'historyList',
storageVersion: 'storageVersion', storageVersion: 'storageVersion',
......
import Storage from './storage' import Storage from './storage'
import storageApi from './storageApi' import storageApi from './storageApi'
module.exports = { Storage, storageApi }
\ No newline at end of file \ No newline at end of file
import * as constData from './constantData'
module.exports = { Storage, storageApi,constData }
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* 微信小程序标准版:统一封装的 storage 操作类 * 微信小程序标准版:统一封装的 storage 操作类
*/ */
import { DEFAULT_GET_STORAGEKEY, STORAGE_OBJECTkEY } from './constantData' import { DEFAULT_GET_STORAGEKEY, STORAGE_OBJECTKEY } from './constantData'
class Storage { class Storage {
types = { types = {
1: 'get', // get 1: 'get', // get
...@@ -36,7 +36,7 @@ class Storage { ...@@ -36,7 +36,7 @@ class Storage {
throw new Error(`Storage ${this.types[type]} func: key can not be empty`) throw new Error(`Storage ${this.types[type]} func: key can not be empty`)
return false return false
} }
// if STORAGE_OBJECTkEY[key] // if STORAGE_OBJECTKEY[key]
return tmpKey return tmpKey
} }
return key return key
...@@ -52,7 +52,7 @@ class Storage { ...@@ -52,7 +52,7 @@ class Storage {
if (key) { if (key) {
// 判断值是否是指定的对象值 // 判断值是否是指定的对象值
let tmpKey = this.checkKeyType(key, 1) let tmpKey = this.checkKeyType(key, 1)
let isObjectKey = STORAGE_OBJECTkEY[tmpKey] let isObjectKey = STORAGE_OBJECTKEY[tmpKey]
// console.log(key) // console.log(key)
// console.log(isObjectKey) // console.log(isObjectKey)
if (isObjectKey) { if (isObjectKey) {
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-16 09:55:40 * @Date: 2024-04-16 09:55:40
* @LastEditors: 前端 qianduan01@didihu.com.cn * @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 * @FilePath: \gl-tape\utils\cache\storageApi.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @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) // console.log(storage)
/** */ /** */
// 实例化对象存储 // 实例化对象存储
...@@ -68,13 +68,13 @@ export function setSystem_info(that) { ...@@ -68,13 +68,13 @@ export function setSystem_info(that) {
} }
export function getRecords(record = 'recordList') { export function getRecords(record = 'recordList') {
return storage.get(STORAGE_OBJECTkEY[record]) return storage.get(STORAGE_OBJECTKEY[record])
} }
export function setRecords(data, record = 'recordList') { export function setRecords(data, record = 'recordList') {
storage.set(STORAGE_OBJECTkEY[record], data) storage.set(STORAGE_OBJECTKEY[record], data)
} }
export function removeRecords(record = 'recordList') { export function removeRecords(record = 'recordList') {
storage.rm(STORAGE_OBJECTkEY[record]) storage.rm(STORAGE_OBJECTKEY[record])
} }
export default { export default {
getSessionId, 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 @@ ...@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-10-14 17:38:35 * @Date: 2024-10-14 17:38:35
* @LastEditors: 前端 qianduan01@didihu.com.cn * @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 * @FilePath: \gl-tape\utils\recordManager\interruptRecord.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -10,6 +10,7 @@ import RecordManager from '../RecordManager.js' ...@@ -10,6 +10,7 @@ import RecordManager from '../RecordManager.js'
import utils from '@/utils/utils.js' import utils from '@/utils/utils.js'
import { storageApi } from '../cache' import { storageApi } from '../cache'
import store from '@/store' import store from '@/store'
let Interval = null
class InterruptRecord extends RecordManager { class InterruptRecord extends RecordManager {
constructor() { constructor() {
super() super()
...@@ -22,6 +23,7 @@ class InterruptRecord extends RecordManager { ...@@ -22,6 +23,7 @@ class InterruptRecord extends RecordManager {
} }
records = {} records = {}
pathName = null pathName = null
audioPath = null
/** /**
* 获取记录列表 * 获取记录列表
* *
...@@ -47,8 +49,10 @@ class InterruptRecord extends RecordManager { ...@@ -47,8 +49,10 @@ class InterruptRecord extends RecordManager {
* *
*/ */
removePreRecord(id) { removePreRecord(id) {
uni.$logger.local.info(`删除待提交的记录${id}`)
this.removeRecord(id) this.removeRecord(id)
storageApi.setRecords('', 'preRecordId') storageApi.setRecords('', 'preRecordId')
clearInterval(Interval)
} }
/** /**
* 初始化保存记录 * 初始化保存记录
...@@ -57,15 +61,14 @@ class InterruptRecord extends RecordManager { ...@@ -57,15 +61,14 @@ class InterruptRecord extends RecordManager {
* @returns {void} - 此函数不返回任何值 * @returns {void} - 此函数不返回任何值
*/ */
async addPreRecords(params) { async addPreRecords(params) {
console.log(storageApi.getRecords('preRecordId'), 6666)
if (storageApi.getRecords('preRecordId')) { if (storageApi.getRecords('preRecordId')) {
uni.$logger.local.info(`添加录音${storageApi.getRecords('preRecordId')}`)
this.addPreAudio() this.addPreAudio()
return return
} }
console.log('pathName')
const pathName = await this.getAudioPathName() const pathName = await this.getAudioPathName()
const audioPath = await this.getAudioPath(pathName) const audioPath = await this.getAudioPath(pathName)
this.audioPath = audioPath
const id = utils.uuid() const id = utils.uuid()
storageApi.setRecords(id, 'preRecordId') storageApi.setRecords(id, 'preRecordId')
const ids = storageApi.getRecords('preRecordId') const ids = storageApi.getRecords('preRecordId')
...@@ -75,22 +78,63 @@ class InterruptRecord extends RecordManager { ...@@ -75,22 +78,63 @@ class InterruptRecord extends RecordManager {
...params, ...params,
audioPath: [audioPath] audioPath: [audioPath]
} }
uni.$logger.local.info(`开始保存记录${id}`)
const records = this.getRecords() || [] const records = this.getRecords() || []
records.push(this.records) records.push(this.records)
this.setRecords(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} - 此函数不返回任何值 * @returns {void} - 此函数不返回任何值
*/ */
async addPreAudio() { async addPreAudio() {
clearInterval(Interval)
this.updateAudio()
const pathName = await this.getAudioPathName() const pathName = await this.getAudioPathName()
const audioPath = await this.getAudioPath(pathName) const audioPath = await this.getAudioPath(pathName)
this.audioPath = audioPath
const addAudioPath = [...this.records.audioPath, audioPath]
this.records.audioPath.push(audioPath) this.records.audioPath.push(audioPath)
const records = this.getPreRecord() const records = this.getPreRecord()
const params = { ...records, ...this.records } const params = { ...records, audioPath: addAudioPath }
this.updateRecord(params) this.updateRecord(params)
this.setLoopAudio()
} }
/** /**
* 更新参数 * 更新参数
...@@ -99,7 +143,9 @@ class InterruptRecord extends RecordManager { ...@@ -99,7 +143,9 @@ class InterruptRecord extends RecordManager {
*/ */
updatePreRecords(params, isRemoveId) { updatePreRecords(params, isRemoveId) {
if (isRemoveId) { if (isRemoveId) {
uni.$logger.local.info(`清除正在接待记录的id`)
storageApi.setRecords('', 'preRecordId') storageApi.setRecords('', 'preRecordId')
clearInterval(Interval)
} }
const updateParams = { ...this.records, ...params } const updateParams = { ...this.records, ...params }
console.log(updateParams, 'updateParams') console.log(updateParams, 'updateParams')
...@@ -174,17 +220,39 @@ class InterruptRecord extends RecordManager { ...@@ -174,17 +220,39 @@ class InterruptRecord extends RecordManager {
var dirR = e.createReader() var dirR = e.createReader()
dirR.readEntries( dirR.readEntries(
function (er) { function (er) {
for (var i = 0; i < er.length; i++) { Promise.all(
if (er[i].name.startsWith('uniapp_temp')) { er.map((item, index) => {
resolve(er[i].name) console.log(item, 'item')
} return new Promise(resolve => {
// er[i].getMetadata(function (metadata) { item.getMetadata(metadata => {
// console.log(metadata.modificationTime, '修改时间') 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 => { err => {
console.log(err) reject(err)
} }
) )
}, },
......
/* /*
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 17:16:46 * @Date: 2024-04-08 17:16:46
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: limin
* @LastEditTime: 2024-09-23 17:40:40 * @LastEditTime: 2024-11-07 15:56:05
* @FilePath: \gl_tape\utils\utils.js * @FilePath: \gl_tape\utils\utils.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -17,7 +17,7 @@ function convertDateTimeFormat(dateTimeStr, separator = '-') { ...@@ -17,7 +17,7 @@ function convertDateTimeFormat(dateTimeStr, separator = '-') {
return `${year}${separator}${month}${separator}${day} ${hours}:${minutes}:${seconds}` return `${year}${separator}${month}${separator}${day} ${hours}:${minutes}:${seconds}`
} }
function deepClone(value) { export function deepClone(value) {
// 排除原始类型的情况,函数时也满足此条件 // 排除原始类型的情况,函数时也满足此条件
if (typeof value !== 'object' || value === null) { if (typeof value !== 'object' || value === null) {
return value return value
...@@ -174,6 +174,17 @@ async function getAudioFilePath(path = '') { ...@@ -174,6 +174,17 @@ async function getAudioFilePath(path = '') {
const rootPath = await getFilePath() const rootPath = await getFilePath()
return `file://${rootPath}${path}` 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 { export default {
compareVersions, compareVersions,
convertDateTimeFormat, convertDateTimeFormat,
...@@ -185,5 +196,6 @@ export default { ...@@ -185,5 +196,6 @@ export default {
uuid, uuid,
getFilePath, getFilePath,
getFileSaveFolderOnClient, getFileSaveFolderOnClient,
serializeIfObject,
getAudioFilePath 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!