|
|
function pages_home() {
|
|
|
return {
|
|
|
component: Vue.component(arguments.callee.toString(), function (resolve, reject) {
|
|
|
// 异步加载本地消息
|
|
|
var timer;
|
|
|
var height;
|
|
|
axios.get("/pages/home.html").then(function (response) {
|
|
|
resolve({
|
|
|
template: response.data,
|
|
|
data() {
|
|
|
return {
|
|
|
//messages: store.state.messages, // 此处为数据库调用为异步处理,有可能不生效,直接在模板中调用state
|
|
|
url: '/UserCenter/api/v1/user/getUserInfo'
|
|
|
};
|
|
|
},
|
|
|
mounted: function () {
|
|
|
weui.tab('#tab', { defaultIndex: 1 });
|
|
|
/*
|
|
|
timer = setInterval(function(){
|
|
|
|
|
|
if(height != $('.main').height()){
|
|
|
height = $('.main').height();
|
|
|
$('.weui-tab__panel').scrollTop(height);
|
|
|
}
|
|
|
|
|
|
console.log('setInterval>>>>>>>>');
|
|
|
},1000);
|
|
|
*/
|
|
|
var url = this.url;
|
|
|
axios.get(url).then(function (response) {
|
|
|
store.commit('setUser', response.data);
|
|
|
}).catch(function (error) {
|
|
|
//error
|
|
|
})
|
|
|
console.log('载入消息>>>>>>>>');
|
|
|
// 从存储载入消息
|
|
|
if(!isLoadedMSG) {
|
|
|
loadMessage(function(msgs){
|
|
|
store.commit('setMessages', msgs);
|
|
|
},10)
|
|
|
isLoadedMSG = true;
|
|
|
}
|
|
|
//
|
|
|
},
|
|
|
methods: {
|
|
|
// 推出登录
|
|
|
logout: function () {
|
|
|
store.commit('logout');
|
|
|
router.push('/login');
|
|
|
},
|
|
|
closeWindow: function () {
|
|
|
if(window.api){
|
|
|
window.api.execScript(
|
|
|
{
|
|
|
name: window.api.winName,
|
|
|
script: "api.closeWin()"
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
computed: {
|
|
|
/*
|
|
|
messages: function () {
|
|
|
console.log('computed messages >>>>>>>>');
|
|
|
return store.state.messages;
|
|
|
},*/
|
|
|
user: function () {
|
|
|
//
|
|
|
console.log('computed user >>>>>>>>');
|
|
|
return store.state.user;
|
|
|
}
|
|
|
},
|
|
|
updated: function () {
|
|
|
//
|
|
|
if(height != $('.main').height()){
|
|
|
height = $('.main').height();
|
|
|
$('.weui-tab__panel').scrollTop(height);
|
|
|
}
|
|
|
},
|
|
|
destroyed:function(){
|
|
|
clearInterval(timer);
|
|
|
}
|
|
|
})
|
|
|
});
|
|
|
}),
|
|
|
onMessage: function (event, model, to, from) {
|
|
|
|
|
|
if(isLoadedMSG ){
|
|
|
|
|
|
}
|
|
|
//loadMessage()
|
|
|
}
|
|
|
}
|
|
|
} |