Files
pupil/pages/my/login/login.vue
”chenxuelian“ 1a379ca8e9 登录
2022-12-27 19:29:16 +08:00

56 lines
1.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view>
<u-button type="primary" open-type="getPhoneNumber" size="medium" @getphonenumber="getphonenumber">
获取电话号码</u-button>
</view>
</template>
<script>
import {loginSys} from '@/service/request.js'
export default {
data() {
return {
}
},
methods: {
getphonenumber(e) {
const {
phoneCode
} = e.detail;
console.log("手机code : ", phoneCode);
uni.login({
"provider": "weixin",
"onlyAuthorize": true, // 微信登录仅请求授权认证
success: function(event) {
const {
code
} = event
console.log("登录code", code);
//客户端成功获取授权临时票据code,向业务服务器发起登录请求。
// 调用登录接口 拿到token 传手机code,更新手机号码
loginSys(code).then(res=>{
console.log(res);
//登录完成后使用手机code换取手机号,调用/user/getMobileByMnp接口
//接口详细链接 https://docs.apipost.cn/preview/468be606f65cae75/3f2f988ddf82dd8e
})
},
fail: function(err) {
// 登录授权失败
// err.code是错误码
}
})
},
}
}
</script>
<style>
</style>