diff --git a/pages/ruzhu/sj-info.vue b/pages/ruzhu/sj-info.vue
index 39037df..449e093 100644
--- a/pages/ruzhu/sj-info.vue
+++ b/pages/ruzhu/sj-info.vue
@@ -6,6 +6,29 @@
门店信息
+
+
+
+
+
@@ -100,6 +123,7 @@
@@ -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,40 +482,55 @@ export default {
onShow() {
this.checkAddressData();
- const localData = this.loadFormDataFromLocal();
- if (localData) {
- Object.assign(this.formData, localData);
-
- // 立即更新显示文本(即使在 serviceList 加载完成前)
- this.updateSelectedServicesTextImmediately();
-
- // 恢复服务技能的选中状态
- if (this.serviceList.length > 0) {
+ // 如果已自动替换,避免被本地存储覆盖(只恢复非邀请码字段)
+ 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);
+
+ // 立即更新显示文本(即使在 serviceList 加载完成前)
+ this.updateSelectedServicesTextImmediately();
+
+ // 恢复服务技能的选中状态
+ if (this.serviceList.length > 0) {
+ this.restoreServiceSkillsSelection();
+ }
+
+ // 恢复获取消息方式的显示文本
+ 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] || '';
+ }
+ }
+
+ // 重新从本地存储加载邀请码验证状态
+ this.loadInviteStateFromLocal();
- // 恢复获取消息方式的显示文本
- if (this.formData.apply_state) {
- const methods = ['朋友圈', '抖音', '地推', '朋友介绍', '微博'];
- this.messageMethodText = methods[this.formData.apply_state - 1] || '';
+ this.checkGlobalData();
+
+ // 邀请码验证
+ if (this.formData.invite_code_other) {
+ this.validateInviteCode(this.formData.invite_code_other);
}
-
- // 恢复专业经验的显示文本
- if (this.formData.major) {
- const experiences = ['实习', '1-3年', '3-5年', '5-10年', '10年以上'];
- this.experienceText = experiences[this.formData.major - 1] || '';
- }
-
- }
-
- // 重新从本地存储加载邀请码验证状态
- this.loadInviteStateFromLocal();
-
- this.checkGlobalData();
-
- // 邀请码验证
- if (this.formData.invite_code_other) {
- this.validateInviteCode(this.formData.invite_code_other);
}
},
@@ -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);
@@ -702,7 +890,7 @@ export default {
},
// 验证邀请码
- async validateInviteCode(code) {
+ async validateInviteCode(code) {
console.log('开始验证邀请码:', code);
// 特殊邀请码13131313直接通过
@@ -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;
@@ -1059,20 +1258,20 @@ export default {
this.tipTitle = tipConfig[field].title;
this.tipImage = tipConfig[field].image;
// 等待图片预加载完成后再显示弹窗
- if (this.tipImagesPreloaded) {
- this.showTipPopupFlag = true;
- } else {
- // 如果图片还没预加载完成,立即加载当前图片
- console.log('图片还未预加载完成,立即加载当前图片');
- this.loadImage(this.tipImage).then(() => {
+ if (this.tipImagesPreloaded) {
this.showTipPopupFlag = true;
- }).catch(() => {
- // 即使加载失败也显示弹窗,避免用户无法操作
- this.showTipPopupFlag = true;
- });
+ } else {
+ // 如果图片还没预加载完成,立即加载当前图片
+ console.log('图片还未预加载完成,立即加载当前图片');
+ this.loadImage(this.tipImage).then(() => {
+ this.showTipPopupFlag = true;
+ }).catch(() => {
+ // 即使加载失败也显示弹窗,避免用户无法操作
+ this.showTipPopupFlag = true;
+ });
+ }
}
- }
- },
+ },
// 隐藏提示弹窗
hideTipPopup() {
@@ -1510,6 +1709,7 @@ export default {
}
+
\ No newline at end of file