有用户反馈追格小程序绑定手机号提示缺少参数,追格技术同学检查代码并无异常,可能还是配置问题。
查阅了一下微信小程序官网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');
}
-
追格小程序登录提示"授权失败"的解决办法近期追格小程序客户反馈,说追格小程序登录提示"授权失败",这种情况一般都是appid未设置导致,不妨按下面方式检查一下。
-
追格资讯小程序开源版优化收藏功能修复收藏数量不准确的问题
-
追格企业官网小程序优化意见反馈追格企业官网小程序优化意见反馈
-
追格小程序用户隐私保护设置教程追格小程序是一个积木式小程序搭建框架,基于Uniapp+WordPress开发的微信小程序,代码免费开源不加密且支持二开,安装追格相应扩展模块(模块支持按需购买),简单配置即可快速搭建不限于圈子社区、知识付费、活动报名、资讯等类型小程序。
-
追格小程序V1.8.5更新发布@好友模块与隐私协议接口追格小程序是一个积木式小程序搭建框架,基于Uniapp+WordPress开发的微信小程序,代码免费开源不加密且支持二开,安装追格相应扩展模块(模块支持按需购买),简单配置即可快速搭建不限于圈子社区、知识付费、活动报名、资讯等类型小程序。
-
追格小程序全部产品都已添加隐私弹框为什么不在微信小程序SDK中弹出隐私弹框
暂无评论,抢个沙发...