您现在的位置是:首页  > 后端  > PHP PHP

微擎人人商城小程序版登陆错误 以及 首页打开控制台持续报错解决方法

2021-09-08【PHP】2311人已围观

简介微擎人人商城小程序版登陆错误 以及 首页打开控制台持续报错解决方法

微擎人人商城小程序版登陆错误

说明

2021年4月28日24时后发布的小程序新版本,无法通过wx.getUserInfo与获取用户个人信息(头像、昵称、性别与地区),将直接获取匿名数据(包括userInfo与encryptedData中的用户个人信息),获取加密后的openID与unionID数据的能力不做调整。此前发布的小程序版本不受影响,但如果要进行版本更新则需要进行适配。

第一步:修改 pages\auth\index.wxml 立即登录按钮改为

  1. <button bindtap="getUserProfile" class="authBtn" lang="zh_CN">
  2. 立即登录
  3. </button>

第二步:修改 pages\auth\index.js 增加 getUserProfile 方法

  1. getUserProfile() {
  2. wx.getUserProfile({
  3. desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  4. success: (res) => {
  5. // console.log("获取用户信息成功", res);
  6. // return;
  7. wx.showLoading({
  8. title: "加载中"
  9. }), wx.login({
  10. success: function (t) {
  11. // console.log(t);
  12. // return;
  13. n.post("wxapp/login", {
  14. code: t.code
  15. }, function (t) {
  16. // console.log(t.openid);
  17. // return;
  18. t.error ? n.alert("获取用户登录态失败:" + t.message) : n.get("wxapp/auth", {
  19. data: res.encryptedData,
  20. iv: res.iv,
  21. sessionKey: t.session_key,
  22. openId: t.openid
  23. }, function (n) {
  24. 1 == n.isblack && wx.showModal({
  25. title: "无法访问",
  26. content: "您在商城的黑名单中,无权访问!",
  27. success: function (n) {
  28. n.confirm && e.close(), n.cancel && e.close();
  29. }
  30. }), res.userInfo.openid = n.openId, res.userInfo.id = n.id, res.userInfo.uniacid = n.uniacid,
  31. e.setCache("userinfo", res.userInfo), e.setCache("userinfo_openid", res.userInfo.openid),
  32. e.setCache("userinfo_id", n.id), e.getSet(), wx.navigateBack({
  33. changed: !0
  34. });
  35. });
  36. });
  37. },
  38. fail: function () {
  39. n.alert("获取用户信息失败!");
  40. },
  41. complete: function () {
  42. wx.hideLoading();
  43. }
  44. });
  45. },
  46. fail: res => {
  47. // console.log("获取用户信息失败", res)
  48. n.alert("获取用户信息失败!");
  49. }
  50. })
  51. },

第三部修改登录接口文件 addons\ewei_shopv2\plugin\app\core\mobile\wxapp.php

由于getUserProfile本身就是不返回openid的,需要openid用login接口

  1. // auth() 方法下面增加
  2. $data["openId"] = $_GPC['openId'];

注意:如果该账号在没有修改之前有登陆,需要到后台[会员管理]删除这个账号,不然用这个账号测试时,还是报错获取不到数据。


首页打开控制台持续报错解决方法

removeTabBarBadge:fail not TabBar page

解决方法

  • 有人说删除 index: e
  • 我是直接删除 wx.removeTabBarBadge 方法

修改对比


关注博客,更多精彩分享,敬请期待!
 

Tags: 微擎  

很赞哦! (0)

我的名片

网名:随心

职业:PHP程序员

现居:湖北省-武汉市

Email:704061912@qq.com