feat: app更新移到login_.vue,引入下载进度

This commit is contained in:
caoqianming 2023-04-12 08:36:12 +08:00
parent 1a3e4b7d1a
commit ca87016f7d
2 changed files with 81 additions and 137 deletions

162
App.vue
View File

@ -1,67 +1,67 @@
<script>
export default {
// globalDatauView
globalData: {
appid: 'wxf7d6140f507466be'
},
getUserRange() {
let that = this;
that.$u.api.deptList({
page: 0,
type__in: 'rparty,dept',
query: '{id, name, parent, type}'
}).then(res => {
let list1 = res;
let list2 = [];
let reqList = [];
list1.forEach(function(item) {
reqList.push(that.$u.api.userList({
page: 0,
belong_dept: item.id,
is_active: true,
query: '{id, name, belong_dept}'
}))
})
Promise.all(reqList).then(res => {
for (let i = 0; i < res.length; i++) {
list1[i].children = res[i]
}
list1.forEach(item=>{
if(item.type == 'dept'){
list2.push({ ...item })
}
})
that.$u.vuex('vuex_userRange', that.parseData(list1))
that.$u.vuex('vuex_userRange2', that.parseData(list2))
})
})
},
parseData(data) {
// * parent
const obj = {};
data.forEach((item) => {
obj[item.id] = item;
});
const parentList = [];
data.forEach((item) => {
const parent = obj[item.parent];
if (parent) {
// *
parent.children = parent.children || [];
parent.children.unshift(item);
} else {
parentList.push(item);
}
});
return parentList;
},
// getUserRange() {
// let that = this;
// that.$u.api.deptList({
// page: 0,
// type__in: 'rparty,dept',
// query: '{id, name, parent, type}'
// }).then(res => {
// let list1 = res;
// let list2 = [];
// let reqList = [];
// list1.forEach(function(item) {
// reqList.push(that.$u.api.userList({
// page: 0,
// belong_dept: item.id,
// is_active: true,
// query: '{id, name, belong_dept}'
// }))
// })
// Promise.all(reqList).then(res => {
// for (let i = 0; i < res.length; i++) {
// list1[i].children = res[i]
// }
// list1.forEach(item=>{
// if(item.type == 'dept'){
// list2.push({ ...item })
// }
// })
// that.$u.vuex('vuex_userRange', that.parseData(list1))
// that.$u.vuex('vuex_userRange2', that.parseData(list2))
// })
// })
// },
// parseData(data) {
// // * parent
// const obj = {};
// data.forEach((item) => {
// obj[item.id] = item;
// });
// const parentList = [];
// data.forEach((item) => {
// const parent = obj[item.parent];
// if (parent) {
// // *
// parent.children = parent.children || [];
// parent.children.unshift(item);
// } else {
// parentList.push(item);
// }
// });
// return parentList;
// },
onLaunch() {
// #ifdef APP-PLUS
let client = plus.push.getClientInfo();
let qyjyClientId = client.clientid;
uni.setStorageSync('qyjyClientId', qyjyClientId)
console.log("设备唯一标识:",qyjyClientId)
// #endif
var that = this
@ -119,36 +119,36 @@
}
});
// #endif
uni.getSystemInfo({
success(res) {
console.log(res)
that.$u.vuex('vuex_version', res.appVersion)
// #ifdef APP-PLUS
if (res.platform == 'android') {
that.$u.api.apkCheck().then(res1 => {
if (res.appVersion < res1.version) {
uni.showModal({
title: "版本更新",
content: '有新的版本发布, 请下载新版本',
confirmText: '立即更新',
showCancel: false,
success: function(res2) {
if (res2.confirm) {
if(res1.file.indexOf("http") == 0){
plus.runtime.openURL(res1.file)
}else{
plus.runtime.openURL(that.vuex_host + res1.file)
}
// uni.getSystemInfo({
// success(res) {
// console.log(res)
// that.$u.vuex('vuex_version', res.appVersion)
// // #ifdef APP-PLUS
// if (res.platform == 'android') {
// that.$u.api.apkCheck().then(res1 => {
// if (res.appVersion < res1.version) {
// uni.showModal({
// title: "",
// content: ', ',
// confirmText: '',
// showCancel: false,
// success: function(res2) {
// if (res2.confirm) {
// if(res1.file.indexOf("http") == 0){
// plus.runtime.openURL(res1.file)
// }else{
// plus.runtime.openURL(that.vuex_host + res1.file)
// }
}
}
});
}
})
}
// #endif
}
})
// }
// }
// });
// }
// })
// }
// // #endif
// }
// })
},
}
</script>

View File

@ -434,64 +434,10 @@
// })
}).catch(e => {})
// #endif
that.getUserRange();
}).catch(e => {
console.log(e)
})
},
getUserRange() {
let that = this;
that.$u.api.deptList({
page: 0,
type__in: 'rparty,dept',
query: '{id, name, parent, type}'
}).then(res => {
let list1 = res;
let list2 = [];
let reqList = [];
list1.forEach(function(item) {
reqList.push(that.$u.api.userList({
page: 0,
belong_dept: item.id,
is_active: true,
query: '{id, name, belong_dept}'
}))
})
Promise.all(reqList).then(res => {
for (let i = 0; i < res.length; i++) {
list1[i].children = res[i]
}
list1.forEach(item => {
if (item.type == 'dept') {
list2.push({
...item
})
}
})
that.$u.vuex('vuex_userRange', that.parseData(list1))
that.$u.vuex('vuex_userRange2', that.parseData(list2))
})
})
},
parseData(data) {
// * parent
const obj = {};
data.forEach((item) => {
obj[item.id] = item;
});
const parentList = [];
data.forEach((item) => {
const parent = obj[item.parent];
if (parent) {
// *
parent.children = parent.children || [];
parent.children.unshift(item);
} else {
parentList.push(item);
}
});
return parentList;
},
formSubmit2(e) {
var that = this;
const obj = e.target.value;
@ -499,7 +445,6 @@
that.$u.api.codeLogin(obj).then(res => {
that.$u.vuex('vuex_token', res.access)
that.$u.vuex('vuex_refresh', res.refresh)
that.getUserRange();
that.$u.api.getUserInfo().then(res => {
if (res.avatar) {
res.avatar = this.vuex_host + res.avatar
@ -619,7 +564,6 @@
}
}
})
that.getUserRange()
})
}
}