You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
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 } ) ;
var url = this . url ;
axios . get ( url ) . then ( function ( response ) {
store . commit ( 'setUser' , response . data ) ;
} ) . catch ( function ( error ) {
//error
} )
// 从存储载入消息
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 ( ) {
// fix height
if ( height != $ ( '.main' ) . height ( ) ) {
height = $ ( '.main' ) . height ( ) ;
$ ( '.weui-tab__panel' ) . scrollTop ( height ) ;
}
} ,
destroyed : function ( ) {
clearInterval ( timer ) ;
}
} )
} ) ;
} ) ,
onMessage : function ( event , model , to , from ) {
if ( isLoadedMSG ) {
// do something
}
// loadMessage()
}
}
}