fix: preserve channel code params for miniapp signup
This commit is contained in:
@@ -122,7 +122,7 @@ class RoutineServices extends BaseServices
|
|||||||
$wechatInfo['spread_code'] = $spread_code;
|
$wechatInfo['spread_code'] = $spread_code;
|
||||||
$wechatInfo['session_key'] = $userInfoConfig['session_key'] ?? '';
|
$wechatInfo['session_key'] = $userInfoConfig['session_key'] ?? '';
|
||||||
$wechatInfo['phone'] = $phone;
|
$wechatInfo['phone'] = $phone;
|
||||||
$createData = [$openid, $wechatInfo, $spread_uid, 'routine', 'routine'];
|
[$openid, $wechatInfo, $spread_uid, $login_type, $userType] = $createData = $this->routineOauth($wechatInfo);
|
||||||
}
|
}
|
||||||
/** @var WechatUserServices $wechatUserServices */
|
/** @var WechatUserServices $wechatUserServices */
|
||||||
$wechatUserServices = app()->make(WechatUserServices::class);
|
$wechatUserServices = app()->make(WechatUserServices::class);
|
||||||
@@ -268,20 +268,44 @@ class RoutineServices extends BaseServices
|
|||||||
$routineInfo['user_type'] = 'routine';//用户类型
|
$routineInfo['user_type'] = 'routine';//用户类型
|
||||||
$routineInfo['phone'] = $routine['phone'] ?? $routine['purePhoneNumber'] ?? '';
|
$routineInfo['phone'] = $routine['phone'] ?? $routine['purePhoneNumber'] ?? '';
|
||||||
$spread_uid = (int)($routine['spread_uid'] ?? 0);//绑定关系uid
|
$spread_uid = (int)($routine['spread_uid'] ?? 0);//绑定关系uid
|
||||||
if (!$spread_uid && isset($routine['spread_code']) && $routine['spread_code']) {
|
$routineInfo = $this->appendSpreadQrcodeInfo($routineInfo, $routine, $spread_uid);
|
||||||
//获取是否有扫码进小程序
|
if (!$spread_uid && isset($routineInfo['spread_uid'])) {
|
||||||
/** @var QrcodeServices $qrcode */
|
$spread_uid = (int)$routineInfo['spread_uid'];
|
||||||
$qrcode = app()->make(QrcodeServices::class);
|
|
||||||
$info = $qrcode->get((int)$routine['spread_code']);
|
|
||||||
if ($info) {
|
|
||||||
$spread_uid = $info['third_id'];
|
|
||||||
$routineInfo['spread_qrcode_id'] = (int)$info['id'];
|
|
||||||
$routineInfo['spread_qrcode_type'] = $info['third_type'] ?? '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return [$routine['openid'] ?? '', $routineInfo, $spread_uid, $routine['login_type'] ?? 'routine', 'routine'];
|
return [$routine['openid'] ?? '', $routineInfo, $spread_uid, $routine['login_type'] ?? 'routine', 'routine'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 尽量根据扫码参数补齐二维码信息,避免前端同时传 spread_uid / spread_code 时丢失渠道码来源。
|
||||||
|
*/
|
||||||
|
protected function appendSpreadQrcodeInfo(array $routineInfo, array $routine, int $spread_uid = 0): array
|
||||||
|
{
|
||||||
|
$spreadCode = (int)($routine['spread_code'] ?? 0);
|
||||||
|
if ($spreadCode <= 0) {
|
||||||
|
if ($spread_uid > 0) {
|
||||||
|
$routineInfo['spread_uid'] = $spread_uid;
|
||||||
|
}
|
||||||
|
return $routineInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var QrcodeServices $qrcode */
|
||||||
|
$qrcode = app()->make(QrcodeServices::class);
|
||||||
|
$info = $qrcode->get($spreadCode);
|
||||||
|
if (!$info) {
|
||||||
|
if ($spread_uid > 0) {
|
||||||
|
$routineInfo['spread_uid'] = $spread_uid;
|
||||||
|
}
|
||||||
|
return $routineInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
$qrcodeSpreadUid = (int)($info['third_id'] ?? 0);
|
||||||
|
$routineInfo['spread_qrcode_id'] = (int)($info['id'] ?? 0);
|
||||||
|
$routineInfo['spread_qrcode_type'] = $info['third_type'] ?? '';
|
||||||
|
$routineInfo['spread_uid'] = $qrcodeSpreadUid ?: $spread_uid;
|
||||||
|
|
||||||
|
return $routineInfo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取返回信息
|
* 获取返回信息
|
||||||
* @param $user
|
* @param $user
|
||||||
|
|||||||
@@ -44,6 +44,9 @@
|
|||||||
this.$Cache.set('spread', queryData.query.spid);
|
this.$Cache.set('spread', queryData.query.spid);
|
||||||
this.globalData.spid = queryData.query.spid;
|
this.globalData.spid = queryData.query.spid;
|
||||||
this.globalData.pid = queryData.query.spid;
|
this.globalData.pid = queryData.query.spid;
|
||||||
|
if (queryData.query.id) {
|
||||||
|
this.globalData.code = queryData.query.id;
|
||||||
|
}
|
||||||
silenceBindingSpread(this.globalData);
|
silenceBindingSpread(this.globalData);
|
||||||
}
|
}
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
@@ -53,6 +56,9 @@
|
|||||||
this.$Cache.set('spread', param.spid);
|
this.$Cache.set('spread', param.spid);
|
||||||
this.globalData.spid = param.spid;
|
this.globalData.spid = param.spid;
|
||||||
}
|
}
|
||||||
|
if (param.id) {
|
||||||
|
this.globalData.code = param.id;
|
||||||
|
}
|
||||||
/** 直播间分享**/
|
/** 直播间分享**/
|
||||||
// const sceneList = [1007, 1008, 1014, 1044, 1045, 1046, 1047, 1048, 1049, 1073, 1154, 1155];
|
// const sceneList = [1007, 1008, 1014, 1044, 1045, 1046, 1047, 1048, 1049, 1073, 1154, 1155];
|
||||||
// if (sceneList.includes(queryData.query.scene)) {
|
// if (sceneList.includes(queryData.query.scene)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user