uniapp 微信小程序通过wx.login获取code

uniapp yekong 257℃

uniapp进行微信小程序开发需要wx.login获取code 代码记录一下

login() {
				var that = this;
				uni.login({
					provider: 'weixin',
					success: function(res) {
						console.log(res)
						that.code = res.code
					}
				});
			},
			
			userlogin() {
				var data = {
					"code": this.code,
				}
				miniappsession(data, {
					header: {
						'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
					}
				}).then(res => {
					if (res.code == 0) {
						uni.showToast({
							title: '登录成功',
							icon: 'none'
						})
						uni.reLaunch({
							url: '/pages/home/home'
						})
					}
				}).catch(err => {

				})
			},
喜欢 (0)