微信小程序获取openid和session_key并且把openid存入数据库。已经调用openid的demo
前后端代码都有,后端php实现
在其它地方同步调用openid。(确保用户完成登录再进行后续的操作);
onLoad:function(options){
getApp().promise.then(resolve => {
var url = app.url + '/api/v1/Room/UserInfo'
util.request(url, 'post', {
name: userInfo.nickName,
avatarUrl: userInfo.avatarUrl,
accid: wx.getStorageSync('accid')
}, '', function (res) {
wx.redirectTo({
url: '/pages/home/home'
})
})
})
}
小程序代码,获取openid,并且做同步的阻塞。
//app.js
var util = require('utils/util.js');
App({
onLaunch: function() {
this.url = 'http://127.0.0.1/smile_chatRoom/'
var that = this;
return that.pr