Exemplo n.º 1
0
// 商品列表
func (this *ListC) List_Index(ctx *web.Context) {
	if this.BaseC.Requesting(ctx) {
		r := ctx.Request
		p := this.BaseC.GetPartner(ctx)

		const size int = 20 //-1表示全部

		idArr := this.getIdArray(r.URL.Path)
		page, _ := strconv.Atoi(r.FormValue("page"))
		if page < 1 {
			page = 1
		}
		categoryId := idArr[len(idArr)-1]
		cat := dps.SaleService.GetCategory(p.Id, categoryId)

		total, items := dps.SaleService.GetPagedOnShelvesGoods(p.Id, categoryId, (page-1)*size, page*size)
		var pagerHtml string
		if total > size {
			pager := pager.NewUrlPager(pager.TotalPage(total, size), page, pager.GetterDefaultPager)
			pager.RecordCount = total
			pagerHtml = pager.PagerString()
		}

		buf := bytes.NewBufferString("")

		if len(items) == 0 {
			buf.WriteString("<div class=\"no_goods\">没有找到商品!</div>")
		} else {
			for i, v := range items {
				buf.WriteString(fmt.Sprintf(`
				<div class="item item-i%d">
					<div class="block">
						<a href="/item-%d.htm" class="goods-link">
							<img class="goods-img" src="%s" alt="%s"/>
							<h3 class="name">%s</h3>
							<span class="sale-price">¥%s</span>
							<span class="market-price"><del>¥%s</del></span>
						</a>
					</div>
                    <div class="clear-fix"></div>
                </div>
		`, i%2, v.GoodsId, format.GetGoodsImageUrl(v.Image),
					v.Name, v.Name, format.FormatFloat(v.SalePrice),
					format.FormatFloat(v.Price)))
			}
		}

		this.BaseC.ExecuteTemplate(ctx, gof.TemplateDataMap{
			"cat":   cat,
			"items": template.HTML(buf.Bytes()),
			"pager": template.HTML(pagerHtml),
		},
			"views/shop/ols/{device}/list.html",
			"views/shop/ols/{device}/inc/header.html",
			"views/shop/ols/{device}/inc/footer.html")
	}
}
Exemplo n.º 2
0
func (this *accountC) IncomeLog_post(ctx *web.Context) {
	m := this.GetMember(ctx)
	r := ctx.Request
	r.ParseForm()
	page, _ := strconv.Atoi(r.FormValue("page"))
	size, _ := strconv.Atoi(r.FormValue("size"))

	n, rows := dps.MemberService.QueryIncomeLog(m.Id, page, size, "", "record_time DESC")
	p := pager.NewUrlPager(pager.TotalPage(n, size), page, pager.GetterJavaScriptPager)
	pager := &front.Pager{Total: n, Rows: rows, Text: p.PagerString()}
	this.jsonOutput(ctx, pager)
}
Exemplo n.º 3
0
func (this *orderC) responseList(ctx *web.Context, where string) {
	m := this.GetMember(ctx)
	r, w := ctx.Request, ctx.Response
	page, _ := strconv.Atoi(r.FormValue("page"))
	size, _ := strconv.Atoi(r.FormValue("size"))

	n, rows := dps.MemberService.QueryPagerOrder(m.Id, page, size, where, "")

	p := pager.NewUrlPager(pager.TotalPage(n, size), page, pager.GetterJavaScriptPager)

	pager := &front.Pager{Total: n, Rows: rows, Text: p.PagerString()}

	js, _ := json.Marshal(pager)
	w.Write(js)
}
Exemplo n.º 4
0
func (this *orderC) Orders_post(ctx *web.Context) {
	m := this.GetMember(ctx)
	r, w := ctx.Request, ctx.ResponseWriter
	r.ParseForm()
	page, _ := strconv.Atoi(r.FormValue("page"))
	size, _ := strconv.Atoi(r.FormValue("size"))
	state := r.FormValue("state")

	var where string
	if state != "" {
		where = fmt.Sprintf("status IN (%s)", state)
	}

	n, rows := dps.MemberService.QueryPagerOrder(m.Id, page, size, where, "")

	p := pager.NewUrlPager(pager.TotalPage(n, size), page, pager.GetterJavaScriptPager)

	pager := &front.Pager{Total: n, Rows: rows, Text: p.PagerString()}

	js, _ := json.Marshal(pager)
	w.Write(js)
}
Exemplo n.º 5
0
// 销售标签列表
func (this *ListC) SaleTagGoodsList(ctx *web.Context) {
	if this.BaseC.Requesting(ctx) {
		r := ctx.Request
		p := this.BaseC.GetPartner(ctx)

		const size int = 20
		page, _ := strconv.Atoi(r.FormValue("page"))
		if page < 1 {
			page = 1
		}
		i := strings.LastIndex(r.URL.Path, "/")
		tagCode := r.URL.Path[i+1:]

		saleTag := dps.SaleService.GetSaleTagByCode(p.Id, tagCode)
		if saleTag == nil {
			http.Error(ctx.Response.ResponseWriter, "404 file not found!", http.StatusNotFound)
			ctx.Response.WriteHeader(404)
			return
		}

		total, items := dps.SaleService.GetPagedValueGoodsBySaleTag(p.Id, saleTag.Id, (page-1)*size, page*size)
		var pagerHtml string
		if total > size {
			pager := pager.NewUrlPager(pager.TotalPage(total, size), page, pager.GetterDefaultPager)
			pager.RecordCount = total
			pagerHtml = pager.PagerString()
		}

		buf := bytes.NewBufferString("")

		if len(items) == 0 {
			buf.WriteString("<div class=\"no_goods\">没有找到商品!</div>")
		} else {
			for i, v := range items {
				buf.WriteString(fmt.Sprintf(`
				<div class="item item-i%d">
					<div class="block">
						<a href="/item-%d.htm" class="goods-link">
							<img class="goods-img" src="%s" alt="%s"/>
							<h3 class="name">%s</h3>
							<span class="sale-price">¥%s</span>
							<span class="market-price"><del>¥%s</del></span>
						</a>
					</div>
                    <div class="clear-fix"></div>
                </div>
		`, i%2, v.GoodsId, format.GetGoodsImageUrl(v.Image),
					v.Name, v.Name, format.FormatFloat(v.SalePrice),
					format.FormatFloat(v.Price)))
			}
		}

		this.BaseC.ExecuteTemplate(ctx, gof.TemplateDataMap{
			"sale_tag": saleTag,
			"items":    template.HTML(buf.Bytes()),
			"pager":    template.HTML(pagerHtml),
		},
			"views/shop/ols/{device}/sale_tag.html",
			"views/shop/ols/{device}/inc/header.html",
			"views/shop/ols/{device}/inc/footer.html")
	}
}