mirror of
https://gitee.com/liuxioabin/fengketrade.git
synced 2026-04-17 12:57:32 +08:00
up
This commit is contained in:
parent
fe6cb4dcc9
commit
098e3dfafd
@ -6,7 +6,7 @@ use app\admin\model\shopro\user\User as UserModel;
|
||||
|
||||
class Invite extends Common
|
||||
{
|
||||
protected $noNeedLogin = ['validate'];
|
||||
protected $noNeedLogin = ['*'];
|
||||
protected $noNeedRight = ['*'];
|
||||
|
||||
/**
|
||||
@ -36,7 +36,7 @@ class Invite extends Common
|
||||
/**
|
||||
* 验证邀请码
|
||||
*/
|
||||
public function validate()
|
||||
public function checkCode()
|
||||
{
|
||||
$inviteCode = $this->request->param('invite_code', '');
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ async function onValidateInvite() {
|
||||
return;
|
||||
}
|
||||
|
||||
const { code: resCode } = await sheep.$api.invite.validate({ invite_code: code });
|
||||
const { code: resCode } = await sheep.$api.invite.checkCode({ invite_code: code });
|
||||
if (resCode === 1) {
|
||||
state.inviteValidated = true;
|
||||
sheep.$helper.toast('邀请码验证成功');
|
||||
@ -183,7 +183,7 @@ sheep.$api.invite.myCode()
|
||||
// 响应: { code: 1, data: { invite_code: "ABC123", invite_count: 5 } }
|
||||
|
||||
// 2. 验证邀请码
|
||||
sheep.$api.invite.validate({ invite_code: "ABC123" })
|
||||
sheep.$api.invite.checkCode({ invite_code: "ABC123" })
|
||||
// 响应: { code: 1, msg: "邀请码有效", data: { ... } }
|
||||
|
||||
// 3. 我邀请的用户列表
|
||||
@ -279,7 +279,18 @@ SELECT parent_user_id, invite_code_used FROM user WHERE id = 新用户ID;
|
||||
|
||||
## 🐛 常见问题
|
||||
|
||||
### 问题1: 邀请码输入框不显示
|
||||
### 问题1: 接口报"跨域"或500错误
|
||||
|
||||
**原因**:
|
||||
- 后端 `Invite::validate()` 方法与 `Api` 基类的 `validate()` 方法签名冲突
|
||||
- 导致 PHP Fatal Error: "Declaration of addons\shopro\controller\Invite::validate() must be compatible with..."
|
||||
|
||||
**解决方案**:
|
||||
- 已将后端方法名从 `validate()` 改为 `checkCode()`
|
||||
- 前端API调用从 `sheep.$api.invite.validate()` 改为 `sheep.$api.invite.checkCode()`
|
||||
- 接口路径从 `/invite/validate` 改为 `/invite/checkCode`
|
||||
|
||||
### 问题2: 邀请码输入框不显示
|
||||
|
||||
**检查**:
|
||||
```javascript
|
||||
@ -287,18 +298,18 @@ SELECT parent_user_id, invite_code_used FROM user WHERE id = 新用户ID;
|
||||
console.log(userInfo.parent_user_id); // 应为 null
|
||||
```
|
||||
|
||||
### 问题2: 验证失败
|
||||
### 问题3: 验证失败
|
||||
|
||||
**检查**:
|
||||
```bash
|
||||
# 查看API响应
|
||||
curl -X POST http://your-domain/invite/validate -d "invite_code=ABC123"
|
||||
curl -X POST http://your-domain/addons/shopro/invite/checkCode -d "invite_code=ABC123"
|
||||
|
||||
# 查看后端日志
|
||||
tail -f runtime/log/$(date +%Y%m)/$(date +%d).log | grep "邀请码"
|
||||
```
|
||||
|
||||
### 问题3: 个人中心不显示邀请码
|
||||
### 问题4: 个人中心不显示邀请码
|
||||
|
||||
**检查**:
|
||||
```javascript
|
||||
|
||||
@ -295,7 +295,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const { code: resCode, msg } = await sheep.$api.invite.validate({ invite_code: code });
|
||||
const { code: resCode, msg } = await sheep.$api.invite.checkCode({ invite_code: code });
|
||||
if (resCode === 1) {
|
||||
state.inviteCode = code;
|
||||
state.inviteValidated = true;
|
||||
|
||||
@ -9,9 +9,9 @@ export default {
|
||||
}),
|
||||
|
||||
// 验证邀请码
|
||||
validate: (data) =>
|
||||
checkCode: (data) =>
|
||||
request({
|
||||
url: 'invite/validate',
|
||||
url: 'invite/checkCode',
|
||||
method: 'POST',
|
||||
data,
|
||||
custom: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user