Merge branch 'mrr_sj_develop_丁杰_20260413_pricer' of https://gitee.com/qtvbidt/mrr.sj.front into mrr_sj_develop_丁杰_20260413_pricer
This commit is contained in:
commit
54cb3b744d
|
|
@ -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>
|
||||
Loading…
Reference in New Issue