Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
a7d1e2cb
Commit
a7d1e2cb
authored
Jun 10, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取二维码
parent
bcfc4ca8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
4 deletions
+102
-4
HttpHelper.cs
Mall.Common/Plugin/HttpHelper.cs
+69
-0
ProductModule.cs
Mall.Module.Product/ProductModule.cs
+1
-0
UserModule.cs
Mall.Module.User/UserModule.cs
+7
-3
AppletUserController.cs
Mall.WebApi/Controllers/User/AppletUserController.cs
+24
-0
UserController.cs
Mall.WebApi/Controllers/User/UserController.cs
+1
-1
No files found.
Mall.Common/Plugin/HttpHelper.cs
View file @
a7d1e2cb
...
...
@@ -291,6 +291,35 @@ namespace Mall.Common.Plugin
}
}
/// <summary>
/// 执行HTTP POST请求。
/// </summary>
/// <param name="url">请求地址</param>
/// <param name="postDataStr">请求地址</param>
/// <returns>HTTP响应</returns>
public
static
string
HttpPostForGetWXQRCodePath
(
string
url
,
string
postDataStr
,
string
path
)
{
HttpWebRequest
req
=
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
req
.
Method
=
"POST"
;
req
.
ContentType
=
"application/octet-stream"
;
req
.
ContentLength
=
Encoding
.
UTF8
.
GetByteCount
(
postDataStr
);
Stream
myRequestStream
=
req
.
GetRequestStream
();
StreamWriter
myStreamWriter
=
new
StreamWriter
(
myRequestStream
,
Encoding
.
GetEncoding
(
"gb2312"
));
myStreamWriter
.
Write
(
postDataStr
);
myStreamWriter
.
Close
();
HttpWebResponse
rsp
=
(
HttpWebResponse
)
req
.
GetResponse
();
if
(
string
.
IsNullOrWhiteSpace
(
rsp
.
CharacterSet
))
{
return
GetResponseAsStringBase64_V2
(
rsp
,
Encoding
.
UTF8
,
path
);
}
else
{
Encoding
encoding
=
Encoding
.
GetEncoding
(
rsp
.
CharacterSet
);
return
GetResponseAsStringBase64_V2
(
rsp
,
encoding
,
path
);
}
}
/// <summary>
/// 把响应流转换为文本
...
...
@@ -319,6 +348,46 @@ namespace Mall.Common.Plugin
}
}
/// <summary>
/// 把响应流转换为文本
/// </summary>
/// <param name="rsp"></param>
/// <param name="encoding"></param>
/// <returns></returns>
private
static
string
GetResponseAsStringBase64_V2
(
HttpWebResponse
rsp
,
Encoding
encoding
,
string
path
)
{
System
.
IO
.
Stream
stream
=
null
;
try
{
// 以字符流的方式读取HTTP响应
stream
=
rsp
.
GetResponseStream
();
return
ReadImageForStream_V2
(
stream
,
path
);
}
catch
{
return
""
;
}
finally
{
// 释放资源
if
(
stream
!=
null
)
stream
.
Close
();
if
(
rsp
!=
null
)
rsp
.
Close
();
}
}
/// <summary>
/// 获取
/// </summary>
/// <param name="imgstream"></param>
/// <returns></returns>
public
static
string
ReadImageForStream_V2
(
Stream
imgstream
,
string
path
)
{
System
.
Drawing
.
Image
result
=
System
.
Drawing
.
Image
.
FromStream
(
imgstream
);
System
.
Drawing
.
Bitmap
bit
=
new
System
.
Drawing
.
Bitmap
(
result
);
bit
.
Save
(
path
,
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
return
path
;
}
/// <summary>
/// 获取
/// </summary>
...
...
Mall.Module.Product/ProductModule.cs
View file @
a7d1e2cb
...
...
@@ -4673,6 +4673,7 @@ namespace Mall.Module.Product
if
(
demodel
.
GoodsId
>
0
)
{
goodsRepository
.
SetGoodsNewId
(
demodel
.
GoodsId
??
0
,
Id
,
trans
);
Id
=
demodel
.
GoodsId
??
0
;
}
//插入分类
foreach
(
var
item
in
demodel
.
CategoryList
)
...
...
Mall.Module.User/UserModule.cs
View file @
a7d1e2cb
...
...
@@ -3954,14 +3954,18 @@ namespace Mall.Module.User
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
CacheManager
.
AppletWeChat
.
WeiXinReidsCache
.
Set
(
appletWeChatModel
.
MiniAppId
,
token
));
}
if
(!
string
.
IsNullOrEmpty
(
token
))
{
string
GetImageUrl
=
"https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token="
+
token
;
//string GetImageUrl = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + token;//获取二维码
string
GetImageUrl
=
"https://api.weixin.qq.com/wxa/getwxacode?access_token="
+
token
;
//获取小程序码
var
postData
=
new
{
path
,
width
};
var
Robj
=
HttpHelper
.
HttpPostForWXQRCode
(
GetImageUrl
,
JsonHelper
.
Serialize
(
postData
));
var
Robj1
=
HttpHelper
.
HttpPost
(
GetImageUrl
,
JsonHelper
.
Serialize
(
postData
),
""
);
string
pathName
=
Guid
.
NewGuid
().
ToString
()
+
".jpg"
;
string
basepath
=
AppContext
.
BaseDirectory
;
string
path_server
=
basepath
+
"\\upfile\\temporary\\"
+
pathName
;
var
Robj
=
HttpHelper
.
HttpPostForGetWXQRCodePath
(
GetImageUrl
,
JsonHelper
.
Serialize
(
postData
),
path_server
);
//var Robj1 = HttpHelper.HttpPost(GetImageUrl, JsonHelper.Serialize(postData), "");
return
Robj
;
}
return
""
;
...
...
Mall.WebApi/Controllers/User/AppletUserController.cs
View file @
a7d1e2cb
...
...
@@ -959,6 +959,30 @@ namespace Mall.WebApi.Controllers.User
}
#
endregion
#
region
获取小程序码
/// <summary>
/// 获取微信小程序码
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetWeiXinQRCodeForApplet
()
{
var
req
=
RequestParm
;
var
userInfo
=
AppletUserInfo
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
string
Path
=
parms
.
GetStringValue
(
"Path"
);
//路径
int
With
=
parms
.
GetInt
(
"With"
,
430
);
//大小
if
(
string
.
IsNullOrEmpty
(
Path
))
{
return
ApiResult
.
ParamIsNull
(
"请传递路径"
);
}
string
base64Img
=
userModule
.
GetWeiXinQRCode
(
Path
,
With
,
userInfo
.
MallBaseId
);
return
ApiResult
.
Success
(
""
,
base64Img
);
}
#
endregion
#
region
个人中心余额
/
积分
/
优惠券气泡
/// <summary>
...
...
Mall.WebApi/Controllers/User/UserController.cs
View file @
a7d1e2cb
...
...
@@ -2539,7 +2539,7 @@ namespace Mall.WebApi.Controllers.User
var
req
=
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
string
Path
=
parms
.
GetStringValue
(
"Path"
);
//路径
int
With
=
parms
.
GetInt
(
"With"
,
10
0
);
//大小
int
With
=
parms
.
GetInt
(
"With"
,
43
0
);
//大小
if
(
string
.
IsNullOrEmpty
(
Path
))
{
return
ApiResult
.
ParamIsNull
(
"请传递路径"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment