有用户反馈追格小程序绑定手机号提示缺少参数,追格技术同学检查代码并无异常,可能还是配置问题。
查阅了一下微信小程序官网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');
}
-
追格小程序V2.2.0两大亮点来袭,你准备好了吗?追格小程序终于迎来了两大全新功能模块的华丽登场!它们分别是圈子(圈主)管理模块和付费推广模块。
-
一为导航主题(One Nav)和追格小程序冲突的解决方法近期有小伙伴反馈,在一为导航主题(One Nav)上面安装追格小程序后,报错如下
-
如何通过链接进入小程序如何通过链接进入小程序
-
应互联网信息内容主管部门要求,建议在[小程序开发者后台-管理-成员管理]处将手机号信息补充完整后再提交代码审核追格小程序交流群里,用户反馈小程序提交审核后被驳回,提示:应互联网信息内容主管部门要求,建议在[小程序开发者后台-管理-成员管理]处将手机号信息补充完整后再提交代码审核。
-
追格小程序“隐私设置”模块调价通知调整内容:感谢您一直以来对追格的关注和支持!随着开发维护等服务成本不断增加,经慎重考虑,现决定于2024年4月29日,将追格小程序“隐私设置”模块价格做以下调整:
-
追格小程序 V2.3.0更新发布商家名片模块等功能追格小程序是一个积木式小程序搭建框架,基于Uniapp+WordPress开发的微信小程序,代码免费开源不加密且支持二开,安装追格相应扩展模块(模块支持按需购买),简单配置即可快速搭建不限于圈子社区、知识付费、活动报名、资讯等类型小程序。
暂无评论,抢个沙发...