func (this *UserController) Q() { w := this.ResponseWriter r := this.Request r.ParseForm() parId := r.FormValue("id") common := CommonController{HTTP: this.HTTP} t := common.getTpl("UserDetail", "T.user.tpl", "Order.add.tpl") showuser := m.User{Id: parId} data := e.TData{} flag := false isCurrentUser := false cookie := u.Cookie{HTTP: this.HTTP} cookie = cookie.GetCookie() // log.Println("获取cookie中的用户名") // username := u.GetCookieUserName(w, r) // if username != "" { //如果已经登录了 // user = user.GetOneUserByName(username) // } else { // } log.Println(parId) if parId == "" { log.Println("url有错误") } showuser = showuser.GetOneUserById() loginuser := m.User{} userId := cookie.UserId //登录用户 log.Println(showuser.RealName) if showuser.RealName != "" { //查到用户 if userId != nil { //查到有登录用户 loginuser.Id = userId.Value flag = true if showuser.Id == loginuser.Id { //已登录的用户浏览别人的资料 isCurrentUser = true } } if !isCurrentUser { //别人浏览 telph := u.SubString(showuser.UserName, 0, len(showuser.UserName)-4) + "****" idCard := u.SubString(showuser.IDCard, 0, len(showuser.IDCard)-4) + "****" showuser.UserName = telph showuser.IDCard = idCard } data = e.TData{Data: showuser, CurrentUser: loginuser, Flag: flag} t.Execute(w, &data) } }
func shortenstr(x string) interface{} { length := len(x) if length > 10 { return u.SubString(x, 0, 10) + "..." } return x }