切换导航条
此项目
正在载入...
登录
anyv
/
xkeasy
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
anyv
6 years ago
提交
4f8e7a412b9256cb29dc9dd1602a42b3aa11ab80
1 个父辈
c9f8e332
1 个管道 的构建
通过
耗费 0 秒
4
变更
3
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
79 行增加
和
2 行删除
app/portal/controller/SalesmangoodsController.php
public/themes/simpleboot3/portal/salesmangoods/salesman_goods_add.html
simplewind/cmf/controller/WeChatBaseController.php
app/portal/controller/SalesmangoodsController.php
查看文件 @
4f8e7a4
...
...
@@ -202,6 +202,78 @@ class SalesmangoodsController extends WeChatBaseController{
}
// 获取签名
public
function
getSignPackage
()
{
// 获取token
$token
=
$this
->
getAccessToken
();
// 获取ticket
$ticketList
=
$this
->
getJsApiTicket
(
$token
[
'accessToken'
]);
$ticket
=
$ticketList
[
'ticket'
];
// 该URL为使用JSSDK接口的URL
$url
=
$_GET
[
'url'
];
if
(
!
$url
)
{
$url
=
'http://xxx.xxx.com/index/index.html'
;
}
// 时间戳
$timestamp
=
time
();
// 随机字符串
$nonceStr
=
$this
->
createNoncestr
();
// 这里参数的顺序要按照 key 值 ASCII 码升序排序 j -> n -> t -> u
$string
=
"jsapi_ticket=
$ticket
&noncestr=
$nonceStr
×tamp=
$timestamp
&url=
$url
"
;
$signature
=
sha1
(
$string
);
$signPackage
=
array
(
"appId"
=>
C
(
'WxPayConf_pub.APPID'
),
"nonceStr"
=>
$nonceStr
,
"timestamp"
=>
$timestamp
,
"url"
=>
$url
,
"signature"
=>
$signature
,
"rawString"
=>
$string
,
"ticket"
=>
$ticket
,
"token"
=>
$token
[
'accessToken'
]
);
// 提供数据给前端
$this
->
ajaxReturn
(
array
(
'status'
=>
true
,
'data'
=>
$signPackage
));
}
public
function
getAccessToken
()
{
// access_token 应该全局存储与更新
// 获取数据库中的access_token
$token
=
M
(
'accesstoken'
)
->
limit
(
1
)
->
find
();
// 如果数据库存在token
if
(
$token
)
{
// 格式化数据库的timestamp
$time
=
strtotime
(
$token
[
'time'
]);
}
// accessToken过期或不存在时
if
(
$time
+
$token
[
'expiresIn'
]
<
time
()
||
$token
[
'accessToken'
]
==
NULL
){
$url
=
"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
.
C
(
'WxPayConf_pub.APPID'
)
.
"&secret="
.
C
(
'WxPayConf_pub.APPSECRET'
);
// 微信返回的信息
$returnData
=
json_decode
(
$this
->
httpGet
(
$url
));
// 组装数据
$resData
[
'accessToken'
]
=
$returnData
->
access_token
;
$resData
[
'expiresIn'
]
=
$returnData
->
expires_in
;
$resData
[
'time'
]
=
date
(
"Y-m-d H:i"
,
time
());
// 把数据存进数据库
M
(
'accesstoken'
)
->
where
(
array
(
'id'
=>
$token
[
'id'
]))
->
save
(
$resData
);
$res
=
$resData
;
}
else
{
$res
=
$token
;
}
return
$res
;
}
...
...
public/themes/simpleboot3/portal/salesmangoods/salesman_goods_add.html
查看文件 @
4f8e7a4
...
...
@@ -304,6 +304,11 @@
function
openCamera
(){
$
.
post
(
"{:url('/')}"
,{},
function
(
data
)
{
});
wx
.
chooseImage
({
count
:
1
,
// 默认9
sizeType
:
[
'original'
],
// 指定是原图还是压缩图,默认都有
...
...
simplewind/cmf/controller/WeChatBaseController.php
查看文件 @
4f8e7a4
...
...
@@ -204,8 +204,8 @@ class WeChatBaseController extends BaseController
*/
public
function
checkWeChatUserLogin
()
{
$user
=
Db
::
name
(
'user'
)
->
where
(
'id'
,
2
)
->
find
();
cmf_update_current_user
(
$user
);
/*$user = Db::name('user')->where('id',5)->find();
cmf_update_current_user($user);*/
$userId
=
cmf_get_current_user_id
();
if
(
empty
(
$userId
))
{
$config
=
[
...
...
请
注册
或
登录
后发表评论