“最难不过坚持”
本人承接扒站仿站,php网站维护,病毒查杀,网站编辑,网站改版,html制作
有需要网站维护,改版,病毒查杀,网站编辑,网站备案,html制作等相关的工作可以联系我。
本人有多年相关工作经验,也可提供免费咨询,交个朋友。
有需要探讨问题的朋友,也可以加我微信,共同探讨!
微信:15011482830 QQ:408917339
- https://jueru.net/
-
评 留言
- :weixiao:
-
评 留言
- :shuijiao: :weiqu: :zhenbang: :leng:
-
评 留言
- :yiwen: :yiwen: :yiwen: :yiwen:
-
评 EasySass: could not generate CSS file. See Output panel for details.
- 这个业务逻辑多少都有点奇怪了,阅读浏览次数增值在新闻详情页的控制器方法里setInc,这怎么还写进模型事件里了。如果非要用onAfterRead也可以,把新闻文章的内容单独分出来一个news_content表,然后把它和news做关联,然后给news_content表的onAfterRead事件做增值处理,这样点进新闻页内查询到文章内容时才会触发它。
-
评 TP6模型事件-查询后onAfterRead不好用
小程序调试时,突然发现获取到的用户昵称变成“微信用户”和头像也非用户微信头像了,原因是微信小程序更新了接口wx.getUserProfile之后导致的
2021年4月28日24时后发布的小程序新版本,无法通过wx.getUserInfo与<button open-type="getUserInfo"/>获取用户个人信息(头像、昵称、性别与地区),将直接获取匿名数据(包括userInfo与encryptedData中的用户个人信息),获取加密后的openID与unionID数据的能力不做调整。此前发布的小程序版本不受影响,但如果要进行版本更新则需要进行适配。
官方文档https://developers.weixin.qq.com/community/develop/doc/000cacfa20ce88df04cb468bc52801
人人商城小程序用户授权登录失败,getUserProfile小程序登录接口升级
怎么修改呢?
1,修改pages\auth\index.wxml
立即登录按钮改为
<button bindtap="getUserProfile" class="authBtn" lang="zh_CN"> 立即登录 </button>
2,修改pages\auth\index.js
第62行添加代码
getUserProfile(){
wx.getUserProfile({
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
// console.log("获取用户信息成功", res);
// return;
wx.showLoading({
title: "加载中"
}), wx.login({
success: function(t) {
// console.log(t);
// return;
n.post("wxapp/login", {
code: t.code
}, function(t) {
// console.log(t.openid);
// return;
t.error ? n.alert("获取用户登录态失败:" + t.message) : n.get("wxapp/auth", {
data: res.encryptedData,
iv: res.iv,
sessionKey: t.session_key,
openId:t.openid
}, function(n) {
1 == n.isblack && wx.showModal({
title: "无法访问",
content: "您在商城的黑名单中,无权访问!",
success: function(n) {
n.confirm && e.close(), n.cancel && e.close();
}
}), res.userInfo.openid = n.openId, res.userInfo.id = n.id, res.userInfo.uniacid = n.uniacid,
e.setCache("userinfo", res.userInfo), e.setCache("userinfo_openid", res.userInfo.openid),
e.setCache("userinfo_id", n.id), e.getSet(), wx.navigateBack({
changed: !0
});
});
});
},
fail: function() {
n.alert("获取用户信息失败!");
},
complete: function() {
wx.hideLoading();
}
});
},
fail: res => {
// console.log("获取用户信息失败", res)
n.alert("获取用户信息失败!");
}
})
},
如图,新旧代码对比
3,修改登录接口文件addons\ewei_shopv2\plugin\app\core\mobile\wxapp.php
由于getUserProfile本身就是不返回openid的,需要openid用login接口
对应上面js的代码就是
接口文件第93行加上代码
$data['openId'] = $_GPC['openId'];
如图
其他不用动。
功能是实现了,不知道有没有其他问题。
参考
https://zhuanlan.zhihu.com/p/362032946
https://blog.csdn.net/weixin_45483107/article/details/115798042
https://blog.csdn.net/weixin_49295874/article/details/115618856?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-1&spm=1001.2101.3001.4242
2021-06-15 21:04:28
回复