欢迎光临,了解微信小程序开发,就上易用通!

thinkphp5+easywechat开发小程序支付

发布:2018-04-23 12:16浏览: 来源:网络 作者:cola

1、composer下载thinkphp5

composer create-project topthink/think [你的目录名] --prefer-dist

2、composer下载easywechat

composer require hooklife/thinkphp5-wechat

3、配置好小程序的appid和appsercret,还有证书

第一步: 
获取用户的openid

小程序代码

 

				
  1. //app.js
  2. App({
  3. onLaunch: function() {
  4. wx.login({
  5. success: function (res) {
  6. if (res.code) {
  7. //发起网络请求获得openid
  8. wx.request({
  9. url: 'https://xxxxxxxx/index/on_login/index',
  10. data: {
  11. code: res.code
  12. },
  13. success:function(res){
  14. //console.log(res.data.openid)
  15. that.globalData.openId = res.data.openid
  16. },
  17. fail:function(e){
  18. console.log(e);
  19. }





免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。