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

fix(功能走查): 上次登陆时间的存储时间节点。存在疑问

上级 4b9c8a9d
...@@ -66,7 +66,7 @@ export default { ...@@ -66,7 +66,7 @@ export default {
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.last_time); // uni.setStorageSync("last_time", this.$store.state.last_time);
}, },
onUnload() {}, onUnload() {},
......
...@@ -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">上次登录时间:{{ userInfo.last_time || "--" }}</view>
<image <image
class="bg-img" class="bg-img"
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
src="@/static/img/add-img/home1.png" src="@/static/img/add-img/home1.png"
></image> ></image>
</view> </view>
<view class="card-item"> <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
...@@ -86,25 +86,7 @@ export default { ...@@ -86,25 +86,7 @@ export default {
}, },
data() { data() {
return { return {
activeTabIndex: 0,
tabList: [
{
defaultIcon: "iconfont icon-yingyongyewuguanli1",
isActive: true,
text: "首页",
},
{
defaultIcon: "iconfont icon-Inspection",
isActive: false,
text: "巡检管理",
},
{
defaultIcon: "iconfont icon-a-ActivityConfiguration",
isActive: false,
text: "同步管理",
},
],
isDialog: false, // isDialog: false, //
list: [], // 展示数据 list: [], // 展示数据
all_data: [], // 所有数据 all_data: [], // 所有数据
...@@ -114,33 +96,14 @@ export default { ...@@ -114,33 +96,14 @@ export default {
countNum: 0, // 统计查询总数 countNum: 0, // 统计查询总数
syncCount: 0, // 待同步条数 syncCount: 0, // 待同步条数
lastTime: "", // 上次登陆时间 // lastTime: "", // 上次登陆时间
}; };
}, },
created() { created() {
this.lastTime = uni.getStorageSync("last_time") || ""; // this.lastTime = uni.getStorageSync("last_time") || "";
}, },
mounted() { mounted() {
uni.showLoading(); this.init();
getAllInspections()
.then((res) => {
this.all_data = res;
this.init();
uni.hideLoading();
})
.catch((error) => {
if (0 == error.code) {
uni.showToast({
title: error.msg,
icon: "none",
duration: 1000,
});
}
this.all_data = [];
uni.hideLoading();
});
}, },
computed: { computed: {
...@@ -149,6 +112,32 @@ export default { ...@@ -149,6 +112,32 @@ export default {
}, },
}, },
methods: { methods: {
init() {
uni.showLoading();
getAllInspections()
.then((res) => {
this.all_data = res;
this.getList();
uni.hideLoading();
})
.catch((error) => {
if (0 == error.code) {
uni.showToast({
title: error.msg,
icon: "none",
duration: 1000,
});
}
this.all_data = [];
uni.hideLoading();
});
},
toSyncPage() {
this.$emit("changeTab", {}, 2)
},
// 待同步数据 // 待同步数据
initSyncCount() { initSyncCount() {
this.syncCount = (this.all_data || []).filter( this.syncCount = (this.all_data || []).filter(
...@@ -157,7 +146,7 @@ export default { ...@@ -157,7 +146,7 @@ export default {
}, },
// 初始化 // 初始化
init() { getList() {
const all_data = this.all_data || []; const all_data = this.all_data || [];
const tempAllData = {}; const tempAllData = {};
...@@ -223,16 +212,12 @@ export default { ...@@ -223,16 +212,12 @@ export default {
}); });
}, },
change(e) { change(e) {
console.log("----", e);
this.searchForm = e; this.searchForm = e;
this.init(); this.init();
}, },
tabClick(item, index) {
console.log("----");
this.activeTabIndex = index;
},
toIndex() { toIndex() {
uni.navigateTo({ uni.navigateTo({
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<!-- 内容区 --> <!-- 内容区 -->
<view class="right-container"> <view class="right-container">
<!-- 首页 --> <!-- 首页 -->
<Content v-if="activeTabIndex == 0" /> <Content v-if="activeTabIndex == 0" @changeTab="tabClick" />
<!-- 巡检管理 --> <!-- 巡检管理 -->
<InspectionManagement v-if="activeTabIndex == 1" /> <InspectionManagement v-if="activeTabIndex == 1" />
...@@ -127,7 +127,7 @@ export default { ...@@ -127,7 +127,7 @@ export default {
success() { success() {
_this.$store.commit("SET_USER", {}); _this.$store.commit("SET_USER", {});
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.last_time); // uni.setStorageSync("last_time", this.$store.state.last_time);
uni.clearStorage(); //测试将所有缓存清除 uni.clearStorage(); //测试将所有缓存清除
}, },
......
...@@ -142,20 +142,8 @@ export default { ...@@ -142,20 +142,8 @@ export default {
this.$refs.form this.$refs.form
.validate() .validate()
.then((res) => { .then((res) => {
// console.log(this.formData.oldPd,this.user.pd)
// 输入密码与该账号密码一致 // 输入密码与该账号密码一致
if (this.formData.oldPd == this.user.passWord) { if (this.formData.oldPd == this.user.passWord) {
// this.user.passWord = this.formData.newPd;
// let key = null;
// this.personList.some((item, index) => {
// if (item.id == this.user.id) {
// key = index;
// }
// });
// console.log("---- this.user", this.user)
// 将数组中与当前登录账号ID相同项替换
// this.personList.splice(key, 1, this.user);
const id = this.user.id; const id = this.user.id;
const tempPersonList = this.personList.map((item) => { const tempPersonList = this.personList.map((item) => {
if (item.id == id) { if (item.id == id) {
...@@ -164,68 +152,6 @@ export default { ...@@ -164,68 +152,6 @@ export default {
return item; return item;
}); });
// let timeStr = getDateTime.dateTimeStr("y-m-d h:i");
// let operData = {
// name: this.$store.state.now_user.name,
// level: "秘密",
// user: this.$store.state.now_user.user,
// module: "其他",
// detail: "无",
// type: "修改密码",
// time: timeStr,
// };
// this.$store.state.oper_record.unshift(operData);
// 重新存储本地用户信息
// let _this = this;
// plus.io.resolveLocalFileSystemURL(
// "/storage/emulated/0/Android/data/asmzx/pd/", //指定的目录
// function(entry) {
// // 创建或打开文件, fs.root是根目录操作对象,直接fs表示当前操作对象
// entry.getFile(
// 'u.txt', {
// create: true // 文件不存在则创建
// },
// fileEntry => {
// // 文件在手机中的路径
// console.log(fileEntry.fullPath)
// fileEntry.createWriter(writer => {
// let data = _this.$Base64.encode(JSON.stringify(_this
// .personList))
// console.log(data, 123);
// // 写入文件成功完成的回调函数
// writer.onwrite = e => {
// // console.log('写入成功');
// };
// // 向文件中写入数据
// writer.write(
// JSON.stringify(data)
// );
// });
// },
// e => {
// console.log('getFile failed: ' + e.message);
// }
// );
// },
// e => {
// console.log(e.message);
// },
// function(err) {
// console.log("访问指定目录失败:" + err.message);
// });
// uni.setStorageSync('user_data', this.personList)
// uni.showToast({
// title: '恭喜您,密码更新成功!',
// icon: 'none',
// duration: 2000
// })
// this.logOut()
const temp = JSON.stringify(tempPersonList); const temp = JSON.stringify(tempPersonList);
const fileContent = JSON.stringify(Base64.encode(temp)); const fileContent = JSON.stringify(Base64.encode(temp));
...@@ -242,15 +168,14 @@ export default { ...@@ -242,15 +168,14 @@ export default {
duration: 2000, duration: 2000,
}); });
// 生成日志
// 生成日志 const logContent = getLogContent(LOG_TYPE_ENUM.updatePassword);
const logContent = getLogContent(LOG_TYPE_ENUM.updatePassword); const log_list = this.$store.state.log_list;
const log_list = this.$store.state.log_list; 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).then((res) => {
addLog(log_list).then((res) => { console.log("日志文件写入成功");
console.log("日志文件写入成功"); });
});
this.logOut(); this.logOut();
}); });
...@@ -277,12 +202,12 @@ export default { ...@@ -277,12 +202,12 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
background-image: linear-gradient( background-image: linear-gradient(
90deg, 90deg,
#e9f7fe 0%, #e9f7fe 0%,
#dceffe 40%, #dceffe 40%,
#d5ebfd 66%, #d5ebfd 66%,
#c9e8fe 100% #c9e8fe 100%
); );
.edit-main { .edit-main {
margin-top: -44px; margin-top: -44px;
......
...@@ -32,6 +32,8 @@ import { ...@@ -32,6 +32,8 @@ import {
createFileWithPlusIO, createFileWithPlusIO,
TEST, TEST,
TEST_2X, TEST_2X,
USER_FILE_NAME,
} from "@/utils/systemCofig"; } from "@/utils/systemCofig";
import { import {
...@@ -42,6 +44,8 @@ import { ...@@ -42,6 +44,8 @@ import {
readLogData, readLogData,
} from "@/utils/IoReadingAndWriting.js"; } from "@/utils/IoReadingAndWriting.js";
import moment from "moment"; import moment from "moment";
import { Base64 } from "js-base64";
export default { export default {
components: { components: {
...@@ -50,11 +54,11 @@ export default { ...@@ -50,11 +54,11 @@ export default {
data() { data() {
return { return {
person: { person: {
user: "bjqxj", // user: "bjqxj",
pd: "JF85250920", // pd: "JF85250920",
// user: "hzsgjy", // 超管账号 user: "hzsgjy", // 超管账号
// pd: "JFXJ85250920", pd: "JFXJ85250920",
}, },
backButtonPress: 0, backButtonPress: 0,
personList: [], personList: [],
...@@ -72,7 +76,7 @@ export default { ...@@ -72,7 +76,7 @@ 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.last_time); // uni.setStorageSync("last_time", this.$store.state.last_time);
plus.runtime.quit(); plus.runtime.quit();
} else { } else {
plus.nativeUI.toast("再划一次退出应用"); plus.nativeUI.toast("再划一次退出应用");
...@@ -142,10 +146,18 @@ export default { ...@@ -142,10 +146,18 @@ export default {
this.person.pd == this.personList[key].passWord this.person.pd == this.personList[key].passWord
) { ) {
const last_time = moment().format("yyyy-MM-DD HH:mm:ss"); const last_time = moment().format("yyyy-MM-DD HH:mm:ss");
this.$store.commit("SET_USER", this.personList[key]); this.personList[key].last_time = last_time;
uni.setStorageSync("now_user", this.personList[key]);
this.$store.commit("SET_TIME", last_time); const userInfo = this.personList[key];
uni.setStorageSync("last_time", last_time); this.$store.commit("SET_USER", userInfo);
uni.setStorageSync("now_user", userInfo);
const fileContent = JSON.stringify(Base64.encode(this.personList));
createFileWithPlusIO(
SYNCHRONIZE_DATA_PAD,
USER_FILE_NAME,
fileContent
);
uni.navigateTo({ uni.navigateTo({
url: "/pages/home/home", url: "/pages/home/home",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论