微信登录完成

This commit is contained in:
caoqianming 2021-04-30 11:27:06 +08:00
parent ae9d715bdd
commit 959450d588
4 changed files with 39 additions and 24 deletions

View File

@ -13,25 +13,40 @@
/**
* h5app-plus(nvue下也为app-plus)mp-weixinmp-alipay......
*/
var that=this
//var that=this
// 小程序自动登录
uni.showLoading({
title:'微信自动登录中...',
mask: true
})
uni.login({
provider: 'weixin',
success: function (loginRes) {
that.$u.api.wxmplogin({code:loginRes.code}).then(res=>{
that.$u.vuex('vuex_token', res.data.access)
}).catch(e=>{uni.reLaunch({
success: (loginRes)=>{
this.$u.api.wxmplogin({code:loginRes.code}).then(res=>{
this.$u.vuex('vuex_token', res.data.access)
this.$u.api.getUserInfo().then(res=>{
uni.hideLoading()
uni.showToast({
title:"登录成功",
icon:"none"
})
uni.reLaunch({
url:"/pages/home/home"
})
this.$u.vuex('vuex_user', res.data)
})
}).catch(e=>{
uni.hideLoading()
uni.showToast({
title:"暂未绑定微信!",
icon:"none"
})
uni.reLaunch({
url:'/pages/login/login'
})})
}
});
// this.$u.api.getUserInfo().then(res=>{
// this.$u.vuex('vuex_user', res.data)
// }).catch(e=>{
// uni.reLaunch({
// url:'/pages/login/login'
// })
// })
},
}
</script>

View File

@ -11,6 +11,15 @@
// }]
// },
"pages": [
{
"path" : "pages/login/login",
"style" :
{
"navigationBarTitleText": "验证码登录",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/home/home",
"style" :
@ -28,15 +37,6 @@
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/login/login",
"style" :
{
"navigationBarTitleText": "验证码登录",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/login/login_password",

View File

@ -20,7 +20,7 @@
<u-form-item label="拍照取证">
<u-image
@click="imgListPreview(index)"
width="260rpx" height="260rpx" :src="item" v-for="(item, index) in fileList" v-bind:key="index" style="margin: 8rpx;"></u-image>
width="260rpx" height="260rpx" :src="item" v-for="(item, index) in fileList" v-bind:key="index" style="margin: 2rpx;"></u-image>
</u-form-item>
</u-form>

View File

@ -315,8 +315,8 @@ class UserViewSet(PageOrNot, ModelViewSet):
'perms': perms,
}
try:
user = UserThird.objects.get(user=user,type='wx_mp').user
data['wxmp_openid'] = user.openid
usert = UserThird.objects.get(user=user,type='wx_mp')
data['wxmp_openid'] = usert.openid
except:
pass
return Response(data)