出售本站【域名】【外链】

uniapp 抖音小程序登录

<ZZZiew> <ZZZiew> <ZZZiew data-eZZZentsync="true"> <ZZZiew>号码管家</ZZZiew> </ZZZiew> <ZZZiew data-eZZZentsync="true" @click="getUserProfile">抖音授权登录</ZZZiew> </ZZZiew> </ZZZiew> //data-eZZZentsync="true" 须要再点击变乱标签上配置,如有父级,父级也须要上 eVport default { data() { return { code: '', anonymous_code: '', } }, methods: { async getUserProfile() { let that = this let obj = {} uni.login({ //uni,tt 都止 force: true, proZZZider: 'toutiao', success: function(loginRes) { console.log(loginRes)//获与code that.code = loginRes.code that.anonymous_code = loginRes.anonymousCode } }) uni.getUserProfile({ success: (res) => { if (that.code) { obj = { //组拆靠山登录接口所需数据 code: that.code, nickname: res.userInfo.nickName, headimgurl: res.userInfo.aZZZatarUrl } } uni.setStorageSync('authInfo', res.userInfo); if (res) { that.loginF(obj)//挪用登录接口 } }, fail: (err) => { console.log('err', err); uni.showModal({ title: '提示', content: JSON.stringify(err), success: function(res) { if (res.confirm) { } else if (res.cancel) { } } }); } }) }, async loginF(obj) { //登录接口 ZZZar res = await this.$post("接口地址", obj); if (res.errcode != 0) { this.$toast(res.errmsg); return; } this.$toast('登陆乐成'); this.$store.set('jwt', res.data.jwt); //将token存到缓存里 setTimeout(() => { uni.switchTab({ url: '登陆乐成后跳转的页面' }) }, 1000) } } }

2024-08-19 00:19  阅读:8