Esempio n. 1
0
//todo:bug 当在UCenter登陆,会话会超时
func (this *mainC) Index(ctx *web.Context) {
	if this.Requesting(ctx) {
		mm := this.GetMember(ctx)
		p := this.GetPartner(ctx)

		fmt.Printf("--%+v   --- %+v\n", mm, p)
		conf := this.GetSiteConf(p.Id)

		acc := dps.MemberService.GetAccount(mm.Id)
		js, _ := json.Marshal(mm)
		info := make(map[string]string)
		info["memName"] = mm.Name

		lv := dps.PartnerService.GetLevel(p.Id, mm.Level)
		//nextLv := dps.PartnerService.GetNextLevel(p.Id, mm.Level)

		//		if nextLv == nil {
		//			nextLv = lv
		//		}

		this.ExecuteTemplate(ctx, gof.TemplateDataMap{
			"level": lv,
			//"nLevel":       nextLv,
			"member":       mm,
			"partner":      p,
			"conf":         conf,
			"partner_host": conf.Host,
			"json":         template.JS(js),
			"acc":          acc,
			"regTime":      time.Unix(mm.RegTime, 0).Format("2006-01-02"),
			"name": template.HTML(gfmt.BoolString(len(mm.Name) == 0, `<span class="red">未填写</span>`,
				mm.Name)),
			"sex": gfmt.BoolString(mm.Sex == 1, "先生",
				gfmt.BoolString(mm.Sex == 2, "女士", "")),
		}, "views/ucenter/{device}/index.html",
			"views/ucenter/{device}/inc/header.html",
			"views/ucenter/{device}/inc/menu.html",
			"views/ucenter/{device}/inc/footer.html")
	}
}
Esempio n. 2
0
func (this *goodsC) LvPrice(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	//todo: should be goodsId
	itemId, _ := strconv.Atoi(ctx.Request.URL.Query().Get("item_id"))
	goods := dps.SaleService.GetGoodsBySku(partnerId, itemId, 0)
	lvs := dps.PartnerService.GetMemberLevels(partnerId)
	var prices []*sale.MemberPrice = dps.SaleService.GetGoodsLevelPrices(partnerId, goods.GoodsId)

	var buf *bytes.Buffer = bytes.NewBufferString("")

	var fmtFunc = func(level int, levelName string, id int, price float32, enabled int) {
		buf.WriteString(fmt.Sprintf(`
		<tr>
                <td><input type="hidden" field="Id_%d" value="%d"/>
                    %s</td>
                <td align="center"><input type="number" field="Price_%d" value="%s"/></td>
                <td align="center"><input type="checkbox" field="Enabled_%d" %s/></td>
            </tr>
		`, level, id, levelName, level, format.FormatFloat(price), level,
			gfmt.BoolString(enabled == 1, "checked=\"checked\"", "")))
	}

	var b bool
	for _, v := range lvs {
		b = false
		for _, v1 := range prices {
			if v.Value == v1.Level {
				fmtFunc(v.Value, v.Name, v1.Id, v1.Price, v1.Enabled)
				b = true
				break
			}
		}
		if !b {
			fmtFunc(v.Value, v.Name, 0, goods.SalePrice, 0)
		}
	}

	ctx.App.Template().Execute(ctx.Response, gof.TemplateDataMap{
		"goods":   goods,
		"setHtml": template.HTML(buf.String()),
	}, "views/partner/goods/level_price.html")
}