有用户反馈追格小程序绑定手机号提示缺少参数,追格技术同学检查代码并无异常,可能还是配置问题。
查阅了一下微信小程序官网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.3.0更新发布商家名片模块等功能追格小程序是一个积木式小程序搭建框架,基于Uniapp+WordPress开发的微信小程序,代码免费开源不加密且支持二开,安装追格相应扩展模块(模块支持按需购买),简单配置即可快速搭建不限于圈子社区、知识付费、活动报名、资讯等类型小程序。
-
微信评价组件:提示此插件已设置不可添加追格小程序全模块用户反馈,说微信评价组件:提示此插件已设置不可添加
-
追格小程序:积分商城发布产品报错,WordPress database error Table 'wp_zhuige_xcx_promotion_log' doesn't exist近期有追格小程序用户反馈,积分商城发布产品报错,大致提示如下:WordPress database error Table 'wp_zhuige_xcx_promotion_log' doesn't exist
-
追格小程序建圈、发帖、商城发布商品报错 Warning: Undefined variable $result in追格小程序建圈、发帖、商城发布商品报错Warning: Undefined variable $result in /www/wwwroot/xly/wp-content/plugins/zhuige-xcx/public/class-zhuige-xcx-public.php on line 159
-
【重要通知】追格小程序更新提示因uni组件更新,追格小程序部分模块样式出现异常。我们已定位问题并正优化中,给您带来不便敬请谅解。感谢支持与理解!追格团队将持续努力,优化产品体验,期待更快与您相见。
-
微信小程序打开任意公众号文章 wx.openOfficialAccountArticlewx.openOfficialAccountArticle是微信小程序通过小程序打开任意公众号文章api,不包括临时链接等异常状态下的公众号文章,必须有点击行为才能调用成功。
暂无评论,抢个沙发...