Exemple #1
0
//判断是否登陆
func CheckAdminLogin(c *beego.Controller, t int64) {
	id, _ := c.GetSession("adminid").(int)
	username, _ := c.GetSession("adminname").(string)
	adminrole, _ := c.GetSession("adminrole").(int)
	if id == 0 || username == "" || adminrole == 0 {
		switch t {
		case 0:
			c.Redirect("/admin/login", 301)
		case 1:
			//返回JSON
			json := &models.TipJSON{}
			json.Status = models.TipError
			json.Message = "请先登录,再执行此操作"
			json.ReturnUrl = "/admin/login"

			c.Data["json"] = json
			c.ServeJson()
			c.StopRun()
		}

	}
	c.Data["AdminName"] = username
	c.Data["AdminId"] = id
	c.Layout = "admin/layout.tpl"
}
Exemple #2
0
//carga las tpl-no me esta funcionando bn
func LoadTpl(this *beego.Controller, s string, b bool) {
	this.Layout = "basic-layout.tpl"
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["Header"] = "header.tpl"
	this.LayoutSections["Footer"] = "footer.tpl"
	this.Data["IsArtProv"] = b
	this.Data["place"] = "Busqueda por Id"
	this.Data["nombotton"] = "Buscar Id Prov"
	this.TplNames = s
}
Exemple #3
0
//提示错误页面
func EchoErrorPage(c *beego.Controller, message string, url string) {
	isGoback := false
	if url == "" {
		isGoback = true
	}
	c.Data["Message"] = message
	c.Data["Url"] = url
	c.Data["IsGoback"] = isGoback
	c.Layout = "admin/error.tpl"
	c.StopRun()
}
Exemple #4
0
//信息提示,如果异步,返回json、如果同步,则页面提示并返回
func EchoTip(c *beego.Controller, json *models.TipJSON) {
	if c.IsAjax() {
		//异步提交
		c.Data["json"] = json
		c.ServeJson()
		c.StopRun()
	} else {
		tpl := "admin/error.tpl"
		if json.Status == models.TipSuccess {
			tpl = "admin/success.tpl"
		}
		c.Data["Tip"] = json
		c.Layout = tpl
		//此处不能用 c.StopRun() 返回,否则会空白页面!
		//c.StopRun()
		return
	}
}