1 Star 0 Fork 0

Ls-piao/zk-h5-202305

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
App.vue 1.97 KB
一键复制 编辑 原始数据 按行查看 历史
wangpeng 提交于 2023-06-13 18:13 . 123
<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>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/Ls-piao/zk-h5-202305.git
git@gitee.com:Ls-piao/zk-h5-202305.git
Ls-piao
zk-h5-202305
zk-h5-202305
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385