流程:登录注册功能, 通过uni. getUserProfile获取wxcode, 通过wxcode传给后端获取openid, sessionkey, unionid。
通过< u- button type= "success" open- type= "getPhoneNumber" @getphonenumber= "decryptPhoneNumber" > 一键登录< / u- button> ,
传到后端这些参数 :
'session_key' : $this . openidData. sessionKey,
'encryptedData' : e. detail. encryptedData,
'iv' : e. detail. iv
获取手机号,
再将手机号,unionid,openid传到后端进行登录
< template> < view class = "page" > < ! -- 自定义头部 navbar -- > < u- navbar back- icon- name= "arrow-left" title= " " : custom- back= "navbarBack" : background= "{ backgroundColor: 'rgba(0,0,0,0)' }" : border- bottom= "false" : is- back= "pageStatus != 'home'" > < / u- navbar> < ! -- logo -- > < view class = "logo-wrap" v- if = "pageStatus == 'home' || pageStatus == 'getWxRole'" > < image class = "logo" src= "xxxxxxxxxxxxxx/static/login/login_logo.png" > < / image> < view class = "app-name" > 欢迎登录< / view> < view class = "app-title" > 弘云艺术中心< / view> < / view> < ! -- 默认登录页面显示 -- > < view style= "width: 100%;" v- if = "pageStatus == 'home'" > < view class = "text-area" @click= "loginByWx" > 手机号快捷登录< / view> < / view> < ! -- 微信授权登录,获取用户信息 -- > < view style= "width: 100%;" v- if = "pageStatus == 'getWxRole'" > < view class = "info" > 为提供优质服务, 需要获取你的以下信息 : < / view> < view class = "public" > < view class = "public-dot" > < / view> < view class = "public-text" > 你的公开信息 ( 头像、昵称等) < / view> < / view> < view class = "text-enter" @click= "getWxLoginRole" > 授权进入< / view> < / view> < ! -- 微信登录小程序,再授权获取用户信息之后 -- > < view class = "loginWx" v- if = "pageStatus == 'loginByWx'" > < view class = "title" > 欢迎使用 弘云艺术中心< / view> < view class = "desc" > 立即登录享受优质服务< / view> < view class = "avatar" > < image mode= "aspectFill" : src= "wxLoginUserInfo.userInfo.avatarUrl" > < / image> < / view> < u- button type= "success" open- type= "getPhoneNumber" @getphonenumber= "decryptPhoneNumber" > 一键登录< / u- button> < / view> < ! -- 协议勾选 -- > < view class = "agree" v- if = "pageStatus == 'home' || pageStatus == 'getWxRole' " > < view class = "agree_img" @click= "changeAgreeFlag" v- show= "!agree_flag" > < image src= "xxxxxxxxxxx/static/mine/check.png" > < / image> < / view> < view class = "agree_img" @click= "changeAgreeFlag" v- show= "agree_flag" > < image src= "xxxxxxxxxxxxxxxxx/static/operate/checked.png" > < / image> < / view> < view class = "agree_text" > 登录代表您已同意< span> 《用户服务协议》《隐私权政策》< / span> < / view> < / view> < / view>
< / template> < script> import FunUniappTheme from '@/theme.scss'</