微信小程序一键登录

新版微信接口已无法获得用户真实的昵称与头像,一键登录只能获取到用户的openid,用户的微信昵称和头像只能通过完善资料,让用户自己选择上传和填写。

一键登录

点击登录后通过wx.login获取用户临时凭证code,然后发送给后端,经过code2Session接口获取到openid

微信小程序登录官方文档

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
getUserInfo() {
return new Promise((resolve, reject) => {
wx.getUserProfile({
lang: 'zh_CN',
desc: '用户登录',
success: (res) => {
resolve(res.userInfo)
},
fail: (err) => {
reject(err)
}
})
})
},

getLogin() {
return new Promise((resolve, reject) => {
wx.login({
success(res) {
resolve(res.code)
},
fail: (err) => {
reject(err)
}
})
})
},

login() {
let userInfo = this.getUserInfo();
let wxCode = this.getLogin();
let that = this

Promise.all([userInfo, wxCode]).then((res) => {
that.userInfo.nickName = res[0].nickName
that.userInfo.avatarUrl = res[0].avatarUrl
uni.request({
url: 'https://www.xxx.com/xxx/user/wxapp/login',
method: 'GET',
data: {
code: res[1]
},
success(res2) {
that.userInfo.openid = res2.data.data.openid
}
})
//都获取权限成功
}).catch(err => {

})
},

完善用户资料

button按钮添加open-type="chooseAvatar"让用户选择头像

inputtype="nickname"可以让用户选择昵称

1
2
3
4
5
6
7
8
9
10
11
12
<view>
<button open-type="chooseAvatar" bindchooseavatar="onChooseAvatar">
<image class="avatar" src="{{avatarUrl}}"></image>
</button>
<form>
<view>
<view>昵称:</view>
<input type="nickname" name="nickname" placeholder="请输入昵称"/>
</view>
<button type="primary" form-type="submit">提交</button>
</form>
</view>

微擎离线版应用安装更新卸载命令

离线安装模式下应用的安装、更新和卸载
由于创始人功能统一迁移到控制台,故对于应用的安装、更新和卸载,系统提供了命令行模式,具体如下:

安装: php console.php module:install module_name=应用标识

更新: php console.php module:upgrade module_name=应用标识

卸载: php console.php module:uninstall module_name=应用标识

NPM新的淘宝源镜像地址

淘宝源更新,旧的web站点npm.taobao.org和淘宝源registry.npm.taobao.org域名将在2022年5月31日零时停止服务。

新的站点:

web站点:npmmirror.com。
淘宝源:registry.npmmirror.com。

1
2
npm config set registry https://registry.npmmirror.com
npm get registry