访客设置为默认两个头像

master
taoshihan 2 years ago
parent 538de693a1
commit 306ef8d31e

@ -2,13 +2,11 @@ package controller
import (
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"github.com/taoshihan1991/imaptool/common"
"github.com/taoshihan1991/imaptool/models"
"github.com/taoshihan1991/imaptool/tools"
"github.com/taoshihan1991/imaptool/ws"
"math/rand"
"strconv"
)
@ -60,7 +58,14 @@ import (
//}
func PostVisitorLogin(c *gin.Context) {
ipcity := tools.ParseIp(c.ClientIP())
avator := fmt.Sprintf("/static/images/%d.jpg", rand.Intn(14))
avator:=""
userAgent := c.GetHeader("User-Agent")
if tools.IsMobile(userAgent) {
avator = "/static/images/phone.png"
} else {
avator = "/static/images/computer.png"
}
toId := c.PostForm("to_id")
id := c.PostForm("visitor_id")

@ -393,7 +393,10 @@ a{color: #07a9fe;text-decoration: none;}
}
.chatTitle{height: 30px;line-height: 30px;color: #1989fa}
.chatBoxSend{background: #fff;height: 100px;}
.chatBoxSend{
background: #fff;height: 100px;
position: relative;
}
.chatBoxSendBtn{float: right;margin: 12px 4px 0 0;}
.footContact{text-align: center;}
.footContact a{font-size: 12px;color: #999;text-decoration: none;}

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

@ -3,6 +3,7 @@ package tools
import (
"io/ioutil"
"net/http"
"regexp"
"strings"
)
@ -50,3 +51,11 @@ func PostHeader(url string, msg []byte, headers map[string]string) (string, erro
}
return string(body), nil
}
func IsMobile(userAgent string) bool {
mobileRe, _ := regexp.Compile("(?i:Mobile|iPod|iPhone|Android|Opera Mini|BlackBerry|webOS|UCWEB|Blazer|PSP)")
str := mobileRe.FindString(userAgent)
if str != "" {
return true
}
return false
}
Loading…
Cancel
Save