|
|
@@ -61,41 +61,41 @@ func (self *PosterController) GetPosterXcxQrcode() {
|
|
|
wxUser := self.GetCurrentWxUser(true)
|
|
|
if wxUser != nil {
|
|
|
wxHead = GetCdnFullImgUrl(wxUser.Head)
|
|
|
- } else {
|
|
|
- if posterQrcodeRecord == nil {
|
|
|
- homeUrl := fmt.Sprintf("pages/start/start")
|
|
|
- width, _ := self.GetInt("width", 430)
|
|
|
- scene := fmt.Sprintf("%s$%d$%d", _type, id, wxUid)
|
|
|
- qrcodeData := wx_mp.GenerateQrcode(wx_mp.QR_SCENE, homeUrl, scene, width)
|
|
|
- //if len(qrcodeData) < 400 {
|
|
|
- //self.ReturnError(403, apps.Error, "", nil)
|
|
|
- //}
|
|
|
- filename := fmt.Sprintf("p_%d.jpg", time.Now().Unix())
|
|
|
- localPath := fmt.Sprintf("%s/%s", beego.AppConfig.String("QrcodePath"), filename)
|
|
|
- err := ioutil.WriteFile(localPath, qrcodeData, 0644)
|
|
|
-
|
|
|
- if err != nil {
|
|
|
- beego.BeeLogger.Error(err.Error())
|
|
|
- }
|
|
|
-
|
|
|
- uploadPath := fmt.Sprintf("qrcode_path/poster/%s", filename)
|
|
|
- //上传到阿里云原目录下面
|
|
|
- err = ali_oss.PutObjectFromFile(beego.AppConfig.String("AliOssEndPoint"),
|
|
|
- beego.AppConfig.String("AliOssAccessId"),
|
|
|
- beego.AppConfig.String("AliOssAccessSecret"),
|
|
|
- beego.AppConfig.String("AliOssBucket"), "", uploadPath, localPath)
|
|
|
-
|
|
|
- if err != nil {
|
|
|
- beego.BeeLogger.Error("Upload Pngs err: %s", err)
|
|
|
- } else {
|
|
|
- qrcodeUrl = GetCdnFullImgUrl(uploadPath)
|
|
|
- }
|
|
|
-
|
|
|
- new(poster_model.PosterQrcodeRecord).Create(wxUid, id, id, _type, uploadPath)
|
|
|
+ }
|
|
|
+
|
|
|
+ if posterQrcodeRecord == nil {
|
|
|
+ homeUrl := fmt.Sprintf("pages/start/start")
|
|
|
+ width, _ := self.GetInt("width", 430)
|
|
|
+ scene := fmt.Sprintf("%s$%d$%d", _type, id, wxUid)
|
|
|
+ qrcodeData := wx_mp.GenerateQrcode(wx_mp.QR_SCENE, homeUrl, scene, width)
|
|
|
+ //if len(qrcodeData) < 400 {
|
|
|
+ //self.ReturnError(403, apps.Error, "", nil)
|
|
|
+ //}
|
|
|
+ filename := fmt.Sprintf("p_%d.jpg", time.Now().Unix())
|
|
|
+ localPath := fmt.Sprintf("%s/%s", beego.AppConfig.String("QrcodePath"), filename)
|
|
|
+ err := ioutil.WriteFile(localPath, qrcodeData, 0644)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ beego.BeeLogger.Error(err.Error())
|
|
|
+ }
|
|
|
|
|
|
+ uploadPath := fmt.Sprintf("qrcode_path/poster/%s", filename)
|
|
|
+ //上传到阿里云原目录下面
|
|
|
+ err = ali_oss.PutObjectFromFile(beego.AppConfig.String("AliOssEndPoint"),
|
|
|
+ beego.AppConfig.String("AliOssAccessId"),
|
|
|
+ beego.AppConfig.String("AliOssAccessSecret"),
|
|
|
+ beego.AppConfig.String("AliOssBucket"), "", uploadPath, localPath)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ beego.BeeLogger.Error("Upload Pngs err: %s", err)
|
|
|
} else {
|
|
|
- qrcodeUrl = GetCdnFullImgUrl(posterQrcodeRecord.QrcodeUrl)
|
|
|
+ qrcodeUrl = GetCdnFullImgUrl(uploadPath)
|
|
|
}
|
|
|
+
|
|
|
+ new(poster_model.PosterQrcodeRecord).Create(wxUid, id, id, _type, uploadPath)
|
|
|
+
|
|
|
+ } else {
|
|
|
+ qrcodeUrl = GetCdnFullImgUrl(posterQrcodeRecord.QrcodeUrl)
|
|
|
}
|
|
|
|
|
|
type Ret struct {
|