浏览代码

手机号转义 +

xingzai 3 年之前
父节点
当前提交
33a2adcf09
共有 1 个文件被更改,包括 4 次插入34 次删除
  1. 4 34
      controllers/report.go

+ 4 - 34
controllers/report.go

@@ -106,7 +106,7 @@ func (c *ReportController) ListReport() {
 		c.FailWithMessage("获取失败")
 		return
 	}
-
+	mobile = url.QueryEscape(mobile) //转义 +
 	nonceStr := common.GetRandString(10)
 	timeUnix := strconv.FormatInt(time.Now().Unix(), 10)
 	if len(list) > 0 {
@@ -144,22 +144,7 @@ func (c *ReportControllerCommon) GetReportInfo() {
 		c.FailWithMessage("请传入报告id")
 		return
 	}
-	var mobile string
-	URL, err := url.Parse(c.Ctx.Input.URI())
-	if err != nil {
-		fmt.Println(err)
-		c.FailWithMessage("获取报告失败")
-		return
-	}
-	urlParameter := URL.RawQuery
-	sliceUrl := strings.Split(urlParameter, "&")
-	if len(sliceUrl) > 0 {
-		for _, v := range sliceUrl {
-			if strings.Contains(v, "mobile=") {
-				mobile = strings.Replace(v, "mobile=", "", -1)
-			}
-		}
-	}
+	mobile := c.GetString("mobile")
 	if mobile == "" {
 		c.FailWithMessage("mobile 必传")
 		return
@@ -195,6 +180,7 @@ func (c *ReportControllerCommon) GetReportInfo() {
 		c.FailWithMessage("无权限")
 		return
 	}
+	mobile = url.QueryEscape(mobile) //转义 +
 	nonceStr := common.GetRandString(10)
 	timeUnix := strconv.FormatInt(time.Now().Unix(), 10)
 	if len(reportInfo.ResearchReportTypeList) > 1 {
@@ -227,23 +213,7 @@ func (c *ReportControllerCommon) GetResearchReportChapter() {
 		c.FailWithMessage("请传入章节id")
 		return
 	}
-	//通过url获取mobile中的参数
-	var mobile string
-	URL, err := url.Parse(c.Ctx.Input.URI())
-	if err != nil {
-		fmt.Println(err)
-		c.FailWithMessage("获取报告失败")
-		return
-	}
-	urlParameter := URL.RawQuery
-	sliceUrl := strings.Split(urlParameter, "&")
-	if len(sliceUrl) > 0 {
-		for _, v := range sliceUrl {
-			if strings.Contains(v, "mobile=") {
-				mobile = strings.Replace(v, "mobile=", "", -1)
-			}
-		}
-	}
+	mobile := c.GetString("mobile")
 	if mobile == "" {
 		c.FailWithMessage("mobile 必传")
 		return