本文整理汇总了Golang中go2o/src/core/infrastructure/format.GetGoodsImageUrl函数的典型用法代码示例。如果您正苦于以下问题:Golang GetGoodsImageUrl函数的具体用法?Golang GetGoodsImageUrl怎么用?Golang GetGoodsImageUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetGoodsImageUrl函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: cart_GetCart
func (this *CartC) cart_GetCart(ctx *web.Context, p *partner.ValuePartner,
memberId int, cartKey string) {
//time.Sleep(time.Second*10)
cart := dps.ShoppingService.GetShoppingCart(p.Id, memberId, cartKey)
if cart.Items != nil {
for _, v := range cart.Items {
v.GoodsImage = format.GetGoodsImageUrl(v.GoodsImage)
}
}
// 持续保存cookie
ck, err := ctx.Request.Cookie("_cart")
if err != nil {
ck = &http.Cookie{
Name: "_cart",
Path: "/",
}
}
ck.Value = cart.CartKey
ck.Expires = time.Now().Add(time.Hour * 48)
http.SetCookie(ctx.Response, ck)
d, _ := json.Marshal(cart)
ctx.Response.Write(d)
}
示例2: GetList
func (this *listC) GetList(ctx *web.Context) {
r, w := ctx.Request, ctx.ResponseWriter
p := this.GetPartner(ctx)
const getNum int = -1 //-1表示全部
categoryId, _ := strconv.Atoi(r.URL.Query().Get("cid"))
items := dps.SaleService.GetOnShelvesGoodsByCategoryId(p.Id, categoryId, getNum)
if len(items) == 0 {
w.Write([]byte(`无商品`))
return
}
buf := bytes.NewBufferString("<ul>")
for _, v := range items {
buf.WriteString(fmt.Sprintf(`
<li>
<div class="gs_goodss">
<img src="%s" alt="%s"/>
<h3 class="name">%s%s</h3>
<span class="srice">原价:¥%s</span>
<span class="sprice">优惠价:¥%s</span>
<a href="javascript:cart.add(%d,1);" class="add"> </a>
</div>
</li>
`, format.GetGoodsImageUrl(v.Image), v.Name, v.Name, v.SmallTitle, format.FormatFloat(v.Price),
format.FormatFloat(v.SalePrice),
v.Id))
}
buf.WriteString("</ul>")
w.Write(buf.Bytes())
}
示例3: Goods_select
//商品选择
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")
}
示例4: List_Index
// 商品列表
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")
}
}
示例5: GoodsView
// 商品详情
func (this *ListC) GoodsView(ctx *web.Context) {
if this.BaseC.Requesting(ctx) {
r := ctx.Request
p := this.BaseC.GetPartner(ctx)
path := r.URL.Path
goodsId, _ := strconv.Atoi(path[strings.LastIndex(path, "-")+1 : strings.Index(path, ".")])
m := this.BaseC.GetMember(ctx)
var level int = 0
if m != nil {
level = m.Level
}
goods, proMap := dps.SaleService.GetGoodsDetails(p.Id, goodsId, level)
goods.Image = format.GetGoodsImageUrl(goods.Image)
// 促销价 & 销售价
var promPrice string
var salePrice string
if goods.PromPrice < goods.SalePrice {
promPrice = fmt.Sprintf(`<span class="prom-price">¥<b>%s</b></span>`, format.FormatFloat(goods.PromPrice))
salePrice = fmt.Sprintf("<del>¥%s</del>", format.FormatFloat(goods.SalePrice))
} else {
salePrice = "¥" + format.FormatFloat(goods.SalePrice)
}
// 促销信息
var promDescribe string
var promCls string = "hidden"
if len(proMap) != 0 {
promCls = ""
buf := bytes.NewBufferString("")
var i int = 0
for k, v := range proMap {
i++
buf.WriteString(fmt.Sprintf(`<div class="prom-box prom%d">
<span class="bg_txt red">%s</span>:<span class="describe">%s</span></div>`, i, k, v))
}
promDescribe = buf.String()
}
this.BaseC.ExecuteTemplate(ctx, gof.TemplateDataMap{
"goods": goods,
"promap": proMap,
"prom_price": template.HTML(promPrice),
"sale_price": template.HTML(salePrice),
"prom_describe": template.HTML(promDescribe),
"prom_cls": promCls,
},
"views/shop/ols/{device}/goods.html",
"views/shop/ols/{device}/inc/header.html",
"views/shop/ols/{device}/inc/footer.html")
}
}
示例6: cart_AddItem
func (this *CartC) cart_AddItem(ctx *web.Context,
p *partner.ValuePartner, memberId int, cartKey string) {
r := ctx.Request
goodsId, _ := strconv.Atoi(r.FormValue("id"))
num, _ := strconv.Atoi(r.FormValue("num"))
item, err := dps.ShoppingService.AddCartItem(p.Id, memberId, cartKey, goodsId, num)
var d map[string]interface{} = make(map[string]interface{})
if err != nil {
d["error"] = err.Error()
} else {
item.GoodsImage = format.GetGoodsImageUrl(item.GoodsImage)
d["item"] = item
}
ctx.Response.JsonOutput(d)
}
示例7: Get_ad
// 获取广告数据
func (this *partnerC) Get_ad(ctx *web.Context) {
partnerId := this.GetPartnerId(ctx)
adName := ctx.Request.FormValue("ad_name")
adv, data := dps.AdvertisementService.GetAdvertisementAndDataByName(partnerId, adName)
if data != nil {
// 图片广告
if adv.Type == ad.TypeGallery {
gv := data.(ad.ValueGallery)
if gv != nil {
for _, v := range gv {
if strings.Index(v.ImageUrl, "http://") == -1 {
v.ImageUrl = format.GetGoodsImageUrl(v.ImageUrl)
}
}
}
ctx.Response.JsonOutput(gv)
return
}
ctx.Response.JsonOutput(data)
} else {
this.ErrorOutput(ctx, "没有广告数据")
}
}
示例8: GetList
func (this *listC) GetList(ctx *web.Context) {
r, w := ctx.Request, ctx.Response
p := this.GetPartner(ctx)
pa := this.GetPartnerApi(ctx)
const getNum int = -1 //-1表示全部
categoryId, err := strconv.Atoi(r.URL.Query().Get("cid"))
if err != nil {
w.Write([]byte(`{"error":"yes"}`))
return
}
items, err := goclient.Partner.GetItems(p.Id, pa.ApiSecret, categoryId, getNum)
if err != nil {
w.Write([]byte(`{"error":"` + err.Error() + `"}`))
return
}
buf := bytes.NewBufferString("<ul>")
for _, v := range items {
buf.WriteString(fmt.Sprintf(`
<li>
<div class="gs_goodss">
<img src="%s" alt="%s"/>
<h3 class="name">%s%s</h3>
<span class="srice">原价:¥%s</span>
<span class="sprice">优惠价:¥%s</span>
<a href="javascript:cart.add(%d,1);" class="add"> </a>
</div>
</li>
`, format.GetGoodsImageUrl(v.Image), v.Name, v.Name, v.SmallTitle, format.FormatFloat(v.Price),
format.FormatFloat(v.SalePrice),
v.Id))
}
buf.WriteString("</ul>")
w.Write(buf.Bytes())
}
示例9: SaleTagGoodsList
// 销售标签列表
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="/goods-%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")
}
}
示例10: Category
//分类树形功能
func (this *categoryC) Category(ctx *web.Context) {
ctx.App.Template().Execute(ctx.ResponseWriter, gof.TemplateDataMap{
"nopicUrl": format.GetGoodsImageUrl(""),
}, "views/partner/category/category.html")
}