微信登录完成
This commit is contained in:
parent
ae9d715bdd
commit
959450d588
|
@ -13,25 +13,40 @@
|
|||
/**
|
||||
* h5,app-plus(nvue下也为app-plus),mp-weixin,mp-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>
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue