授权登录
getUserInfoFun: function (e) {
if (e == undefined) {
} else {
if (e.detail.errMsg == "getUserInfo:ok") {
var S = this;
wx.getUserInfo({
success: function (res) {
app.information.personInfo = res;
S.showPrePage();
}
【授权登录】})
app.information.userInfo = e.detail.userInfo
} else {
}
}
},
showPrePage: function (e) {
var utilMd5 = require('../../utils/util.js');
var that = this;
var timestamp = Date.parse(new Date());
timestamp = timestamp / 1000;
var password = utilMd5.hexMD5(app.information.code + timestamp);
wx.request({
url: '' + app.information.host + '/api/json/member/member.ashx?action=otherlogin&companyid=' + app.information.companyid+'&code=' + password + '×tamp=' + timestamp + '&type=wxlogin&openid=' + app.information.openid + '&nickname=' + app.information.userInfo.nickName + '&sex=' + app.information.userInfo.gender + '&headimgurl= ' + app.information.userInfo.avatarUrl,
header: {
'content-type': 'application/json',
},
//存储cookie
success: res => {
console.log(res)
if (res.header["Set-Cookie"].length > 200) {
app.information.cookie = res.header["Set-Cookie"];
that.setData({
eye: "0",
})
var e={id:that.data.id}
that.onLoad(e),
wx.showToast({
// 提示内容
title: "登录成功",
icon: "none",
duration: 2000,
mask: false,
})
} else {
wx.showToast({
// 提示内容
title: "登录失败",
icon: "none",
duration: 2000,
mask: false,
})
}
},
});
},
.jiazai{width: 100vw;
height: 100vh;
position: fixed;
z-index: 99;
background: rgba(0,0,0,0)}
.jiazai button{border-radius: 0;
border: none;
width: 80vw;
height: 13.33vw;
position: fixed;
bottom: 0;
right: 0;
background: #FF302D;
line-height: 14vw;
color: #fff;
font-size: 4vw;
font-weight: 600}
推荐阅读
- 运维|Linux 禁止用户或 IP通过 SSH 登录
- 窗上的冰花
- 【微信开放平台】微信第三方扫码登录(亲测可用)
- 部署教程
- 小程序登录、用户信息相关接口调整
- 实体店商家通过微信小程序解决流量和租金等问题-小程序登录小程序源码
- 爬虫怎样绕过验证码()
- 知乎免登录谷歌插件推荐
- 深入理解Kubernetes的认证与授权机制
- linux服务器间建立免密码登录