Commit 0820f3c8 authored by 肖健's avatar 肖健

小程序登录调整

parent 7c363b63
......@@ -53,6 +53,28 @@ export default {
title: '登录中...'
})
},
async wechatLogin() {
wx.login({
success: (res) => {
this.code = res.code
this.wechatSession(res.code)
}
})
},
//获取session_key
async wechatSession(code) {
let that = this
let param = {
code: code,
}
let opts = { url: '/xcx/code/session', method: 'post' }
await that.http.httpRequest(opts, param).then(res => {
if (res.data.code == 200) {
that.openid = res.data.data.openid
}
})
},
//解析手机号
getPhoneNumber(e) {
let that = this
......@@ -70,6 +92,7 @@ export default {
let param = {
code: detail.code,
openid : that.openid
}
let opts = { url: '/xcx/login', method: 'post' }
......@@ -106,6 +129,7 @@ export default {
}
},
onLoad() { //默认加载
this.wechatLogin()
let userToken = uni.getStorageSync('userToken')
if (userToken) {
let that = this
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment