uniapp 请求接口微信小程序码生成渲染记录

uniapp yekong

记录生成二维码数据处理方式,方便后期查询

getUn() {
				var that = this;
				getUn({
					page: this.page,
					width: 200,
					scene: this.userId
				}).then(res => {
					if (res.code == 200) {
						that.img = 'data:image/png;base64,' + res.data.img
						that.show = true
					}
				}).catch(err => {

				})
			},

获取

通过二维码进入页面,会获取到scene,并记录下来。

onLoad(e) {
			var that = this;
			// 分享小程序码scene记录用于注册使用
			if (e.scene) {
				uni.setStorageSync('qpId', e.scene)
			}
		},

注册

用户注册的时候,会将scene传给接口

login() {
				var that = this;
				var qpId = uni.getStorageSync('qpId') ? uni.getStorageSync('qpId') : 1
				useraUser({
					"encryptedData": that.encryptedData2,
					"iv": that.iv2,
					"nickName": that.nickName,
					"qpId": qpId,
					"pic": that.pic,
					"sex": that.sex,
					"sessionKey": that.sessionKey,
					"unionId": that.unionId,
					"waOpenId": that.waOpenId
				}).then(res => {
					if (res.code == 200) {
						if (res.data.id) {
							uni.showToast({
								title: '注册成功',
								icon: 'none'
							})
							uni.reLaunch({
								url: '/pages/home/home'
							})
						} else {}
					}
				}).catch(err => {

				})
			},
喜欢