async onLoad(options) {
let that = this
uni.hideTabBar(); //隐藏原生tabbar
// uni.getNetworkType({
// success: function(res) {
// console.log("network:", res.networkType);
// }
// });
// uni.onNetworkStatusChange(this.onNetworkStatusChange)
// #ifdef MP-WEIXIN
// wx.onBackgroundFetchData(() => {
// })
wx.getBackgroundFetchData({
fetchType: 'pre',
success(res) {
// console.log("fetchedData:",res) // 缓存数据
that.record = JSON.parse(res.fetchedData).data
},
fail(err){
console.log("err:",err)
}
})
// #endif
},
onReachBottom() { //滚动到底翻页
// this.$refs.udb.loadMore()
},
onReady() {
// #ifdef MP-WEIXIN
const windowInfo = wx.getWindowInfo()
this.windowWidth = windowInfo.screenWidth
// console.log("windowWidth:", windowInfo)
// #endif
// #ifndef MP-WEIXIN
uni.getSystemInfo({
success: (res) => {
let cha = res.screenWidth - 1320
// #ifdef H5
this.windowWidth = res.screenWidth - cha;
// #endif
// #ifndef H5
this.windowWidth = res.screenWidth
// #endif
},
});
// #endif
},
async onShow() {
let that = this
// this.tabBerLists = uni.getStorageSync('tabBarList') // 自定义的tabbar赋值
// console.log("hasmore", that.hasMore)
let token = uni.getStorageSync('uni_id_token')
// console.log("Token", token)
if (token) {
let resuser = await db.collection("uni-id-users").where({
token: token
})
.field({
username: true,
userType: true,
realName: true,
wx_openid: true,
identitycard: true
})
.get()
// console.log("resuser", resuser)
if (resuser.data.length == 1) {
let userdata = resuser.data[0]
getApp().globalData.userName = userdata.username
getApp().globalData.realName = userdata.realName
getApp().globalData.userType = userdata.userType
getApp().globalData.adminType = userdata.userType
getApp().globalData.openid = userdata.wx_openid ? userdata.wx_openid.mp : ''
//未读消息
// console.log("userName:", getApp().globalData.userName)
var count = await db.collection('Messages')
.where({
messageSend: getApp().globalData.userName,
isRead: false
}).count()
// console.log("count:", count)
getApp().globalData.unreadMessages = count.total
//通过manager更新
let resmanager = await db.collection("Managers").where({
userName: userdata.username
})
.get()
if (resmanager.data.length > 0) {
resmanager = resmanager.data[0]
getApp().globalData.adminType = resmanager.adminType
getApp().globalData.userDept = resmanager.department
getApp().globalData.adminLevel = resmanager.adminType
getApp().globalData.scopeCompany = resmanager.scopeCompany
getApp().globalData.division = resmanager.division
getApp().globalData.position = resmanager.position
}
if (resuser.data[0].userType == '供应商') {
getApp().globalData.userDept = '供应商'
}
if (resuser.data[0].userType == '管理员') {
that.$store.commit('setRoleId', 1)
getApp().globalData.setRoleId = 1
that.tabBerLists = uni.getStorageSync('tabBarList') // 自定义的tabbar赋值
if (that.tabBerLists.length == 4) {
that.currenttab = 3
that.tabBerLists[2].mark = getApp().globalData.unreadMessages
}
} else {
that.$store.commit('setRoleId', 0)
getApp().globalData.setRoleId = 0
that.tabBerLists = uni.getStorageSync('tabBarList')
if (that.tabBerLists.length == 4) {
that.currenttab = 3
that.tabBerLists[1].mark = getApp().globalData.unreadMessages
}
}
} else if (resuser.data.length == 0) {
uni.navigateTo({
url: "/pagessub/ucenter/pages/login/login-withpwd"
})
}
} else {
console.log("user has no token")
uni.showToast({
title: "未登录",
icon: 'none'
})
that.$store.commit('setRoleId', 0)
getApp().globalData.setRoleId = 0
that.tabBerLists = uni.getStorageSync('tabBarList')
if (that.tabBerLists.length == 4) {
that.currenttab = 3
}
}
// #ifndef MP-WEIXIN
let resp = await db.collection('Projects')
.where({
isShow: true
})
.orderBy('flag', 'desc')
.get()
if (resp.data) {
that.record = resp.data
} else {
uni.showToast({
title: "没有数据"
})
}
// #endif
// this.$refs.udb.loadData() //udb为unicloud-db组件的ref属性值
},
DCloud_UNI_HT
已经复现,在排查了,修复后我会告知
2025-01-15 11:15