【声明】关于六久阁私自出售我公司dedecms小程序插件声明
发布时间:2023-09-11 08:21:33查看:0授权登录member 
接口名称:用户授权登录
接口标识:member
接口url:https://你的网站/index.php?m=api&c=index&_ajax=1&a=member
接口参数
(1)type:'baidu'用户来源,必填;例:baidu、weixin、douyin
(2)其他相关参数比如:code、data、iv等(具体请参考demo)

小程序代码:
  1. getUserInfo: function (e) { 
  2.         wx.getUserProfile({ 
  3.             desc: '用于完善会员资料'// 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 
  4.             success: (e) => { 
  5.                 console.log(e) 
  6.                 wx.login({ 
  7.                     success: (res) => { 
  8.                         var code = res.code; //返回code 
  9.                         console.log(code) 
  10.                         wx.request({ 
  11.                             url: app.globalData.api+"member"
  12.                             data: { 
  13.                                 'type''weixin'
  14.                                 "code": code, 
  15.                                 "encryptedData": e.encryptedData, 
  16.                                 "iv": e.iv, 
  17.                                 "signature": e.signature, 
  18.                                 "rawData": e.rawData, 
  19.                                 'aid': app.globalData.aid 
  20.                             }, 
  21.                             method: 'POST'
  22.                             header: { 
  23.                                 'content-type''application/x-www-form-urlencoded'// 默认值  
  24.                             }, 
  25.                             success: function (res2) { 
  26.                                 if(res2.data.code == 200){ 
  27.                                     let data = res2.data.data; 
  28.                                     wx.setStorageSync('userInfo', data); 
  29.                                     wx.showToast({ 
  30.                                         title: '授权成功!!'
  31.                                         icon: 'success'
  32.                                         duration: 1500, 
  33.                                         success: function () { 
  34.                                             wx.switchTab({ 
  35.                                                 url: '/pages/member/index/index'
  36.                                             }) 
  37.                                         } 
  38.                                     }) 
  39.                                 }else
  40.                                     wx.showToast({ 
  41.                                         title: '授权失败!!'
  42.                                         icon: 'fail'
  43.                                         duration: 1500, 
  44.                                         success: function () { 
  45.                                              
  46.                                         } 
  47.                                     }) 
  48.                                 } 
  49.                             } 
  50.                         }) 
  51.                     } 
  52.                 }) 
  53.             }, 
  54.             fail:(e)=>{ 
  55.                 console.log(e) 
  56.             } 
  57.         }) 
  58.     }, 
注意:
(1)由于官方接口权限收回,可能部分用户无法获取用户头像和昵称
(2)由于用户名不能重复,重复的用户名会自动添加随机数字


版权声明:本文为原创文章,未经允许不得转载。https://doc.tengcee.com/eyoucms/eyouapi/275.html

服务热线

15137100750

我知道你不会打


但是我还是要写


你懂得!

微信二维码

QQ群二维码