商家邀请码bug相关

This commit is contained in:
BAKEYi 2026-04-29 16:06:33 +08:00
parent 8aed4815fd
commit 46e0975e89
1 changed files with 346 additions and 56 deletions

View File

@ -6,6 +6,29 @@
<text>门店信息</text>
</view>
<!-- 邀请码确认弹窗 -->
<uni-popup ref="existingInvitePopup" type="center" :mask-click="false">
<view class="invite-popup-content">
<view class="invite-popup-header">
<text class="invite-popup-title">请确认邀请信息</text>
</view>
<view class="invite-popup-body">
<view class="invite-item">
<text class="invite-label">邀请码</text>
<text class="invite-value">{{ existingInviterInfo && existingInviterInfo.invite_code }}</text>
</view>
<view class="invite-item">
<text class="invite-label">邀请人</text>
<text class="invite-value">{{ (existingInviterInfo && (existingInviterInfo.name || existingInviterInfo.nick_name)) || '' }}</text>
</view>
</view>
<view class="invite-popup-footer">
<view class="invite-btn cancel" @click="hideExistingInviteTipPopup">关闭</view>
<view class="invite-btn confirm" @click="useExistingInviteCode">确认</view>
</view>
</view>
</uni-popup>
<!-- 店铺logo -->
<view class="form-item box-cont">
<view class="label-wrapper">
@ -100,6 +123,7 @@
</view>
<input type="text" v-model="formData.invite_code_other" placeholder="请输入邀请码"
placeholder-class="placeholder" class="input"
:disabled="hasExistingInviter"
@input="handleInviteCodeInput" />
</view>
@ -351,6 +375,7 @@ export default {
tipImage: '',
currentTipType: '',
userId: null,
userMobile: null, //
identity: 2,
tipImagesPreloaded: false,
tipPopupBg: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/ab410a5d-5819-47f2-a0fc-3fd6b90d6770',
@ -361,6 +386,11 @@ export default {
inviterInfo: null,
currentValidatingCode: '',
//
existingInviterInfo: null,
hasExistingInviter: false, //
hasAutoReplacedInvite: false, //
fromAddressPage: false,
addressListener: null,
@ -411,8 +441,9 @@ export default {
uni.$off('address-selected-for-sj');
},
mounted() {
this.getUserInfo();
async mounted() {
//
await this.getUserInfo();
this.preloadTipImages();
this.locatinCitys = this.ChinaCitys[0].citys;
@ -433,7 +464,11 @@ export default {
this.setupAddressListener();
if (this.formData.invite_code_other) {
// 使
await this.forceUseExistingInviter();
//
if (!this.hasAutoReplacedInvite && this.formData.invite_code_other) {
this.validateInviteCode(this.formData.invite_code_other);
}
},
@ -447,6 +482,21 @@ export default {
onShow() {
this.checkAddressData();
//
if (this.hasAutoReplacedInvite) {
const localData = this.loadFormDataFromLocal();
if (localData) {
const { invite_code_other, ...otherData } = localData;
Object.keys(otherData).forEach(key => {
if (this.formData[key] !== undefined && key !== 'invite_code_other') {
this.formData[key] = otherData[key];
}
});
this.restoreServiceSkillsSelection();
this.updateSelectedServicesTextImmediately();
}
} else {
//
const localData = this.loadFormDataFromLocal();
if (localData) {
Object.assign(this.formData, localData);
@ -470,7 +520,6 @@ export default {
const experiences = ['实习', '1-3年', '3-5年', '5-10年', '10年以上'];
this.experienceText = experiences[this.formData.major - 1] || '';
}
}
//
@ -482,6 +531,7 @@ export default {
if (this.formData.invite_code_other) {
this.validateInviteCode(this.formData.invite_code_other);
}
}
},
onHide() {
@ -493,7 +543,137 @@ export default {
},
methods: {
//
// ========== 使 ==========
async forceUseExistingInviter() {
if (this.hasAutoReplacedInvite) return false;
//
if (!this.userMobile) {
console.log('用户手机号未获取,跳过强制替换');
return false;
}
try {
// 1.
const res = await request.post('/sj/User/getBInviteCode', {
account: this.userMobile,
type: 2 // 2=
});
console.log('查询已有邀请码结果:', res);
if (res && res.code === 200 && res.data) {
// invite_code invite_code_other
const oldInviteCode = res.data.invite_code || res.data.invite_code_other;
if (oldInviteCode) {
console.log('检测到已绑定邀请码:', oldInviteCode);
// 2.
const inviteRes = await request.post('/user/user/getInvite', {
invite_code: oldInviteCode
});
console.log('获取邀请人信息结果:', inviteRes);
if (inviteRes && inviteRes.code === 200 && inviteRes.data && inviteRes.data.account) {
const fullInviterInfo = inviteRes.data;
//
this.formData.invite_code_other = oldInviteCode;
this.hasExistingInviter = true; //
this.hasAutoReplacedInvite = true;
this.inviteCodeError = false;
this.inviterInfo = fullInviterInfo;
this.currentValidatingCode = oldInviteCode;
this.existingInviterInfo = fullInviterInfo;
//
this.saveInviteStateToLocal();
this.saveFormDataToLocal();
//
this.showExistingInviteTipPopup();
return true;
} else {
console.error('获取邀请人信息失败,邀请码可能无效');
}
} else {
console.log('接口返回成功但无邀请码数据');
}
} else {
console.log('查询已有邀请码接口异常:', res?.msg);
}
} catch (error) {
console.error('强制替换邀请人失败:', error);
}
return false;
},
//
showExistingInviteTipPopup() {
if (this.$refs.existingInvitePopup) {
this.$refs.existingInvitePopup.open();
} else {
uni.showModal({
title: '请确认邀请信息',
content: `邀请码:${this.existingInviterInfo?.invite_code}\n邀请人${this.existingInviterInfo?.name || this.existingInviterInfo?.nick_name}`,
confirmText: '确认',
cancelText: '关闭',
success: (res) => {
if (res.confirm) {
this.useExistingInviteCode();
} else {
//
this.formData.invite_code_other = '';
this.hasExistingInviter = false;
this.hasAutoReplacedInvite = false;
this.inviterInfo = null;
this.existingInviterInfo = null;
this.saveFormDataToLocal();
}
}
});
}
},
// 使
useExistingInviteCode() {
if (this.existingInviterInfo) {
//
const inviteState = {
inviterInfo: this.existingInviterInfo,
inviteCodeError: false,
currentValidatingCode: this.existingInviterInfo.invite_code
};
uni.setStorageSync('store_invite_state', inviteState);
this.saveFormDataToLocal();
}
this.hideExistingInviteTipPopup();
},
//
hideExistingInviteTipPopup() {
if (this.$refs.existingInvitePopup) {
this.$refs.existingInvitePopup.close();
}
},
//
getUserInfo() {
return request.post('/sj/User/getUser').then(result => {
this.userId = result.data.id;
//
this.userMobile = result.data.mobile || result.data.account;
if (this.userMobile) {
getApp().globalData.userMobile = this.userMobile;
}
console.log('用户ID获取成功:', this.userId, '手机号:', this.userMobile);
}).catch(err => {
console.error('获取用户信息失败:', err);
});
},
//
loadInviteStateFromLocal() {
try {
@ -562,6 +742,7 @@ export default {
console.log('保存邀请码验证状态失败:', e);
}
},
//
triggerInviteErrorShake() {
//
@ -606,6 +787,13 @@ export default {
//
handleInviteCodeInput(e) {
//
if (this.hasAutoReplacedInvite) {
console.log('已强制使用原邀请人,禁止修改邀请码');
this.formData.invite_code_other = this.inviterInfo ? this.inviterInfo.invite_code : '';
return;
}
const code = e.detail ? e.detail.value : this.formData.invite_code_other;
console.log('邀请码输入:', code);
@ -794,7 +982,6 @@ export default {
}
},
//
loadFormDataFromLocal() {
try {
@ -878,6 +1065,23 @@ export default {
}
},
// onShow
updateSelectedServicesTextImmediately() {
//
this.updateSelectedServicesText();
//
if (this.formData.apply_state) {
const methods = ['朋友圈', '抖音', '地推', '朋友介绍', '微博'];
this.messageMethodText = methods[this.formData.apply_state - 1] || '';
}
//
if (this.formData.major) {
const experiences = ['实习', '1-3年', '3-5年', '5-10年', '10年以上'];
this.experienceText = experiences[this.formData.major - 1] || '';
}
},
//
@ -965,7 +1169,6 @@ export default {
this.$forceUpdate()
},
//
checkGlobalData() {
if (getApp().globalData.storeInfoData) {
@ -976,7 +1179,7 @@ export default {
}
},
//
// serviceList
updateSelectedServicesText() {
if (this.formData.servers_kill && this.formData.servers_kill.length > 0 && this.serviceList.length > 0) {
const selectedServices = this.serviceList
@ -989,12 +1192,8 @@ export default {
}
},
//
getUserInfo() {
request.post('/sj/User/getUser').then(result => {
this.userId = result.data.id;
})
},
//
// getUserInfo()
getFormData() {
return this.formData;
@ -1510,6 +1709,7 @@ export default {
}
</script>
<style scoped>
.store-info-page {
/* padding: 28rpx 0; */
@ -2073,4 +2273,94 @@ export default {
.tip-btn .btn-text {
color: inherit;
}
/* 邀请码确认弹窗样式 */
.invite-popup-content {
width: 571rpx;
height: 535rpx;
background-image: url('https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/6f130301-f3df-467c-8a1c-dc49f85e5295.png');
background-size: cover;
background-position: center;
border-radius: 30rpx;
display: flex;
flex-direction: column;
align-items: center;
padding: 40rpx;
box-sizing: border-box;
}
.invite-popup-header {
width: 100%;
text-align: center;
margin-bottom: 40rpx;
}
.invite-popup-title {
font-size: 36rpx;
font-weight: 500;
color: #333333;
}
.invite-popup-body {
flex: 1;
width: 100%;
display: flex;
flex-direction: column;
gap: 24rpx;
}
.invite-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx;
background-color: rgba(255, 255, 255, 0.9);
border-radius: 16rpx;
}
.invite-label {
font-size: 28rpx;
color: #666666;
}
.invite-value {
font-size: 28rpx;
color: #333333;
font-weight: 500;
}
.invite-popup-footer {
width: 100%;
display: flex;
gap: 20rpx;
margin-top: 40rpx;
}
.invite-btn {
flex: 1;
height: 88rpx;
border-radius: 44rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
font-weight: 500;
}
.invite-btn.cancel {
background-color: #FFFFFF;
color: #FC437C;
border: 2rpx solid #FC437C;
}
.invite-btn.confirm {
background: linear-gradient(90deg, #FC437C 0%, #FF618F 100%);
color: #FFFFFF;
}
/* 输入框禁用样式 */
.input:disabled {
color: #999999;
background-color: #F5F5F5;
}
</style>