提交 d522c8ff authored 作者: 邓文彬's avatar 邓文彬

fix(pad): bug修改

上级 db344710
......@@ -55,7 +55,6 @@ export default {
function (e) {}
);
// #endif
},
onShow: function () {
const now_user = uni.getStorageSync("now_user") || {};
......@@ -63,13 +62,18 @@ export default {
this.$store.commit("SET_USER", now_user);
}
this.init();
},
onHide: function () {
// app关闭时将数据存储到本地缓存
uni.setStorageSync("now_user", this.$store.state.now_user);
uni.setStorageSync("last_time", this.$store.state.now_user.loginTime);
uni.setStorageSync("last_time", this.$store.state.now_user.LastSynchronizationTime);
uni.redirectTo({
url: "/pages/login/login",
});
uni.clearStorage(); //将所有缓存清除
console.log("---测试", )
},
onUnload() {},
methods: {
......@@ -95,7 +99,7 @@ export default {
});
})
.catch((error) => {
console.log("--USER_LiST-", USER_LiST)
console.log("--USER_LiST-", USER_LiST);
// 文件不存在, 写入文件
const fileContent = JSON.stringify(
Base64.encode(JSON.stringify(USER_LiST))
......
......@@ -7,7 +7,7 @@
>HI,欢迎回来{{ userInfo.name }}{{ userInfo.user }}</view
>
<view class="unit">所属单位:{{ userInfo.unitName || "--" }}</view>
<view class="time">上次登录时间:{{ lastTime || "--" }}</view>
<view class="time">上次同步时间:{{ lastTime || "--" }}</view>
<image
class="bg-img"
......@@ -16,7 +16,7 @@
></image>
</view>
<view class="card-item" @click="toSyncPage">
<view class="title2x">巡检、报修记录</view>
<view class="title2x">巡检记录</view>
<view class="count">
<text class="num">{{ syncCount }}</text
>
......@@ -57,7 +57,7 @@
:key="index"
>
<view v-if="(item.list || []).length" class="seconed-title">
{{ item.time }}
{{ item.submitTime || item.time }}
</view>
<view class="inspect-list">
......@@ -100,7 +100,7 @@ export default {
},
created() {
this.lastTime = uni.getStorageSync("last_time") || "";
// uni.getStorageSync("last_time", this.$store.state.now_user.loginTime || "");
// uni.getStorageSync("last_time", this.$store.state.now_user.LastSynchronizationTime || "");
},
mounted() {
this.init();
......@@ -110,7 +110,6 @@ export default {
userInfo() {
return this.$store.state.now_user || {};
},
},
methods: {
init() {
......@@ -152,11 +151,11 @@ export default {
const tempAllData = {};
all_data.forEach((item) => {
const val = tempAllData[item.submitTime] || [];
const val = tempAllData[item.submitMonth] || [];
if (val.length) {
tempAllData[item.submitTime].push(item);
tempAllData[item.submitMonth].push(item);
} else {
tempAllData[item.submitTime] = [item];
tempAllData[item.submitMonth] = [item];
}
});
......@@ -225,8 +224,6 @@ export default {
},
toPage() {
uni.showLoading();
getDarft()
......@@ -278,7 +275,7 @@ export default {
margin-right: 16px;
height: 166px;
box-sizing: border-box;
padding: 32px 0 24px 24px;
padding: 32px 0 24px 12px;
position: relative;
overflow: hidden;
......@@ -296,9 +293,8 @@ export default {
position: absolute;
right: 0px;
bottom: 0px;
width: 160px;
height: 150px;
// z-index: -1;
width: 110px;
height: 130px;
z-index: 1;
}
......
......@@ -4,7 +4,7 @@
<view class="user-info">
<image class="user-img" src="@/static/img/add-img/home1.png"></image>
<text class="text" >{{ userName }}</text>
<text class="text">{{ userName }}</text>
</view>
<view class="tab-list">
......@@ -24,8 +24,7 @@
<view class="button-group">
<!-- v-if="isAdmin" -->
<view
class="log-button" @click="lookLog">操作日志</view>
<view class="log-button" @click="lookLog">操作日志</view>
<view class="reset-password-button" @click="updatePassword"
>修改密码?</view
>
......@@ -81,7 +80,7 @@ export default {
{
defaultIcon: "iconfont icon-yingyongyewuguanli1",
isActive: true,
text: "页",
text: "页",
},
{
defaultIcon: "iconfont icon-Inspection",
......@@ -98,14 +97,17 @@ export default {
};
},
computed: {
isAdmin(){
return this.$store.state.now_user.isAdmin
}
isAdmin() {
return this.$store.state.now_user.isAdmin;
},
},
onLoad(options = {}) {
// options就是路由参数,它是一个对象
// this.tabIndex = ;
this.tabClick({}, options.tabIndex || 0);
},
watch: {
},
methods: {
// 修改密码
......@@ -128,14 +130,15 @@ export default {
dialogInputConfirm2() {
uni.redirectTo({
url: "/pages/login/login",
success: () =>{
success: () => {
// uni.clearStorage(); //测试将所有缓存清除
// console.log("-退出---",this.$store.state.now_user.loginTime)
// console.log("-退出---",this.$store.state.now_user.LastSynchronizationTime)
uni.setStorageSync("now_user", this.$store.state.now_user);
uni.setStorageSync("last_time", this.$store.state.now_user.loginTime || "");
uni.setStorageSync(
"last_time",
this.$store.state.now_user.LastSynchronizationTime || ""
);
},
});
},
......@@ -181,7 +184,7 @@ export default {
align-items: center;
justify-content: flex-end;
height: 72px;
// border: 1px solid;
.user-img {
height: 48px;
......
......@@ -104,7 +104,7 @@ export default {
this.formData = {
inspectionType: "1",
inspectionCode: `JFXJ${moment().format("yyyyMMDDhhmmss")}`,
recordName: `${moment().format("yyyyMMDDhhmmss")}-机房巡检记录`,
recordName: `${moment().format("yyyyMMDD")}-机房巡检记录`,
inspectionTime: moment().format("yyyy-MM-DD HH:mm:ss"),
inspectionBy: this.$store.state.now_user.user,
inspectionById: this.$store.state.now_user.userId,
......@@ -116,6 +116,7 @@ export default {
fillCheck: "", // tab字典的value值, 校验通过的
creatTime: `${new Date().getTime()}`,
items: [
// {
// "itemCode": "1", // 检查项
......@@ -127,7 +128,7 @@ export default {
},
change(val) {
this.formData.recordName = `${moment().format("yyyyMMDDhhmmss")}-${
this.formData.recordName = `${moment().format("yyyyMMDD")}-${
val.detail.data.text
}`;
this.formData.inspectionType = val.detail.value;
......
......@@ -436,6 +436,8 @@ export default {
isException,
synchronization: 0, // 是否导出过
submitTime: moment().format("yyyy-MM-DD"), // 记录提交时间
submitMonth: moment().format("yyyy-MM"), // 记录提交月份
originData: {
baseInfo,
tempForm,
......
......@@ -18,7 +18,8 @@
:key="index"
>
<view v-if="(item.list || []).length" class="seconed-title">
{{ item.time }}
{{ item.submitTime || item.time
}}
</view>
<view class="inspect-list">
......@@ -98,11 +99,11 @@ export default {
const tempAllData = {};
all_data.forEach((item) => {
const val = tempAllData[item.submitTime] || [];
const val = tempAllData[item.submitMonth] || [];
if (val.length) {
tempAllData[item.submitTime].push(item);
tempAllData[item.submitMonth].push(item);
} else {
tempAllData[item.submitTime] = [item];
tempAllData[item.submitMonth] = [item];
}
});
......
......@@ -33,6 +33,7 @@ import {
TEST,
TEST_2X,
USER_FILE_NAME,
getUserList,
} from "@/utils/systemCofig";
import {
......@@ -72,7 +73,10 @@ export default {
uni.setStorageSync("oper_record", this.$store.state.oper_record);
uni.setStorageSync("all_data", this.$store.state.all_data);
uni.setStorageSync("now_user", this.$store.state.now_user);
uni.setStorageSync("last_time", this.$store.state.now_user.loginTime);
uni.setStorageSync(
"last_time",
this.$store.state.now_user.LastSynchronizationTime
);
plus.runtime.quit();
} else {
plus.nativeUI.toast("再划一次退出应用");
......@@ -83,33 +87,9 @@ export default {
return true;
},
methods: {
setUser() {
return new Promise((resolve, reject) => {
try {
const value = uni.getStorageSync("user_data");
if (value) {
// this.personList = JSON.parse(value);
// console.log("---this.personList", this.personList);
resolve(eval(value));
} else {
uni.getStorage({
key: "user_data",
success: function (res) {
// this.personList =;
// console.log("---this.personList", this.personList);
resolve(eval(value));
},
});
}
} catch (e) {
console.log("setUser--", e);
}
});
},
// 点击登录
login() {
this.setUser().then((personList) => {
getUserList().then((personList) => {
this.personList = personList;
console.log("111", personList);
......@@ -134,42 +114,14 @@ export default {
this.person.user == this.personList[key].user &&
this.person.pd == this.personList[key].passWord
) {
// 存储最近一次登陆时间
const userInfo = this.personList[key];
uni.setStorageSync("last_time", userInfo.loginTime || "");
// console.log("--last_time----",userInfo.loginTime)
// 更新用户登陆时间
const loginTime = moment().format("yyyy-MM-DD");
this.personList[key].loginTime = loginTime;
userInfo.loginTime = loginTime;
this.$store.commit("SET_USER", userInfo);
uni.setStorageSync("now_user", userInfo);
// console.log("--userInfo---", userInfo);
// console.log("写入用户数据内容---", this.personList);
// 更新用户数据
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
);
uni.navigateTo({
url: "/pages/home/home",
});
uni.showToast({
title: "登录成功",
icon: "none",
......@@ -181,6 +133,9 @@ export default {
const log_list = res;
// 更新日志信息
const logContent = getLogContent(LOG_TYPE_ENUM.login);
log_list.push(logContent);
this.$store.commit("SET_LOG_LIST", log_list);
addLog(log_list);
......@@ -188,6 +143,7 @@ export default {
uni.hideLoading();
})
.catch((error) => {
if (error.code == 0) {
uni.showToast({
title: error.msg,
......@@ -207,8 +163,10 @@ export default {
// 密码不正确
} else {
console.log("222");
uni.showToast({
title: "密码错误",
title: "密码错误,请重试",
icon: "none",
duration: 2000,
});
......@@ -216,8 +174,10 @@ export default {
}
// 不存在该账号
} else {
console.log("3333");
uni.showToast({
title: "账号不存在",
title: "您无权登录,请联系管理员处理",
icon: "none",
duration: 2000,
});
......
......@@ -28,7 +28,7 @@
<view class="image-item top-image">
<image
src="@/static/img/add-img/jd_table.png"
src="@/static/img/add-img/jd_bg.png"
mode="widthFix"
></image>
</view>
......
......@@ -338,6 +338,7 @@ export default {
items: [],
synchronization: 0, // 是否导出过
submitTime: moment().format("yyyy-MM-DD"), // 记录提交时间
submitMonth: moment().format("yyyy-MM"), // 记录提交月份
originData: {
baseInfo,
tempForm,
......
......@@ -43,6 +43,8 @@ import {
checkAndCreateDirectory,
createFileWithPlusIO,
setSm2,
USER_FILE_NAME,
getUserList,
} from "@/utils/systemCofig";
import {
......@@ -174,6 +176,7 @@ export default {
}
});
this.$store.commit("SET_ALL_DATA", allList);
console.log("---userData---", userData);
const keys = Object.keys(userData);
const promiseArr = keys.map((key) => {
......@@ -205,6 +208,9 @@ export default {
addLog(log_list).then((res) => {
console.log("日志文件写入成功");
});
// 更新同步时间
this.updateSysTime();
}, 2 * 1000);
})
.catch((error) => {
......@@ -239,6 +245,38 @@ export default {
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;
console.log("---更新最近一次同步时间--", userInfo)
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);
});
},
},
};
</script>
......
......@@ -18,7 +18,7 @@
:key="index"
>
<view v-if="(item.list || []).length" class="seconed-title">{{
item.time
item.submitTime || item.time
}}</view>
<view class="inspect-list">
......@@ -116,11 +116,11 @@ export default {
const tempAllData = {};
all_data.forEach((item) => {
const val = tempAllData[item.submitTime] || [];
const val = tempAllData[item.submitMonth] || [];
if (val.length) {
tempAllData[item.submitTime].push(item);
tempAllData[item.submitMonth].push(item);
} else {
tempAllData[item.submitTime] = [item];
tempAllData[item.submitMonth] = [item];
}
});
......
......@@ -82,7 +82,7 @@ export const readLogData = () => {
return new Promise((resolve, reject) => {
readFilesInDirectory(directoryPath)
.then((res) => {
console.log("--读取日志-, ", directoryPath, res);
// console.log("--读取日志-, ", directoryPath, res);
const temp = res.map((element) => {
return JSON.parse(Base64.decode(element));
......
......@@ -65,25 +65,25 @@ export const USER_LiST = [
roleName: "超管", // 有用 -- 职位名称
unitName: "所属单位", // 所属单位
isAdmin: true, // 标识超管权限
loginTime: "", // 登录时间
LastSynchronizationTime: "", // 上次同步时间
},
{
userId: 2, // 有用
user: "test1", // 有用 谁创建,谁有权限编辑和删除
passWord: "JF123456", // 有用
roleName: "巡检员", // 有用
roleName: "巡检员1", // 有用
unitName: "所属单位", // 所属单位
isAdmin: true, // 标识超管权限
loginTime: "", // 登录时间
isAdmin: false, // 标识超管权限
LastSynchronizationTime: "", // 上次同步时间
},
{
userId: 3, // 有用
user: "test2", // 有用 谁创建,谁有权限编辑和删除
passWord: "JF123456", // 有用
roleName: "巡检员", // 有用
roleName: "巡检员2", // 有用
unitName: "所属单位", // 所属单位
isAdmin: true, // 标识超管权限
loginTime: "", // 登录时间
isAdmin: false, // 标识超管权限
LastSynchronizationTime: "", // 上次同步时间
},
];
......@@ -433,3 +433,30 @@ export function setSm2(data) {
}
}
// 获取用户数据
export function getUserList() {
return new Promise((resolve, reject) => {
try {
const value = uni.getStorageSync("user_data");
if (value) {
// this.personList = JSON.parse(value);
// console.log("---this.personList", this.personList);
resolve(eval(value));
} else {
uni.getStorage({
key: "user_data",
success: function (res) {
// this.personList =;
// console.log("---this.personList", this.personList);
resolve(eval(value));
},
});
}
} catch (e) {
reject(e)
console.log("getUserList--", e);
}
});
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论