const app = getApp(); const config = global.config; const imgUrl = config.imgDir+"blank_info_bg.png"; const scenes = { imgUrl, 401:{ message:"请先登陆哦", btnText:"点击登陆" } } Component({ properties: { status:{ type:Number, observer:function(res){ this.refresh() } }, config:Object, bg:{ type:String, value:"#00b0f0" } }, data: { }, methods: { refresh(){ let {config, status} = this.data; var {message="", btnText="", imgUrl=""} = scenes; if(scenes[status]) var {message=message, btnText=btnText, imgUrl=imgUrl} = scenes[status]; if(config[status]) var {message=message, btnText=btnText, imgUrl=imgUrl} = config[status]; this.setData({message, btnText, imgUrl}); }, onTapBody(){ console.log("tapbody") let {status} = this.data; this.triggerEvent("refresh",{target:"body", status}) }, onTapButton(){ console.log("tapButton") let {status } =this.data; this.triggerEvent("refresh",{target:"button", status}) } } })