|
|
@@ -315,7 +315,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { updateUserInfo, createFamily, directRegister, getUserInfo, requestJoinByCode, getMyMembership } from '../../utils/api.js'
|
|
|
+import { updateUserInfo, createFamily, directRegister, getUserInfo, requestJoinByCode, getMyMembership, bindReferral } from '../../utils/api.js'
|
|
|
import config from '@/config.js'
|
|
|
|
|
|
export default {
|
|
|
@@ -936,6 +936,25 @@ export default {
|
|
|
console.error('保存 mascot 失败', e)
|
|
|
}
|
|
|
}
|
|
|
+ // 新用户流程:消费分享者推荐码,绑定推荐人(非 team 类型)
|
|
|
+ // 登录页 completeLogin 在 needsRoleSelect=true 时直接跳本页,跳过了 handleReferralBind,
|
|
|
+ // 因此在此处统一消费 storage 中的 inviteCode,避免推荐人绑定丢失
|
|
|
+ var inviteCode = uni.getStorageSync('inviteCode')
|
|
|
+ var inviteType = uni.getStorageSync('inviteType')
|
|
|
+ if (inviteCode && inviteType !== 'team') {
|
|
|
+ var self = this
|
|
|
+ bindReferral(inviteCode).then(function(res) {
|
|
|
+ if (res && res.code === 200) {
|
|
|
+ console.log('新用户绑定推荐人成功', inviteCode)
|
|
|
+ } else if (res && res.code === 400) {
|
|
|
+ console.log('用户已有推荐人,跳过绑定')
|
|
|
+ }
|
|
|
+ }).catch(function(e) {
|
|
|
+ console.log('新用户绑定推荐人失败', e)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ uni.removeStorageSync('inviteCode')
|
|
|
+ uni.removeStorageSync('inviteType')
|
|
|
// 用 switchTab 跳转带底部 TabBar 的首页(行/身/智/心/富)
|
|
|
// parent-index/child-index 是分包页面(非 TabBar 页),用 navigateTo 会丢失底部 TabBar
|
|
|
uni.switchTab({ url: '/pages/index-home/index' })
|