예제 #1
0
func (c *DqsjController) AdminHuoDong() {
	bool, _ := chackDqsjAccount(c.Ctx)
	if bool {

	} else {
		c.Redirect("/dqsj/adminlogin", 302)
		return
	}
	if c.Ctx.Input.IsGet() {
		beego.Debug("AdminHuoDong Get")
	}
	if c.Ctx.Input.IsPost() {
		beego.Debug("AdminHuoDong Post")
	}
	op := c.Input().Get("op")
	switch op {
	case "uphuodong":
		huodong := c.Input().Get("huodong")
		beego.Debug("huodong:", huodong)
		if len(huodong) == 0 {
			break
		}
		err := models.ModifyDqsjHomeHD(huodong)
		if err != nil {
			beego.Error(err)
		}
		// beego.Debug("is admin del " + id)
		c.Redirect("/dqsj/adminhuodong", 302)
		return
	case "del":
		id := c.Input().Get("id")
		if len(id) == 0 {
			break
		}
		id = c.Input().Get("id")
		err := models.DeleteDqsjHD(id)
		if err != nil {
			beego.Error(err)
		}
		// beego.Debug("is admin del " + id)
		c.Redirect("/dqsj/adminhuodong", 302)
		return
	case "state":
		id := c.Input().Get("id")
		if len(id) == 0 {
			break
		}
		id = c.Input().Get("id")
		err := models.UpdateDqsjHD(id, 1)
		if err != nil {
			beego.Error(err)
		}
		// beego.Debug("is admin state " + id)
		c.Redirect("/dqsj/adminhuodong", 302)
		return
	case "state1":
		id := c.Input().Get("id")
		if len(id) == 0 {
			break
		}
		id = c.Input().Get("id")
		err := models.UpdateDqsjHD(id, 0)
		if err != nil {
			beego.Error(err)
		}
		// beego.Debug("is admin state1" + id)
		c.Redirect("/dqsj/adminhuodong", 302)
		return
	case "additem":
		content := c.Input().Get("content")
		if len(content) == 0 {
			break
		}
		err := models.AddDqsjHD(content)
		if err != nil {
			beego.Error(err)
		}
		// beego.Debug("is admin state1" + id)
		c.Redirect("/dqsj/adminhuodong", 302)
		return
	}

	obj, err := models.GetOneDqsjHome()
	if err != nil {
		beego.Debug(err)
	}
	c.Data["HuoDong"] = ""
	if obj != nil {
		c.Data["HuoDong"] = obj.HuoDong
	}
	obj1, err := models.GetAllDqsjHD()
	if err != nil {
		beego.Debug(err)
	}
	c.Data["DqsjHuoDong"] = obj1
	c.TplName = "dqsjadminhuodong.html"
}
예제 #2
0
//主页
func (c *DqsjController) Home() {
	if c.Ctx.Input.IsGet() {
		beego.Debug("Home Get")
	}
	if c.Ctx.Input.IsPost() {
		beego.Debug("Home Post")
	}
	//微信分享
	token := getDqsjToken()
	if len(token) > 0 {
		beego.Debug("http_dqsj_token :", token)
	}
	appId := ""
	isdebug := "flase"
	iniconf, err := config.NewConfig("json", "conf/myconfig.json")
	if err != nil {
		beego.Debug(err)
	} else {
		appId = iniconf.String("qax580::appid")
		isdebug = iniconf.String("qax580::isdebug")
	}
	url := "http://www.baoguangguang.cn/dqsj/home"
	if isdebug == "true" {
		url = "http://localhost:8080/dqsj/home"
	}

	timestamp := time.Now().Unix()
	noncestr := getNonceStr(16, KC_RAND_KIND_ALL)
	ticket := getDqsjTicket(token)
	c.Data["AppId"] = appId
	c.Data["TimesTamp"] = timestamp
	c.Data["NonceStr"] = noncestr
	c.Data["Ticket"] = signatureWxJs(ticket, noncestr, timestamp, url)
	wxShareCon := models.WxShareCon{}
	wxShareCon.Title = "大签世界火盆烤肉欢迎您的到来!"
	wxShareCon.Link = url
	wxShareCon.ImgUrl = "http://182.92.167.29:8080/static/img/dqsjicon.jpg"
	c.Data["WxShareCon"] = wxShareCon
	// beego.Debug(wxShareCon)

	//广告栏
	c.Data["ImgUrlPath"] = getImageUrl()
	guanggaos, err := models.GetAllDqsjGuanggaosState1()
	if err != nil {
		beego.Error(err)
	}
	c.Data["Guanggaos"] = guanggaos

	obj, err := models.GetOneDqsjHome()
	if err != nil {
		beego.Debug(err)
	}
	c.Data["HuoDong"] = ""
	if obj != nil {
		c.Data["HuoDong"] = obj.HuoDong
		beego.Debug("HuoDong:", obj.HuoDong)
	}
	obj1, err := models.GetAllDqsjHDState1()
	if err != nil {
		beego.Debug(err)
	}
	if obj1 != nil {
		for i := 0; i < len(obj1); i++ {
			obj1[i].ShowId = int64(i + 1)
		}
	}
	c.Data["DqsjHuoDong"] = obj1

	config, err := models.GetConfigPan()
	bpan := false
	if config != nil {
		bpan = config.Bpan
	}
	c.Data["Bpan"] = bpan

	c.TplName = "dqsjhome.html"
}