import autologBehavior from "../../behaviors/autolog-behavior" ; import { navigateTo } from "../../utils/navigate" ; const PAGE_NAME = "index" ; const app = getApp ( ) ; Component ( { behaviors : [ autologBehavior ] , data : { PAGE_NAME , userInfo : { } , canIUseGetUserInfo : wx . canIUse ( "button.open-type.getUserInfo" ) } , methods : { onLoad ( ) { this . checkUserInfo ( ) ; } , checkUserInfo ( ) { if ( app . globalData . userInfo ) { this . setData ( { userInfo : app . globalData . userInfo , hasUserInfo : true } ) ; } else if ( this . data . canIUseGetUserInfo ) { app . userInfoReadyCallback = ( res ) => { this . setData ( { userInfo : res , hasUserInfo : true } ) ; } ; } else { wx . getUserInfo ( { success : res => { app . globalData . userInfo = res . userInfo ; this . setData ( { userInfo : res . userInfo , hasUserInfo : true } ) ; } } ) ; } } , getUserInfo ( e ) { app . globalData . userInfo = e . detail . userInfo ; this . setData ( { userInfo : e . detail . userInfo , hasUserInfo : true } ) ; } , gotoOtherPage ( e ) { const { page } = e . currentTarget . dataset ; navigateTo ( page ) ; } , gotoSuccess ( ) { navigateTo ( "/pages/result/result" , { urlParams : { type : "success" , title : "操作成功" , info : "成功就是这么简单" } } ) ; } , gotoFail ( ) { navigateTo ( "/pages/result/result" , { urlParams : { type : "warn" , title : "操作出错" , info : "人生也常常不如意" } } ) ; } } } ) ;