1 Star 0 Fork 197

Dominic/uniapp-oa

forked from hjp1011/uniapp-oa 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
App.vue 3.21 KB
一键复制 编辑 原始数据 按行查看 历史
<script>
/* eslint-disable */
import Vue from 'vue';
import { configList, bindingEquipment } from '@/api/basic';
import { verifyAccessToken } from '@/api/login'
import { mapMutations } from 'vuex';
export default {
async onLaunch() {
await this.initData();
},
onHide() {},
methods: {
...mapMutations(['setNotifyNum']),
// 数据初始化
async initData() {
// 获取页面设置配置
const _this = this;
const token = uni.getStorageSync('accessToken');
// #ifdef APP-PLUS
// 5+ push 消息推送 ps:使用:H5+的方式监听,实现推送
plus.push.addEventListener(
'click',
function(msg) {
_this.navTo(JSON.parse(msg.content));
},
false
);
// 监听在线消息事件
plus.push.addEventListener(
'receive',
function(msg) {
_this.navTo(JSON.parse(msg.content));
},
false
);
// #endif
// 获取系统title高度
await this.initSystemInfo();
if (token) {
await this.handleVerifyAccessToken(token);
}
if (this.$mStore.getters.hasLogin) {
// 初始化Websocket
// await this.$mWebsocket.initWebsocket();
// 初始化数量
this.setNotifyNum(uni.getStorageSync('notifyNum') || 0);
// #ifdef APP-PLUS
const info = plus.push.getClientInfo();
await this.handleBindingEquipment(info.clientid, token);
// #endif
}
},
// 初始化系统信息
initSystemInfo() {
uni.getSystemInfo({
success(e) {
// #ifndef MP
Vue.prototype.StatusBar = e.statusBarHeight;
if (e.platform === 'android') {
Vue.prototype.CustomBar = e.statusBarHeight + 50;
} else {
Vue.prototype.CustomBar = e.statusBarHeight + 43;
}
// #endif
// #ifdef MP-WEIXIN
Vue.prototype.StatusBar = e.statusBarHeight;
const custom = wx.getMenuButtonBoundingClientRect();
Vue.prototype.Custom = custom;
Vue.prototype.CustomBar = custom.top - e.statusBarHeight;
// #endif
// #ifdef MP-ALIPAY
Vue.prototype.StatusBar = e.statusBarHeight;
Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
// #endif
}
});
},
// 设备绑定(app推送)
async handleBindingEquipment(id, token) {
const oauth_client = uni.getSystemInfoSync().platform;
await this.$http.post(bindingEquipment, {
token,
oauth_client,
oauth_client_user_id: id
});
},
async handleVerifyAccessToken (token) {
await this.$http.post(verifyAccessToken, { token }).then(r => {
if (!r.data.token) {
this.$mStore.commit('logout');
}
});
},
// 推送消息跳转
async navTo(item) {
let route;
const id = item.target_id;
const type = item.target_type;
switch (type) {
default:
route = '/pages/index/index';
break;
}
if (route) this.$mRouter.push({ route });
},
}
};
</script>
<style lang="scss">
// 导入colorUI
@import '/static/css/colorui/main.css';
@import '/static/css/colorui/icon.css';
@import '/static/css/colorui/animation.css';
// 导入阿里巴巴矢量图标库
/*#ifdef MP*/
@import './static/css/iconfont/iconfont.css';
/*#endif*/
/*#ifndef MP*/
@import url('https://at.alicdn.com/t/font_1823374_98c45zxwb3c.css');
/*#endif*/
@import './static/css/reset.scss';
@import './static/css/uni.scss';
</style>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/yiwanmu/uniapp-oa.git
git@gitee.com:yiwanmu/uniapp-oa.git
yiwanmu
uniapp-oa
uniapp-oa
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385