Example #1
0
//商品选择
func (this *goodsC) Goods_select(ctx *web.Context) {
	r, w := ctx.Request, ctx.Response
	r.ParseForm()
	cateOpts := cache.GetDropOptionsOfCategory(this.GetPartnerId(ctx))
	ctx.App.Template().Execute(w, gof.TemplateDataMap{
		"cate_opts":  template.HTML(cateOpts),
		"no_pic_url": format.GetGoodsImageUrl(""),
	}, "views/partner/goods/goods_select.html")
}
Example #2
0
func (this *goodsC) Create(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	shopChks := cache.GetShopCheckboxs(partnerId, "")
	cateOpts := cache.GetDropOptionsOfCategory(partnerId)

	ctx.App.Template().Execute(ctx.ResponseWriter, gof.TemplateDataMap{
		"shop_chk":  template.HTML(shopChks),
		"cate_opts": template.HTML(cateOpts),
	},
		"views/partner/goods/create_goods.html")
}
Example #3
0
func (this *goodsC) Create(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	shopChks := cache.GetShopCheckboxs(partnerId, "")
	cateOpts := cache.GetDropOptionsOfCategory(partnerId)

	e := &sale.ValueItem{
		Image: ctx.App.Config().GetString(variable.NoPicPath),
	}
	js, _ := json.Marshal(e)

	ctx.App.Template().Execute(ctx.Response, gof.TemplateDataMap{
		"entity":    template.JS(js),
		"shop_chk":  template.HTML(shopChks),
		"cate_opts": template.HTML(cateOpts),
	},
		"views/partner/goods/create_goods.html")
}
Example #4
0
func (this *categoryC) EditCategory(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	r, w := ctx.Request, ctx.Response
	r.ParseForm()
	id, _ := strconv.Atoi(r.Form.Get("id"))
	var category *sale.ValueCategory = dps.SaleService.GetCategory(partnerId, id)
	json, _ := json.Marshal(category)

	re := regexp.MustCompile(fmt.Sprintf("<option class=\"opt\\d+\" value=\"%d\">[^>]+>", id))
	originOpts := cache.GetDropOptionsOfCategory(partnerId)
	cateOpts := re.ReplaceAll(originOpts, nil)

	ctx.App.Template().Execute(w,
		gof.TemplateDataMap{
			"entity":    template.JS(json),
			"cate_opts": template.HTML(cateOpts),
		},
		"views/partner/category/category_edit.html")
}
Example #5
0
func (this *goodsC) Edit(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	r, w := ctx.Request, ctx.Response
	var e *sale.ValueItem
	id, _ := strconv.Atoi(r.URL.Query().Get("item_id"))
	e = dps.SaleService.GetValueItem(partnerId, id)
	if e == nil {
		w.Write([]byte("商品不存在"))
		return
	}
	js, _ := json.Marshal(e)

	shopChks := cache.GetShopCheckboxs(partnerId, e.ApplySubs)
	cateOpts := cache.GetDropOptionsOfCategory(partnerId)

	ctx.App.Template().Execute(w,
		gof.TemplateDataMap{
			"entity":    template.JS(js),
			"shop_chk":  template.HTML(shopChks),
			"cate_opts": template.HTML(cateOpts),
		},
		"views/partner/goods/update_goods.html")
}