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

fix(pad): bug修改

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