Эх сурвалжийг харах

feat:微信浏览器判断

wangshan 3 жил өмнө
parent
commit
041b1babf9
1 өөрчлөгдсөн 10 нэмэгдсэн , 0 устгасан
  1. 10 0
      src/qfw/util/common.go

+ 10 - 0
src/qfw/util/common.go

@@ -12,6 +12,7 @@ import (
 	"math"
 	"math/big"
 	mathRand "math/rand"
+	"net/http"
 	"net/url"
 	"reflect"
 	"regexp"
@@ -706,3 +707,12 @@ func RetainDecimal(v float64, n int) float64 {
 	n10 := math.Pow10(n)
 	return math.Trunc((v+0.5/n10)*n10) / n10
 }
+
+//判断是否是微信访问
+func CheckWxBrowser(Request *http.Request) bool {
+	if strings.Index(Request.UserAgent(), "MicroMessenger") > -1 || strings.Index(Request.UserAgent(), "Wechat") > -1 {
+		return true
+	} else {
+		return false
+	}
+}