代码拉取完成,页面将自动刷新
<script>
export default {
onLaunch: function() {
this.getUser()
// uni.setStorageSync('user', {
// "UserID": 3,
// "OpenID": "oF0KA6dP5OuOZSsnpKgh4Hxzlbo0",
// "UserName": "钒钒",
// "HeaderUrl": "https://thirdwx.qlogo.cn/mmopen/vi_32/D2XevEHZeaictpcR1Gacewtr2g5nRgSnKB821aR5vDKooFGOIVs6GJLU9qFibibeWibdd3KibpskswhdrocIPubpNwA/132",
// "IsRenZheng": true,
// "ZhanShangInfo": {
// "ZhangShangID": 289,
// "ZhangShangName": "测试商家",
// "Content": null,
// "ZhangShangLoge": "@/upload/images/2023/5/t_a8e7b352dde86a8a.jpg",
// "ZhangShangSeat": "E12",
// "ImageUrl": null
// }
// })
},
onShow: function() {
},
onHide: function() {
},
methods: {
async getUser() {
// let openid = uni.getStorageSync('openid')
// if (!openid) {
let code = await this.$api.getCode()
let res = await this.$api.getOpenId({
code
})
uni.setStorageSync('openid', res.UserData.openid)
uni.setStorageSync('access_token', res.UserData.access_token)
let isResgist = await this.$api.isRegist({
openid: res.UserData.openid
})
if (isResgist.UserData) {
// 一注册
uni.setStorageSync('user', isResgist.UserData)
} else {
// 未注册
let user = await this.$api.getUserInfo({
openid: res.UserData.openid,
accessToken: res.UserData.access_token
})
await this.$api.regist({
OpenId: res.UserData.openid,
HeadUrl: user.UserData.headimgurl,
UserName: user.UserData.nickname
})
let userInfo = await this.$api.isRegist({
openid: res.UserData.openid
})
uni.setStorageSync('user', userInfo.UserData)
}
}
// }
}
}
</script>
<style lang="scss">
/*每个页面公共css */
@import "@/uni_modules/uview-ui/index.scss";
@import "common/demo.scss";
.u-row {
width: 100% !important;
}
.uni-flex {
display: flex;
}
</style>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。