# wePay **Repository Path**: passionDper/wePay ## Basic Information - **Project Name**: wePay - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-09-19 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # wePay ### 1.登录代码 login: function () { wx.login({ success: function (res) { console.log(res.code) //发送请求 wx.request({ url: 'test.php', //接口地址 data: { code: res.code }, header: { 'content-type': 'application/json' //默认值 }, success: function (res) { console.log(res.data) } }) } }) }, ### 2.分享代码 Page({ <<<<<<< HEAD data: { }, onLoad: function () { wx.showShareMenu({ withShareTicket: true, success: function (res) { // 分享成功 console.log(res) }, fail: function (res) { // 分享失败 console.log(res) } }) }, onShareAppMessage: function () { return { title: '这里是小程序', path: '/page/index/index?id=123', success: function (res) { console.log(res.shareTickets[0]) wx.getShareInfo({ shareTicket: res.shareTickets[0], success: function (res) { console.log(res) }, fail: function (res) { console.log(res) }, complete: function (res) { console.log(res) } }) }, fail: function (res) { // 分享失败 console.log(res) } } } }) ### 3.获取openID const APP_ID ='';//输入小程序appid const APP_SECRET ='';//输入小程序app_secret var OPEN_ID=''//储存获取到openid var SESSION_KEY=''//储存获取到session_key Page({ getOpenIdTap:function(){ var that=this; wx.login({ success:function(res){ wx.request({ //获取openid接口 url: 'https://api.weixin.qq.com/sns/jscode2session', data:{ appid:APP_ID, secret:APP_SECRET, js_code:res.code, grant_type:'authorization_code' }, method:'GET', success:function(res){ console.log(res.data) OPEN_ID = res.data.openid;//获取到的openid SESSION_KEY = res.data.session_key;//获取到session_key console.log(OPEN_ID.length) console.log(SESSION_KEY.length) that.setData({ openid: res.data.openid.substr(0, 10) + '********' + res.data.openid.substr(res.data.openid.length - 8, res.data.openid.length), session_key: res.data.session_key.substr(0, 8) + '********' + res.data.session_key.substr(res.data.session_key.length - 6, res.data.session_key.length) }) } }) } }) } }) ======= >>>>>>> 267d0ef28b54404c3ba229ef5dabe3428703cfad