示例#1
0
func (c *DqsjController) GuangGao() {
	if c.Ctx.Input.IsGet() {
		beego.Debug("GuangGao Get")
	}
	if c.Ctx.Input.IsPost() {
		beego.Debug("GuangGao 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/guanggao"
	if isdebug == "true" {
		url = "http://localhost:8080/dqsj/guanggao"
	}
	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)

	op := c.Input().Get("op")
	switch op {
	case "con":
		id := c.Input().Get("id")
		if len(id) == 0 {
			break
		}
		guangao, err := models.GetOneDqsjGuanggao(id)
		if err != nil {
			beego.Error(err)
		}
		c.Data["Guanggao"] = guangao
		beego.Debug("guangao :", guangao)
		c.TplName = "dqsjguanggao.html"
		return
	}

	c.TplName = "dqsjguanggao.html"
}
示例#2
0
func (c *DqsjController) Gua() {
	if c.Ctx.Input.IsGet() {
		beego.Debug("Gua Get")
	}
	if c.Ctx.Input.IsPost() {
		beego.Debug("Gua 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/gua"
	if isdebug == "true" {
		url = "http://localhost:8080/dqsj/gua"
	}
	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

	guaitem, err := models.GetAllGuaItemState1()
	if err != nil {
		beego.Error(err)
	}
	var guas []models.DqsjGuaItem
	for i := 0; i < len(guaitem); i++ {
		for j := 0; j < int(guaitem[i].Probability); j++ {
			guas = append(guas, guaitem[i])
		}
	}
	rand.Seed(time.Now().UnixNano())
	ri := rand.Intn(len(guas))
	rguaitem := guas[ri]
	beego.Debug("rguaitem :", rguaitem)
	beego.Debug("guas len", len(guas), "ri :", ri)
	c.Data["GuaItem"] = rguaitem
	c.TplName = "dqsjgua1.html"
}
示例#3
0
/**
投票详情
*/
func (c *PollController) PollHomeCon() {
	if c.Ctx.Input.IsGet() {
		beego.Debug("PollHome Get")
	}
	if c.Ctx.Input.IsPost() {
		beego.Debug("PollHome Post")
	}
	openid := getPollCookie(c)
	pollsid := c.Input().Get("pollsid")
	pollid := c.Input().Get("pollid")
	beego.Debug("pollsid:", pollsid)
	beego.Debug("pollid:", pollid)
	c.Data["PollsId"] = pollsid
	c.Data["PollId"] = pollid
	op := c.Input().Get("op")
	beego.Debug("op:", op)
	switch op {
	case "vote":
		err := models.AddVote(openid, pollsid, pollid)
		if err != nil {
			beego.Debug(err)
		}
		url := fmt.Sprintf("/poll/pollhomecon?pollsid=%s&pollid=%s", pollsid, pollid)
		beego.Debug("url:", url)
		c.Redirect(url, 302)
		return
	}

	obj, err := models.GetOnePoll(pollsid, pollid)
	if err != nil {
		beego.Error(err)
	}
	num, err := models.GetVoteNum1(pollsid, pollid)
	if err != nil {
		beego.Error(err)
	}
	polls, err := models.GetOnePolls(pollsid)
	if err != nil {
		beego.Error(err)
	}

	wxShareCon := models.WxShareCon{}
	wxShareCon.Title = obj.Title
	wxShareCon.Link = fmt.Sprintf("http://www.baoguangguang.cn/poll/pollwx?id=%s", pollsid)
	wxShareCon.ImgUrl = fmt.Sprintf("http://182.92.167.29:8080/imagehosting/%s", obj.Image)
	shaer_url := fmt.Sprintf("http://www.baoguangguang.cn/poll/pollhomecon?pollsid=%s&pollid=%s", pollsid, pollid)
	getPollShare(polls.Appid, polls.Secret, shaer_url, wxShareCon, c)
	beego.Debug("VoteNum", num)
	obj.VoteNum = num
	c.Data["Time"] = polls.EndTimeLong
	c.Data["Polls"] = polls
	c.Data["Obj"] = obj
	c.TplName = "pollhomecon.html"
}
示例#4
0
//幸运盘
func (c *DqsjController) Pan() {
	if c.Ctx.Input.IsGet() {
		beego.Debug("Pan Get")
	}
	if c.Ctx.Input.IsPost() {
		beego.Debug("Pan 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/pan"
	if isdebug == "true" {
		url = "http://localhost:8080/dqsj/pan"
	}
	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)
	panitem, err := models.GetAllPanItemState1()
	if err != nil {
		beego.Error(err)
	}
	c.Data["PanItem"] = panitem
	beego.Debug("panitem :", panitem)
	c.TplName = "dqsjpan.html"
}
示例#5
0
//菜单
func (c *DqsjController) Cai() {
	if c.Ctx.Input.IsGet() {
		beego.Debug("Cai Get")
	}
	if c.Ctx.Input.IsPost() {
		beego.Debug("Cai 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/cai"
	if isdebug == "true" {
		url = "http://localhost:8080/dqsj/cai"
	}
	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)

	objs, err := models.GetAllCaiGroupState1()
	if err != nil {
		beego.Error(err)
	}
	var showCaiGroup []models.DqsjShowCaiGroup
	for i := 0; i < len(objs); i++ {
		objitem, err := models.GetAllCaiItemState1(objs[i].Id)
		if err != nil {
			beego.Error(err)
		} else {
			obgshow := models.DqsjShowCaiGroup{Id: objs[i].Id, Name: objs[i].Name,
				OrderId: objs[i].OrderId, State: objs[i].State, Time: objs[i].Time, CaiItems: objitem}
			showCaiGroup = append(showCaiGroup, obgshow)
		}

	}

	c.Data["ShowCaiGroup"] = showCaiGroup
	tips, err := models.GetAllCaiTipsState1()
	if err != nil {
		beego.Error(err)
	}
	c.Data["CaiTips"] = tips

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

	c.TplName = "dqsjcai.html"
}
示例#6
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"
}
示例#7
0
/**
投票主页
*/
func (c *PollController) PollHome() {
	if c.Ctx.Input.IsGet() {
		beego.Debug("PollHome Get")
	}
	if c.Ctx.Input.IsPost() {
		beego.Debug("PollHome Post")
	}
	pollsid := c.Input().Get("pollsid")
	beego.Debug("pollsid :", pollsid)
	state := c.Input().Get("state")
	code := c.Input().Get("code")
	beego.Debug("/poll/pollhem state :", state)
	beego.Debug("/poll/pollhem code :", code)
	share_url := "http://www.baoguangguang.cn/poll/pollhome"
	if len(code) != 0 && len(state) != 0 {
		pollsid = state
		_, err := getPollWxOpenId(c, pollsid, code)
		if err != nil {
			beego.Error(err)
		}
		share_url = fmt.Sprintf("http://www.baoguangguang.cn/poll/pollhome?code=%s&state=%s", code, state)
	}
	beego.Debug("/poll/pollhem pollsid :", pollsid)
	openid := getPollCookie(c)
	//测试openid
	isdebug := "false"
	iniconf, err := config.NewConfig("json", "conf/myconfig.json")
	if err != nil {
		beego.Debug(err)
	} else {
		isdebug = iniconf.String("qax580::isdebug")
	}
	if isdebug == "true" {
		openid = "o3AhEuB_wdTELvlErL4F1Em4Nck4"
		c.Data["OpenId"] = openid
	}

	op := c.Input().Get("op")
	beego.Debug("op :", op)
	switch op {
	case "vote":
		id := c.Input().Get("id")
		err := models.AddVote(openid, pollsid, id)
		if err != nil {
			beego.Error(err)
		}
		url := fmt.Sprintf("/poll/pollhome?pollsid=%s", pollsid)
		c.Redirect(url, 302)
		return
	}
	c.Data["Time"] = int64(0)
	if len(pollsid) != 0 {
		err := models.AddPollsPv(pollsid)
		if err != nil {
			beego.Error(err)
		}
		polls, err := models.GetOnePolls(pollsid)
		if err != nil {
			beego.Error(err)
		}
		beego.Debug("polls", polls)
		c.Data["Time"] = polls.EndTimeLong
		c.Data["Polls"] = polls
		pv, err := models.GetPollsPv(pollsid)
		c.Data["PV"] = pv
		pollnum, err := models.GetPollAllNum(pollsid)
		c.Data["PollNum"] = pollnum
		votenum, err := models.GetVoteAllNum(pollsid)
		c.Data["VoteNum"] = votenum

		endtime := polls.EndTimeLong
		curtime := time.Now().Unix()
		timestr := "活动已过期"
		if endtime-curtime > 0 {
			t := time.Unix(endtime, 0)

			_, mon, day := t.Date()
			_, cmon, cday := time.Now().Date()
			hour, min, _ := t.Clock()
			chour, cmin, _ := time.Now().Clock()
			timestr = fmt.Sprintf("%d月%d天%02d小时%02d分", mon-cmon, day-cday, hour-chour, min-cmin)
			// beego.Debug(timestr)
		}
		c.Data["TimeStr"] = timestr

		objs, err := models.GetAllPollState(pollsid, 1)
		if err != nil {
			beego.Debug(err)
		}
		for i := 0; i < len(objs); i++ {
			num, err := models.GetVoteNum(pollsid, objs[i].Id)
			if err != nil {
				beego.Error(err)
			}
			objs[i].VoteNum = num
		}
		// beego.Debug("objs :", objs)
		c.Data["Objs"] = objs
		wxShareCon := models.WxShareCon{}
		wxShareCon.Title = polls.Title
		wxShareCon.Link = fmt.Sprintf("http://www.baoguangguang.cn/poll/pollwx?id=%s", pollsid)
		wxShareCon.ImgUrl = fmt.Sprintf("http://182.92.167.29:8080/imagehosting/%s", polls.Image)
		getPollShare(polls.Appid, polls.Secret, share_url, wxShareCon, c)
	}
	c.Data["PollsId"] = pollsid
	c.TplName = "pollhome.html"
}