1 Star 0 Fork 0

Qy-cloud / LittleBearRepastUniapp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
App.vue 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
chengwei 提交于 2020-06-02 19:05 . first
<script>
import Vue from 'vue';
import {mapGetters} from 'vuex';
export default {
data(){
return {
logincode:''
}
},
onLaunch: function() {
uni.getSystemInfo({
success: function(e) {
// #ifndef MP
Vue.prototype.StatusBar = e.statusBarHeight;
if (e.platform == 'android') {
Vue.prototype.CustomBar = e.statusBarHeight + 50;
} else {
Vue.prototype.CustomBar = e.statusBarHeight + 45;
};
// #endif
// #ifdef MP-WEIXIN
Vue.prototype.StatusBar = e.statusBarHeight;
let custom = wx.getMenuButtonBoundingClientRect();
Vue.prototype.Custom = custom;
Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
// #endif
// #ifdef MP-ALIPAY
Vue.prototype.StatusBar = e.statusBarHeight;
Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
// #endif
}
})
},
onShow: function() {
let that = this;
console.log('App Show',that);
// wx.login({
// success: function (res) {
// console.log('appvue',res);
// if (res.code) {
// var code = res.code;
// that.$store.commit('setLoingCode', res.code);
// } else { }
// }
// });
uni.connectSocket({
url: 'wss://www.example.com/socket',
data() {
return {
x: '',
y: ''
};
},
header: {
'content-type': 'application/json'
},
protocols: ['protocol1'],
method: 'GET'
});
uni.onSocketOpen(function (res) {
console.log('WebSocket连接已打开!');
});
uni.onSocketError(function (res) {
console.log('WebSocket连接打开失败,请检查!');
that.$store.dispatch('webSocket',res);
});
uni.sendSocketMessage({
data: ''
});
uni.onSocketMessage(function (res) {
console.log('收到服务器内容:' + res.data);
});
uni.onSocketClose(function (res) {
console.log('WebSocket 已关闭!');
});
},
onHide: function() {
console.log('App Hide')
},
methods:{
setWebSocket(){
this.$store.dispatch('webSocket','5555');
}
}
}
</script>
<style lang="scss">
@import "colorui/main.css";
@import "colorui/icon.css";
@import "colorui/animation.css";
@import "static/css/commom.scss";
</style>
1
https://gitee.com/qyrj/LittleBearRepastUniapp.git
git@gitee.com:qyrj/LittleBearRepastUniapp.git
qyrj
LittleBearRepastUniapp
LittleBearRepastUniapp
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891