Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
inspection-pad-web
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
专网
inspection-pad-web
Commits
d191c3fa
提交
d191c3fa
authored
4月 14, 2025
作者:
zs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
edit
上级
0892dbfe
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
477 行增加
和
466 行删除
+477
-466
inspect.js
api/inspect.js
+1
-1
init.js
api/sqllite/init.js
+9
-15
dialog.vue
pages/inspectionManagement/dialog.vue
+453
-429
systemCofig.js
utils/systemCofig.js
+14
-21
没有找到文件。
api/inspect.js
浏览文件 @
d191c3fa
...
...
@@ -45,7 +45,7 @@ export default {
,inspectionTime
,isException
,synFlag
,createTime,delFlag
,createTime,delFlag
,inspectionData
FROM
${
table
.
inspectionRecordName
}
where 1=1
${
data
.
inspectionType
?
`AND inspectionType = '
${
data
.
inspectionType
}
'`
:
''
}
...
...
api/sqllite/init.js
浏览文件 @
d191c3fa
...
...
@@ -13,7 +13,7 @@ export default {
// app初始化
async
init
()
{
const
BASE_PATH
=
"_documents/data/asmzx/pad"
;
// 基础路径
// uni.showLoading({
// title: '正在初始化...',
// })
...
...
@@ -25,7 +25,7 @@ export default {
await
this
.
initSqlLite
(
sqllitedb
);
// 确保表被创建
console
.
log
(
'Tables created.'
);
await
ioUtil
.
createDir
(
BASE_PATH
,
'发送数据'
)
let
isInit
=
await
SqlliteDbUtil
.
checkIfDataImported
(
sqllitedb
);
// 确保表存在后再查询
console
.
log
(
'Data imported:'
,
isInit
);
if
(
!
isInit
)
{
...
...
@@ -94,20 +94,14 @@ export default {
// 初始化目录
async
initDir
()
{
try
{
const
_www
=
_Path
.
getPrivateWWW
()
const
_doc
=
_Path
.
getPrivateDOC
()
const
_download
=
_Path
.
getDownloads
()
const
_temp
=
_Path
.
getTempPath
()
const
wwwEntry
=
await
ioUtil
.
getFileEntry
(
_www
)
const
docEntry
=
await
ioUtil
.
getFileEntry
(
_doc
)
const
downloadEntry
=
await
ioUtil
.
getFileEntry
(
_download
)
const
downloadEntry
=
await
ioUtil
.
getFileEntry
()
if
(
downloadEntry
)
{
await
ioUtil
.
createDir
(
downloadEntry
.
fullPath
,
'base'
)
await
ioUtil
.
createDir
(
downloadEntry
.
fullPath
,
'export'
)
await
ioUtil
.
createDir
(
downloadEntry
.
fullPath
,
'import'
)
await
ioUtil
.
createDir
(
downloadEntry
.
fullPath
,
'doc'
)
await
ioUtil
.
createDir
(
downloadEntry
.
fullPath
,
'error'
)
await
ioUtil
.
createDir
(
BASE_PATH
,
'base'
)
await
ioUtil
.
createDir
(
BASE_PATH
,
'export'
)
await
ioUtil
.
createDir
(
BASE_PATH
,
'import'
)
await
ioUtil
.
createDir
(
BASE_PATH
,
'doc'
)
await
ioUtil
.
createDir
(
BASE_PATH
,
'error'
)
}
// 获取设备名称
...
...
@@ -118,7 +112,7 @@ export default {
brand
:
e
.
deviceBrand
,
deviceModel
:
e
.
deviceModel
,
}
const
deviceFilePath
=
downloadEntry
.
fullPath
+
'name.txt'
const
deviceFilePath
=
BASE_PATH
+
'name.txt'
await
ioUtil
.
removeExistFile
(
deviceFilePath
)
await
ioUtil
.
writeFile
(
'name.txt'
,
downloadEntry
,
JSON
.
stringify
(
deviceData
))
},
...
...
pages/inspectionManagement/dialog.vue
浏览文件 @
d191c3fa
<
template
>
<view
class=
"synchronous-dialog"
>
<view
class=
"synchronous-content"
>
<view
class=
"row-item"
>
<text
class=
"title"
>
待打包数据
</text>
</view>
<view
class=
"row-item count-num"
>
<text
class=
"num"
>
{{
list
.
length
}}
</text>
<text>
条
</text>
</view>
<view
class=
"operating-instructions"
>
<view
class=
"title"
>
操作说明:
</view>
<view
class=
"instructions-item"
>
1、在PAD端,点击“数据打包”,做好同步准备。
</view>
<view
class=
"instructions-item"
>
2、完成打包后,将PAD直联PC机,等待PC机自动导入需同步记录。
</view>
<view
class=
"instructions-item"
>
3、PC端自动导入完成后,请点击“同步数据”,同步成功后,列表自动刷新展示同步数据;且PAD同步的数据不支持修改。
</view>
</view>
<view
class=
"row-item bottom-row"
>
<button
class=
"button"
:loading=
"loading"
@
click=
"clickHandle"
>
数据打包
</button>
</view>
<!-- 关闭按钮 -->
<div
class=
"close-button"
>
<text
class=
"iconfont icon-shibai1"
@
click=
"close"
></text>
</div>
</view>
</view>
<view
class=
"synchronous-dialog"
>
<view
class=
"synchronous-content"
>
<view
class=
"row-item"
>
<text
class=
"title"
>
待打包数据
</text>
</view>
<view
class=
"row-item count-num"
>
<text
class=
"num"
>
{{
list
.
length
}}
</text>
<text>
条
</text>
</view>
<view
class=
"operating-instructions"
>
<view
class=
"title"
>
操作说明:
</view>
<view
class=
"instructions-item"
>
1、在PAD端,点击“数据打包”,做好同步准备。
</view>
<view
class=
"instructions-item"
>
2、完成打包后,将PAD直联PC机,等待PC机自动导入需同步记录。
</view>
<view
class=
"instructions-item"
>
3、PC端自动导入完成后,请点击“同步数据”,同步成功后,列表自动刷新展示同步数据;且PAD同步的数据不支持修改。
</view>
</view>
<view
class=
"row-item bottom-row"
>
<button
class=
"button"
:loading=
"loading"
@
click=
"clickHandle"
>
数据打包
</button>
</view>
<!-- 关闭按钮 -->
<div
class=
"close-button"
>
<text
class=
"iconfont icon-shibai1"
@
click=
"close"
></text>
</div>
</view>
</view>
</
template
>
<
script
>
import
{
SYNCHRONIZE_DATA_PAD
,
checkAndCreateDirectory
,
createFileWithPlusIO
,
setSm2
,
USER_FILE_NAME
,
getUserList
,
}
from
"@/utils/systemCofig"
;
import
{
findPhotosUrls
}
from
"@/utils/index.js"
;
import
{
copySelectedFiles
}
from
"@/utils/plus.js"
;
import
{
writeInspectionData
,
copyDirectory
,
deleteAllFilesInDirectory
,
addLog
,
getLogContent
,
LOG_TYPE_ENUM
,
}
from
"@/utils/IoReadingAndWriting.js"
;
import
moment
from
"moment"
;
import
{
getAllInspections
}
from
"@/request/index.js"
;
import
{
Base64
}
from
"js-base64"
;
import
inspectApi
from
"@/api/inspect"
;
export
default
{
props
:
{
list
:
{
type
:
Array
,
default
:
()
=>
{},
},
},
components
:
{},
data
()
{
return
{
loading
:
false
,
notSynchronizationList
:
[],
// 未同步数据
allList
:
[],
// 所有数据
};
},
computed
:
{
userInfo
()
{
return
this
.
$store
.
state
.
now_user
;
},
},
watch
:
{
list
(
newVal
)
{
console
.
log
(
"newVal"
,
newVal
);
this
.
init
();
},
},
// async mounted() {
// const temp = [];
// this.list.forEach((item) => {
// temp.push(...(item.list || []));
// });
// console.log("this.list", this.list);
// console.log("temp", temp);
// this.notSynchronizationList = temp.filter(
// (item) => item.synchronization == 0 && item.isSign === true
// );
// getAllInspections().then((res) => {
// this.allList = res;
// });
// },
methods
:
{
init
()
{
const
temp
=
[];
this
.
notSynchronizationList
=
this
.
list
;
getAllInspections
().
then
((
res
)
=>
{
this
.
allList
=
res
;
});
},
close
()
{
this
.
$emit
(
"close"
);
},
/**
* 1.生成两个文件. 机房文件 和 井道文件
* 2. 更新巡检数据状态 synchronization 置为 1
* 3. 写入数据
* 读取上一次打包的文件, 复制到 [ history ] 文件夹中
*/
async
clickHandle
()
{
if
(
this
.
loading
)
return
;
const
directoryPath
=
`
${
SYNCHRONIZE_DATA_PAD
}
/发送数据`
;
const
targetDirectoryPath
=
`
${
SYNCHRONIZE_DATA_PAD
}
/history`
;
checkAndCreateDirectory
(
directoryPath
).
then
(()
=>
{
copyDirectory
(
directoryPath
,
targetDirectoryPath
)
.
then
(()
=>
{
return
deleteAllFilesInDirectory
(
directoryPath
);
})
.
then
(()
=>
{
this
.
coverData
();
})
.
catch
((
error
)
=>
{
uni
.
showToast
({
title
:
error
,
icon
:
"none"
,
duration
:
1000
,
});
});
});
},
copyPhotos
()
{
const
urls
=
findPhotosUrls
(
this
.
list
).
map
((
url
)
=>
url
.
split
(
"/"
).
pop
());
console
.
log
(
"urls"
,
urls
);
return
copySelectedFiles
(
"_documents/data/photos"
,
`
${
SYNCHRONIZE_DATA_PAD
}
/发送数据/
${
this
.
userInfo
.
user
}
`
,
urls
);
},
// 处理数据
coverData
()
{
const
userName
=
this
.
$store
.
state
.
now_user
.
user
;
const
notSynchronizationList
=
this
.
notSynchronizationList
;
const
allList
=
this
.
allList
;
console
.
log
(
"窗口allList"
,
allList
);
console
.
log
(
"窗口this.notSynchronizationList"
,
this
.
notSynchronizationList
);
let
timeStr
=
moment
().
format
(
"yyyy_MM_DD_hh_mm_ss"
);
const
JFXJ_DATA
=
notSynchronizationList
.
filter
((
item
)
=>
item
.
inspectionType
==
1
)
.
map
((
item
)
=>
{
return
item
;
});
// 机房数据类型是 1
const
JDXJ_DATA
=
notSynchronizationList
.
filter
((
item
)
=>
item
.
inspectionType
==
2
)
.
map
((
item
)
=>
{
return
item
;
});
// 井道数据类型是 2
console
.
log
(
5151
,
JFXJ_DATA
,
JDXJ_DATA
);
this
.
loading
=
true
;
const
tmepList
=
[];
if
(
JFXJ_DATA
.
length
)
{
let
JFXJ_DATA_FILE_NAME
=
`
${
userName
}
_JFXJ_
${
timeStr
}
.txt`
;
tmepList
.
push
(
this
.
packedData
(
JFXJ_DATA
,
JFXJ_DATA_FILE_NAME
));
}
JDXJ_DATA
.
forEach
((
item
,
index
)
=>
{
let
JDXJ_DATA_FILE_NAME
=
`
${
userName
}
_JDXJ_
${
timeStr
}
_
${
index
}
.txt`
;
tmepList
.
push
(
this
.
packedData
(
item
,
JDXJ_DATA_FILE_NAME
));
});
console
.
log
(
"同步窗口"
);
console
.
log
(
"同步窗口"
,
tmepList
);
Promise
.
all
(
tmepList
)
.
then
(()
=>
{
// 更新巡检数据状态
const
synchronizationUids
=
notSynchronizationList
.
map
((
item
)
=>
{
item
.
synchronization
=
1
;
return
item
.
uid
;
});
const
userData
=
{};
allList
.
forEach
((
item
)
=>
{
if
(
synchronizationUids
.
includes
(
item
.
uid
))
{
item
.
synchronization
=
1
;
}
if
(
userData
[
item
.
createByName
])
{
userData
[
item
.
createByName
].
push
(
item
);
}
else
{
userData
[
item
.
createByName
]
=
[
item
];
}
});
this
.
$store
.
commit
(
"SET_ALL_DATA"
,
allList
);
const
keys
=
Object
.
keys
(
userData
);
const
promiseArr
=
keys
.
map
((
key
)
=>
{
const
val
=
userData
[
key
];
return
writeInspectionData
(
val
,
key
);
});
Promise
.
all
(
promiseArr
)
.
then
(
async
()
=>
{
setTimeout
(
async
()
=>
{
uni
.
showToast
({
title
:
"打包成功"
,
icon
:
"none"
,
duration
:
2000
,
});
let
ids
=
this
.
list
.
map
((
e
)
=>
e
.
id
);
await
inspectApi
.
updateSyncData
(
ids
);
this
.
close
();
this
.
loading
=
false
;
// 生成日志
const
logContent
=
getLogContent
(
LOG_TYPE_ENUM
.
sys
,
""
,
"同步模块"
);
const
log_list
=
this
.
$store
.
state
.
log_list
;
log_list
.
push
(
logContent
);
this
.
$store
.
commit
(
"SET_LOG_LIST"
,
log_list
);
addLog
(
log_list
).
then
((
res
)
=>
{});
// 更新同步时间
this
.
updateSysTime
();
// 复制照片
await
this
.
copyPhotos
();
// zip
},
2
*
1000
);
})
.
catch
((
error
)
=>
{
this
.
loading
=
false
;
uni
.
showToast
({
title
:
error
,
icon
:
"none"
,
duration
:
2000
,
});
});
})
.
catch
(()
=>
{
setTimeout
(()
=>
{
uni
.
showToast
({
title
:
"打包失败"
,
icon
:
"none"
,
duration
:
2000
,
});
this
.
loading
=
false
;
},
2
*
1000
);
});
},
// 打包文件
packedData
(
content
,
fileName
)
{
// const fileContent = setSm2(content);
const
fileContent
=
Base64
.
encode
(
JSON
.
stringify
(
content
));
console
.
log
(
"packedData"
,
fileContent
);
return
createFileWithPlusIO
(
`
${
SYNCHRONIZE_DATA_PAD
}
/发送数据`
,
fileName
,
fileContent
);
},
// 更新最近一次同步时间
updateSysTime
()
{
getUserList
().
then
((
personList
)
=>
{
const
now_user
=
this
.
$store
.
state
.
now_user
;
const
key
=
personList
.
findIndex
(
(
item
)
=>
item
.
userId
==
now_user
.
userId
);
// 更新用户同步时间
const
userInfo
=
personList
[
key
];
const
LastSynchronizationTime
=
moment
().
format
(
"yyyy-MM-DD HH:mm"
);
personList
[
key
].
LastSynchronizationTime
=
LastSynchronizationTime
;
userInfo
.
LastSynchronizationTime
=
LastSynchronizationTime
;
this
.
$store
.
commit
(
"SET_USER"
,
userInfo
);
uni
.
setStorageSync
(
"last_time"
,
userInfo
.
LastSynchronizationTime
||
""
);
// 更新用户数据
const
fileContent
=
JSON
.
stringify
(
Base64
.
encode
(
JSON
.
stringify
(
personList
))
);
uni
.
setStorage
({
key
:
"user_data"
,
data
:
JSON
.
stringify
(
personList
),
fail
:
(
error
)
=>
{
console
.
log
(
"APP.vue 存储数据失败"
,
error
);
},
});
createFileWithPlusIO
(
SYNCHRONIZE_DATA_PAD
,
USER_FILE_NAME
,
fileContent
)
.
then
(()
=>
{
console
.
log
(
"---用户数据更新成功"
);
})
.
catch
((
error
)
=>
{
console
.
log
(
"---用户数据更新失败"
,
error
);
});
});
},
},
};
import
{
SYNCHRONIZE_DATA_PAD
,
checkAndCreateDirectory
,
createFileWithPlusIO
,
setSm2
,
USER_FILE_NAME
,
getUserList
,
zipCompress
}
from
"@/utils/systemCofig"
;
import
{
findPhotosUrls
}
from
"@/utils/index.js"
;
import
{
copySelectedFiles
}
from
"@/utils/plus.js"
;
import
{
writeInspectionData
,
copyDirectory
,
deleteAllFilesInDirectory
,
addLog
,
getLogContent
,
LOG_TYPE_ENUM
,
}
from
"@/utils/IoReadingAndWriting.js"
;
import
moment
from
"moment"
;
import
{
getAllInspections
}
from
"@/request/index.js"
;
import
{
Base64
}
from
"js-base64"
;
import
inspectApi
from
"@/api/inspect"
;
import
inspect
from
"@/api/inspect"
;
export
default
{
props
:
{
list
:
{
type
:
Array
,
default
:
()
=>
{},
},
},
components
:
{},
data
()
{
return
{
loading
:
false
,
notSynchronizationList
:
[],
// 未同步数据
allList
:
[],
// 所有数据
};
},
computed
:
{
userInfo
()
{
return
this
.
$store
.
state
.
now_user
;
},
},
watch
:
{
list
(
newVal
)
{
console
.
log
(
"newVal"
,
newVal
);
this
.
init
();
},
},
// async mounted() {
// const temp = [];
// this.list.forEach((item) => {
// temp.push(...(item.list || []));
// });
// console.log("this.list", this.list);
// console.log("temp", temp);
// this.notSynchronizationList = temp.filter(
// (item) => item.synchronization == 0 && item.isSign === true
// );
// getAllInspections().then((res) => {
// this.allList = res;
// });
// },
methods
:
{
init
()
{
const
temp
=
[];
this
.
notSynchronizationList
=
this
.
list
;
getAllInspections
().
then
((
res
)
=>
{
this
.
allList
=
res
;
});
},
close
()
{
this
.
$emit
(
"close"
);
},
/**
* 1.生成两个文件. 机房文件 和 井道文件
* 2. 更新巡检数据状态 synchronization 置为 1
* 3. 写入数据
* 读取上一次打包的文件, 复制到 [ history ] 文件夹中
*/
async
clickHandle
()
{
if
(
this
.
loading
)
return
;
const
directoryPath
=
`
${
SYNCHRONIZE_DATA_PAD
}
/发送数据`
;
const
targetDirectoryPath
=
`
${
SYNCHRONIZE_DATA_PAD
}
/history`
;
// checkAndCreateDirectory(directoryPath).then(() => {
copyDirectory
(
directoryPath
,
targetDirectoryPath
)
.
then
(()
=>
{
return
deleteAllFilesInDirectory
(
directoryPath
);
})
.
then
(()
=>
{
this
.
coverData
();
})
.
catch
((
error
)
=>
{
uni
.
showToast
({
title
:
error
,
icon
:
"none"
,
duration
:
1000
,
});
});
// });
},
copyPhotos
()
{
this
.
list
.
forEach
(
e
=>
{
e
.
inspectionData
=
JSON
.
parse
(
e
.
inspectionData
)
||
'{}'
})
const
urls
=
findPhotosUrls
(
this
.
list
).
map
((
url
)
=>
url
.
split
(
"/"
).
pop
());
console
.
log
(
"urls"
,
urls
);
return
copySelectedFiles
(
"_documents/data/photos"
,
`
${
SYNCHRONIZE_DATA_PAD
}
/发送数据`
,
urls
);
},
// 处理数据
coverData
()
{
const
userName
=
this
.
$store
.
state
.
now_user
.
user
;
const
notSynchronizationList
=
this
.
notSynchronizationList
;
const
allList
=
this
.
allList
;
console
.
log
(
"窗口allList"
,
allList
);
console
.
log
(
"窗口this.notSynchronizationList"
,
this
.
notSynchronizationList
);
let
timeStr
=
moment
().
format
(
"yyyy_MM_DD_hh_mm_ss"
);
const
JFXJ_DATA
=
notSynchronizationList
.
filter
((
item
)
=>
item
.
inspectionType
==
1
)
.
map
((
item
)
=>
{
return
item
;
});
// 机房数据类型是 1
const
JDXJ_DATA
=
notSynchronizationList
.
filter
((
item
)
=>
item
.
inspectionType
==
2
)
.
map
((
item
)
=>
{
return
item
;
});
// 井道数据类型是 2
console
.
log
(
5151
,
JFXJ_DATA
,
JDXJ_DATA
);
this
.
loading
=
true
;
const
tmepList
=
[];
if
(
JFXJ_DATA
.
length
)
{
let
JFXJ_DATA_FILE_NAME
=
`
${
userName
}
_JFXJ_
${
timeStr
}
.txt`
;
tmepList
.
push
(
this
.
packedData
(
JFXJ_DATA
,
JFXJ_DATA_FILE_NAME
));
}
JDXJ_DATA
.
forEach
((
item
,
index
)
=>
{
let
JDXJ_DATA_FILE_NAME
=
`
${
userName
}
_JDXJ_
${
timeStr
}
_
${
index
}
.txt`
;
tmepList
.
push
(
this
.
packedData
(
item
,
JDXJ_DATA_FILE_NAME
));
});
console
.
log
(
"同步窗口"
);
console
.
log
(
"同步窗口"
,
tmepList
);
Promise
.
all
(
tmepList
)
.
then
(()
=>
{
// 更新巡检数据状态
const
synchronizationUids
=
notSynchronizationList
.
map
((
item
)
=>
{
item
.
synchronization
=
1
;
return
item
.
uid
;
});
const
userData
=
{};
allList
.
forEach
((
item
)
=>
{
if
(
synchronizationUids
.
includes
(
item
.
uid
))
{
item
.
synchronization
=
1
;
}
if
(
userData
[
item
.
createByName
])
{
userData
[
item
.
createByName
].
push
(
item
);
}
else
{
userData
[
item
.
createByName
]
=
[
item
];
}
});
this
.
$store
.
commit
(
"SET_ALL_DATA"
,
allList
);
const
keys
=
Object
.
keys
(
userData
);
const
promiseArr
=
keys
.
map
((
key
)
=>
{
const
val
=
userData
[
key
];
return
writeInspectionData
(
val
,
key
);
});
Promise
.
all
(
promiseArr
)
.
then
(
async
()
=>
{
setTimeout
(
async
()
=>
{
uni
.
showToast
({
title
:
"打包成功"
,
icon
:
"none"
,
duration
:
2000
,
});
let
ids
=
this
.
list
.
map
((
e
)
=>
e
.
id
);
// 复制照片
await
this
.
copyPhotos
();
await
zipCompress
(
`
${
SYNCHRONIZE_DATA_PAD
}
/发送数据`
,
`
${
SYNCHRONIZE_DATA_PAD
}
/fssj/
${
userName
}
_JFXJ_
${
timeStr
}
.zip`
);
// zip
await
inspectApi
.
updateSyncData
(
ids
);
this
.
close
();
this
.
loading
=
false
;
// 生成日志
const
logContent
=
getLogContent
(
LOG_TYPE_ENUM
.
sys
,
""
,
"同步模块"
);
const
log_list
=
this
.
$store
.
state
.
log_list
;
log_list
.
push
(
logContent
);
this
.
$store
.
commit
(
"SET_LOG_LIST"
,
log_list
);
addLog
(
log_list
).
then
((
res
)
=>
{});
// 更新同步时间
this
.
updateSysTime
();
},
2
*
1000
);
})
.
catch
((
error
)
=>
{
this
.
loading
=
false
;
uni
.
showToast
({
title
:
error
,
icon
:
"none"
,
duration
:
2000
,
});
});
})
.
catch
(()
=>
{
setTimeout
(()
=>
{
uni
.
showToast
({
title
:
"打包失败"
,
icon
:
"none"
,
duration
:
2000
,
});
this
.
loading
=
false
;
},
2
*
1000
);
});
},
// 使用示例
// 打包文件
packedData
(
content
,
fileName
)
{
// const fileContent = setSm2(content);
const
fileContent
=
Base64
.
encode
(
JSON
.
stringify
(
content
));
console
.
log
(
"packedData"
,
fileContent
);
return
createFileWithPlusIO
(
`
${
SYNCHRONIZE_DATA_PAD
}
/发送数据`
,
fileName
,
fileContent
);
},
// 更新最近一次同步时间
updateSysTime
()
{
getUserList
().
then
((
personList
)
=>
{
const
now_user
=
this
.
$store
.
state
.
now_user
;
const
key
=
personList
.
findIndex
(
(
item
)
=>
item
.
userId
==
now_user
.
userId
);
// 更新用户同步时间
const
userInfo
=
personList
[
key
];
const
LastSynchronizationTime
=
moment
().
format
(
"yyyy-MM-DD HH:mm"
);
personList
[
key
].
LastSynchronizationTime
=
LastSynchronizationTime
;
userInfo
.
LastSynchronizationTime
=
LastSynchronizationTime
;
this
.
$store
.
commit
(
"SET_USER"
,
userInfo
);
uni
.
setStorageSync
(
"last_time"
,
userInfo
.
LastSynchronizationTime
||
""
);
// 更新用户数据
const
fileContent
=
JSON
.
stringify
(
Base64
.
encode
(
JSON
.
stringify
(
personList
))
);
uni
.
setStorage
({
key
:
"user_data"
,
data
:
JSON
.
stringify
(
personList
),
fail
:
(
error
)
=>
{
console
.
log
(
"APP.vue 存储数据失败"
,
error
);
},
});
createFileWithPlusIO
(
SYNCHRONIZE_DATA_PAD
,
USER_FILE_NAME
,
fileContent
)
.
then
(()
=>
{
console
.
log
(
"---用户数据更新成功"
);
})
.
catch
((
error
)
=>
{
console
.
log
(
"---用户数据更新失败"
,
error
);
});
});
},
},
};
</
script
>
<
style
scoped
lang=
"less"
>
.synchronous-dialog {
position: fixed;
z-index: 999;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
.synchronous-content {
padding: 3% 20px 32px 24px;
width: 400px;
height: 60%;
box-sizing: border-box;
background-image: linear-gradient(
-6deg,
#f9ffe7 0%,
#ffffff 12%,
#fcfeff 73%,
#ccf1ff 100%
);
border: 0.4px solid rgba(224, 224, 224, 1);
border-radius: 12px;
position: relative;
.row-item {
display: flex;
align-items: center;
justify-content: center;
}
.title {
font-family: PingFangSC-Medium;
font-size: 18px;
color: #000000;
text-align: center;
line-height: 26px;
font-weight: 500;
}
.count-num {
margin: 5% 0 5% 0;
align-items: flex-end;
.num {
display: inline-block;
font-family: AlibabaPuHuiTi_2_65_Medium;
font-size: 50px;
color: #3774f6;
line-height: 44px;
font-weight: 500;
}
}
.operating-instructions {
margin-bottom: 8%;
.title {
font-size: 13px;
color: #4a4a4a;
line-height: 24px;
font-weight: 600;
text-align: left;
}
.instructions-item {
font-size: 12px;
color: #7c7c7c;
line-height: 22px;
font-weight: 400;
}
}
// 打包按钮
.bottom-row {
position: absolute;
bottom: 24px;
left: 50%;
transform: translateX(-50%);
.button {
display: flex;
align-items: center;
justify-content: center;
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
box-shadow: 0px 10px 24px 0px rgba(51, 104, 246, 0.24);
border-radius: 27px;
width: 160px;
height: 40px;
color: #fff;
}
}
// 关闭按钮
.close-button {
position: absolute;
bottom: -40px;
left: 50%;
transform: translateX(-50%);
.iconfont {
font-size: 24px;
}
}
}
}
</
style
>
.synchronous-dialog {
position: fixed;
z-index: 999;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
.synchronous-content {
padding: 3% 20px 32px 24px;
width: 400px;
height: 60%;
box-sizing: border-box;
background-image: linear-gradient(-6deg,
#f9ffe7 0%,
#ffffff 12%,
#fcfeff 73%,
#ccf1ff 100%);
border: 0.4px solid rgba(224, 224, 224, 1);
border-radius: 12px;
position: relative;
.row-item {
display: flex;
align-items: center;
justify-content: center;
}
.title {
font-family: PingFangSC-Medium;
font-size: 18px;
color: #000000;
text-align: center;
line-height: 26px;
font-weight: 500;
}
.count-num {
margin: 5% 0 5% 0;
align-items: flex-end;
.num {
display: inline-block;
font-family: AlibabaPuHuiTi_2_65_Medium;
font-size: 50px;
color: #3774f6;
line-height: 44px;
font-weight: 500;
}
}
.operating-instructions {
margin-bottom: 8%;
.title {
font-size: 13px;
color: #4a4a4a;
line-height: 24px;
font-weight: 600;
text-align: left;
}
.instructions-item {
font-size: 12px;
color: #7c7c7c;
line-height: 22px;
font-weight: 400;
}
}
// 打包按钮
.bottom-row {
position: absolute;
bottom: 24px;
left: 50%;
transform: translateX(-50%);
.button {
display: flex;
align-items: center;
justify-content: center;
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
box-shadow: 0px 10px 24px 0px rgba(51, 104, 246, 0.24);
border-radius: 27px;
width: 160px;
height: 40px;
color: #fff;
}
}
// 关闭按钮
.close-button {
position: absolute;
bottom: -40px;
left: 50%;
transform: translateX(-50%);
.iconfont {
font-size: 24px;
}
}
}
}
</
style
>
\ No newline at end of file
utils/systemCofig.js
浏览文件 @
d191c3fa
...
...
@@ -471,25 +471,17 @@ export function getUserList() {
});
}
export
function
zipCompress
(
name
)
{
const
BASE_PATH
=
"_documents/data"
;
const
targetPath
=
plus
.
io
.
convertLocalFileSystemURL
(
BASE_PATH
+
'/photos'
);
const
zipfile
=
plus
.
io
.
convertLocalFileSystemURL
(
BASE_PATH
+
`/
${
name
}
.zip`
);
plus
.
zip
.
compress
(
targetPath
,
zipfile
,
{
recursive
:
true
,
overwrite
:
true
},
function
()
{
plus
.
io
.
resolveLocalFileSystemURL
(
zipfile
,
function
(
zipEntry
)
{
zipEntry
.
file
(
function
(
file
)
{
console
.
log
(
"ZIP 文件大小: "
+
file
.
size
+
" 字节"
);
});
});
},
function
(
error
)
{
alert
(
"压缩失败: "
+
error
.
message
);
}
);
export
function
zipCompress
(
sourceDir
,
zipPath
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
plus
.
zip
.
compress
(
plus
.
io
.
convertLocalFileSystemURL
(
sourceDir
),
plus
.
io
.
convertLocalFileSystemURL
(
zipPath
),
{
recursive
:
true
,
overwrite
:
true
,
},
()
=>
resolve
(
zipPath
),
(
error
)
=>
reject
(
`压缩失败:
${
error
.
message
}
`
)
);
});
}
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论