• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang format.GetGoodsImageUrl函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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)
}
开发者ID:AlwaysOnline,项目名称:go2o,代码行数:27,代码来源:cart_c.go


示例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">&nbsp;</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())
}
开发者ID:honj51,项目名称:go2o,代码行数:32,代码来源:list_c.go


示例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")
}
开发者ID:zoe527,项目名称:go2o,代码行数:10,代码来源:goods_c.go


示例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")
	}
}
开发者ID:kevinhuo88888,项目名称:go2o,代码行数:58,代码来源:list_c.go


示例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")
	}
}
开发者ID:zoe527,项目名称:go2o,代码行数:55,代码来源:list_c.go


示例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)
}
开发者ID:AlwaysOnline,项目名称:go2o,代码行数:16,代码来源:cart_c.go


示例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, "没有广告数据")
	}
}
开发者ID:jacobxk,项目名称:go2o,代码行数:24,代码来源:partner_c.go


示例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">&nbsp;</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())
}
开发者ID:sunxboy,项目名称:go2o,代码行数:37,代码来源:list_c.go


示例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")
	}
}
开发者ID:zoe527,项目名称:go2o,代码行数:63,代码来源:list_c.go


示例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")
}
开发者ID:honj51,项目名称:go2o,代码行数:6,代码来源:category_c.go



注:本文中的go2o/src/core/infrastructure/format.GetGoodsImageUrl函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang log.PrintErr函数代码示例发布时间:2022-05-28
下一篇:
Golang format.FormatFloat函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap