Example #1
0
func (this *ScheduleController) Me() {
	w := this.ResponseWriter
	r := this.Request
	r.ParseForm()
	user := r.FormValue("user")

	page := u.Page{PageSize: 5, ShowPages: 5}

	currentPage := r.FormValue("page")

	log.Println("当前页数", currentPage)
	page.CurrentPage, _ = strconv.Atoi(currentPage)
	page.InitSkipRecords()

	log.Println("过滤多少页", page.SkipRecords)
	log.Println("总页数", page.TotalPages)
	order := m.Order{OUser: user}
	page = order.GetOuserOrders(page)
	page.InitTotalPages()

	t := template.New("")
	t = t.Funcs(template.FuncMap{"datetime": datetime})
	t, err := t.ParseFiles("views/Schedule.me.tpl")
	t.ExecuteTemplate(w, "mySchedule", &page)

	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
	}
}
Example #2
0
// 	if err != nil {
// 		http.Error(w, err.Error(), http.StatusInternalServerError)
// 	}
// }
func (this *ScheduleController) My() {
	w := this.ResponseWriter
	r := this.Request
	r.ParseForm()
	user := r.FormValue("user")

	page := u.Page{PageSize: 10, ShowPages: 5}

	currentPage := r.FormValue("page")

	log.Println("当前页数", currentPage)
	page.CurrentPage, _ = strconv.Atoi(currentPage)
	page.InitSkipRecords()

	log.Println("过滤多少页", page.SkipRecords)
	log.Println("总页数", page.TotalPages)
	order := m.Order{RUser: user}
	page = order.GetRuserOrders(page)
	page.InitTotalPages()

	context := pongo2.Context{"orderlist": page.Data}

	var tplExample = pongo2.Must(pongo2.FromFile("views/Schedule.my.tpl"))

	err := tplExample.ExecuteWriter(context, w)
	if err != nil {
		log.Println(err)
		http.Error(w, err.Error(), http.StatusInternalServerError)
	}
}
Example #3
0
/**
 * 接受预约
 */
func (this *ScheduleController) Accept() {
	data := e.Data{Msg: "操作成功", Status: 1}
	w := this.ResponseWriter
	r := this.Request
	r.ParseForm()
	orderId := r.FormValue("order")
	order := m.Order{Id: orderId, Status: "已接受"}
	order.UpdateOrderStatusById()
	u.OutputJson(w, &data)
}
Example #4
0
func (this *OrderController) Add() {
	w := this.ResponseWriter
	r := this.Request
	data := e.Data{Msg: "生成订单成功", Status: 1}
	r.ParseForm()

	money := r.FormValue("money")
	startTime := r.FormValue("startTime")
	endTime := r.FormValue("endTime")
	address := r.FormValue("address")
	ruserId := r.FormValue("ruser")
	remark := r.FormValue("remark")
	skillId := r.FormValue("skill")

	order := m.Order{}
	order.Skill.Id = skillId
	order.Skill = order.Skill.GetSkillById()

	order.RUser = ruserId
	cookie := u.Cookie{HTTP: this.HTTP}
	cookie = cookie.GetCookie()

	if cookie.UserId != nil {
		order.OUser = cookie.UserId.Value
	}

	log.Println(startTime)
	log.Println(endTime)
	order.BeginTime, _ = time.Parse("2006-01-02 15:04", startTime)
	order.EndTime, _ = time.Parse("2006-01-02 15:04", endTime)
	order.OrderTime = time.Now()
	order.Status = "预约"
	order.Remark = remark
	order.Address = address
	order.TotalPrice, _ = strconv.ParseFloat(money, 32)
	ordered, err := order.InsertOrder()
	data.Data = ordered
	if err != nil {
		data.Msg = "订单生成失败"
		data.Status = 0
	}
	u.OutputJson(w, &data)
}