1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package controllers
-
- type BaseViewController struct {
- BaseController
- }
-
- // 设置模板
- // 第一个参数模板,第二个参数为layout
- func (this *BaseViewController) SetTpl(template ...string) {
- var tplName string
- layout := ""
- switch {
- case len(template) == 1:
- tplName = template[0]
- case len(template) == 2:
- tplName = template[0]
- layout = template[1]
- default:
- tplName = "index.tpl"
- }
- this.Layout = layout
- this.TplName = tplName
- }
-
- // 重定向
- func (this *BaseViewController) Redirect302(url string) {
- this.Redirect(url, 302)
- this.StopRun()
- }
-
- // 错误页面
- func (this *BaseViewController) Abort404() {
- this.Abort("404")
- }
-
- // // 微信错误页面
- // func (this *BaseViewController) WxAbort404(title, desc string) {
- // this.Data["Title"] = title
- // this.Data["Desc"] = desc
- // this.SetTpl("view_wx/error/404.html")
- // }
-
- // type BaseAuthViewController struct {
- // BaseViewController
- // }
-
- // func (this *BaseAuthViewController) Prepare() {
- // this.BaseController.Prepare()
- // backUrl := utils.SetThisRequestURI(this.Ctx.Request.RequestURI)
- // backUrl = base64.URLEncoding.EncodeToString([]byte(backUrl))
- // if this.GetUserInfo() == nil {
- // if strings.HasPrefix(this.Ctx.Request.RequestURI, "/web/") {
- // this.Redirect302(beego.URLFor("WebLoginViewController.Login") + "?backUrl=" + backUrl)
- // } else {
- // this.Redirect302(beego.URLFor("WxLoginViewController.Login") + "?backUrl=" + backUrl)
- // }
- // }
- // }
|