有用户反馈追格小程序绑定手机号提示缺少参数,追格技术同学检查代码并无异常,可能还是配置问题。
查阅了一下微信小程序官网API,根据微信提示,从基础库 2.21.2 开始,对获取手机号的接口进行了安全升级,旧版本接口目前可以继续使用,但建议开发者使用新版本接口,以增强小程序安全性。
虽旧版本不影响使用,本着负责与安全考虑,追格技术同学对接口做了升级,若有需求可参考如下流程操作,本接口将在追格小程序V1.7.0后的版本同步更新。
1、前端:/pages/user/login/login.vue
/**
* 获取手机号
*/
getPhoneNumber(e) {
Rest.post(Api.URL('user', 'set_mobile'), {
encrypted_data: e.detail.encryptedData,
iv: e.detail.iv,
code: this.code,
}).then(res => {
Alert.toast(res.message)
// 更新本地缓存的信息
let user = Auth.getUser();
user.mobile = res.data.mobile;
Auth.setUser(user);
uni.$emit('zhuige_event_user_mobile', {
mobile: res.data.mobile
});
Util.navigateBack();
})
}
}
}
</script>
【改成如下】
/**
* 获取手机号
*/
getPhoneNumber(e) {
if (e.detail.errMsg != 'getPhoneNumber:ok') {
Alert.toast(e.detail.errMsg)
return;
}
// Rest.post(Api.URL('user', 'set_mobile'), {
// encrypted_data: e.detail.encryptedData,
// iv: e.detail.iv,
// code: this.code,
// }).then(res => {
// Alert.toast(res.message)
// // 更新本地缓存的信息
// let user = Auth.getUser();
// user.mobile = res.data.mobile;
// Auth.setUser(user);
// uni.$emit('zhuige_event_user_mobile', {
// mobile: res.data.mobile
// });
// Util.navigateBack();
// })
Rest.post(Api.URL('user', 'set_mobile2'), {
code: e.detail.code
}).then(res => {
Alert.toast(res.message)
// 更新本地缓存的信息
let user = Auth.getUser();
user.mobile = res.data.mobile;
Auth.setUser(user);
uni.$emit('zhuige_event_user_mobile', {
mobile: res.data.mobile
});
Util.navigateBack();
})
}
}
}
</script>
2、后端/zhuige-xcx/public/rest/class-zhuige-xcx-user-controller.php
/**
* 设置手机号2
*/
public function set_mobile2($request)
{
$user_id = get_current_user_id();
$code = $this->param($request, 'code', '');
if (empty($code)) {
return $this->error('缺少参数');
}
$os = $this->param($request, 'os', '');
$mobile = '';
if ($os == 'wx') {
$wx_session = ZhuiGe_Xcx::get_wx_token();
if (!$wx_session) {
return $this->success(['acode' => ZHUIGE_XCX_BASE_URL . 'public/images/placeholder.jpg']);
}
} else {
return $this->error('暂不支持此平台');
}
【改成如下】
/**
* 设置手机号2
*/
public function set_mobile2($request)
{
$user_id = get_current_user_id();
$code = $this->param($request, 'code', '');
if (empty($code)) {
return $this->error('缺少参数');
}
$os = $this->param($request, 'os', '');
if ($os != 'wx') {
return $this->error('暂不支持此平台');
}
$wx_session = ZhuiGe_Xcx::get_wx_token();
if (!$wx_session) {
return $this->error('获取不到token');
}
-
追格付费推广模块内测中:新功能抢先看,敬请期待正式发布!追格付费推广模块,专为帖子和文章等内容付费推广设计,适用于小程序首页的醒目置顶推广。
-
WordPress是干什么的WordPress是一款开源的CMS,也就是常说的内容管理系统,它基于PHP开发,并使用MySQL作为数据库管理系统。
-
追格小程序V2.2.0两大亮点来袭,你准备好了吗?追格小程序终于迎来了两大全新功能模块的华丽登场!它们分别是圈子(圈主)管理模块和付费推广模块。
-
一为导航主题(One Nav)和追格小程序冲突的解决方法近期有小伙伴反馈,在一为导航主题(One Nav)上面安装追格小程序后,报错如下
-
如何通过链接进入小程序如何通过链接进入小程序
-
应互联网信息内容主管部门要求,建议在[小程序开发者后台-管理-成员管理]处将手机号信息补充完整后再提交代码审核追格小程序交流群里,用户反馈小程序提交审核后被驳回,提示:应互联网信息内容主管部门要求,建议在[小程序开发者后台-管理-成员管理]处将手机号信息补充完整后再提交代码审核。
暂无评论,抢个沙发...