邀请码确认弹窗

This commit is contained in:
BAKEYi 2026-06-02 15:02:18 +08:00
parent b03ffe7225
commit fc78b157a9
3 changed files with 1970 additions and 1675 deletions

View File

@ -197,6 +197,29 @@
</view> </view>
</view> </view>
</view> </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 || existingInviterInfo.invite_code_other) }}</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="cancelInviteConfirm">关闭</view>
<view class="invite-btn confirm" @click="useExistingInviteCode">确认</view>
</view>
</view>
</uni-popup>
</view> </view>
</template> </template>
@ -213,6 +236,7 @@ export default {
return { return {
userId: null, userId: null,
userMobile: null, //
formData: loadedData || { formData: loadedData || {
name: '', name: '',
contact_type: '1', contact_type: '1',
@ -250,6 +274,12 @@ export default {
inviterInfo: null, inviterInfo: null,
currentValidatingCode: '', currentValidatingCode: '',
inviteValidationTimer: null, inviteValidationTimer: null,
//
existingInviterInfo: null,
hasExistingInviter: false,
hasAutoReplacedInvite: false,
confirmResolve: null // saveFormData Promise resolve
} }
}, },
computed: { computed: {
@ -289,11 +319,21 @@ export default {
onShow() { onShow() {
const localData = this.loadFormDataFromLocal(); const localData = this.loadFormDataFromLocal();
if (localData) { if (localData) {
//
if (this.hasAutoReplacedInvite) {
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];
}
});
} else {
this.formData = { this.formData = {
...this.formData, ...this.formData,
...localData ...localData
}; };
} }
}
this.checkGlobalData(); this.checkGlobalData();
this.checkAddressData(); this.checkAddressData();
@ -318,11 +358,14 @@ export default {
} }
}, },
mounted() { async mounted() {
this.locatinCitys = this.ChinaCitys[0].citys; this.locatinCitys = this.ChinaCitys[0].citys;
this.locationAreas = this.locatinCitys[0].areas; this.locationAreas = this.locatinCitys[0].areas;
if (this.formData.invite_code_other) { //
await this.forceUseExistingInviter();
if (!this.hasAutoReplacedInvite && this.formData.invite_code_other) {
this.validateInviteCode(this.formData.invite_code_other); this.validateInviteCode(this.formData.invite_code_other);
} }
}, },
@ -332,6 +375,124 @@ export default {
}, },
methods: { methods: {
// 使
async forceUseExistingInviter() {
if (this.hasAutoReplacedInvite) return false;
//
if (!this.userMobile) {
await this.getUserInfo();
}
if (!this.userMobile) {
console.log('用户手机号未获取,跳过强制替换');
return false;
}
try {
// 1.
const res = await request.post('/sj/User/getBInviteCode', {
account: this.userMobile,
type: 2 //
});
if (res && (res.code === 200 || res.state === 1) && res.data) {
const oldInviteCode = res.data.invite_code || res.data.invite_code_other;
if (oldInviteCode) {
console.log('检测到已绑定邀请码:', oldInviteCode);
// 2.
const inviteRes = await request.post('/sj/user/getInvite', {
invite_code: oldInviteCode
});
if (inviteRes && (inviteRes.code === 200 || inviteRes.state === 1) && 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();
return true;
}
}
}
} catch (error) {
console.error('强制替换邀请人失败:', error);
}
return false;
},
//
showInviteConfirmPopup(inviterData) {
this.$nextTick(() => {
if (this.$refs.existingInvitePopup) {
this.existingInviterInfo = inviterData;
this.$refs.existingInvitePopup.open();
} else {
uni.showModal({
title: '请确认邀请信息',
content: `邀请码:${inviterData?.invite_code || inviterData?.invite_code_other}\n邀请人${inviterData?.name || inviterData?.nick_name}`,
confirmText: '确认',
cancelText: '取消',
success: (res) => {
if (res.confirm) {
this.useExistingInviteCode();
} else {
this.cancelInviteConfirm();
}
}
});
}
});
},
//
hideExistingInviteTipPopup() {
if (this.$refs.existingInvitePopup) {
this.$refs.existingInvitePopup.close();
}
},
// 使
useExistingInviteCode() {
if (this.existingInviterInfo) {
const inviteState = {
inviterInfo: this.existingInviterInfo,
inviteCodeError: false,
currentValidatingCode: this.existingInviterInfo.invite_code || this.existingInviterInfo.invite_code_other
};
uni.setStorageSync('store_invite_state', inviteState);
this.saveFormDataToLocal();
}
this.hideExistingInviteTipPopup();
// Promise
if (this.confirmResolve) {
this.confirmResolve(true);
this.confirmResolve = null;
}
},
// /
cancelInviteConfirm() {
this.hideExistingInviteTipPopup();
// Promise
if (this.confirmResolve) {
this.confirmResolve(false);
this.confirmResolve = null;
}
},
loadInviteStateFromLocal() { loadInviteStateFromLocal() {
try { try {
const inviteState = uni.getStorageSync('store_invite_state'); const inviteState = uni.getStorageSync('store_invite_state');
@ -447,6 +608,13 @@ export default {
// //
handleInviteCodeInput(e) { handleInviteCodeInput(e) {
//
if (this.hasAutoReplacedInvite) {
console.log('已强制使用原邀请人,禁止修改邀请码');
this.formData.invite_code_other = this.inviterInfo ? (this.inviterInfo.invite_code || this.inviterInfo.invite_code_other) : '';
return;
}
const code = e.detail ? e.detail.value : this.formData.invite_code_other; const code = e.detail ? e.detail.value : this.formData.invite_code_other;
console.log('邀请码输入:', code); console.log('邀请码输入:', code);
@ -590,7 +758,7 @@ export default {
try { try {
// //
const response = await request.post('/sj/user/getInvite', { const response = await request.post('/sj/user/getInvite', {
invite_code_other: code invite_code: code
}); });
console.log('邀请码验证响应:', response); console.log('邀请码验证响应:', response);
@ -696,10 +864,15 @@ export default {
}, },
getUserInfo() { getUserInfo() {
// data /使
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
request.post('/sj/user/getuser').then(result => { request.post('/sj/user/getuser').then(result => {
if (result.state === 1) { if (result.state === 1) {
this.userId = result.data.id; this.userId = result.data.id;
this.userMobile = result.data.mobile || result.data.account; //
if (this.userMobile && getApp().globalData) {
getApp().globalData.userMobile = this.userMobile;
}
console.log('用户ID获取成功:', this.userId); console.log('用户ID获取成功:', this.userId);
resolve(this.userId); resolve(this.userId);
} else { } else {
@ -719,58 +892,84 @@ export default {
}; };
}, },
// Promise
saveFormData() { saveFormData() {
return new Promise((resolve) => {
if (!this.formData.name) { if (!this.formData.name) {
uni.showToast({ uni.showToast({
title: '请输入店铺名称', title: '请输入店铺名称',
icon: 'none' icon: 'none'
}); });
return false; return resolve(false);
} }
if (!this.formData.dependency) { if (!this.formData.dependency) {
uni.showToast({ uni.showToast({
title: '请选择门店所在地', title: '请选择门店所在地',
icon: 'none' icon: 'none'
}); });
return false; return resolve(false);
} }
if (!this.formData.address) { if (!this.formData.address) {
uni.showToast({ uni.showToast({
title: '请选择门店详细地址', title: '请选择门店详细地址',
icon: 'none' icon: 'none'
}); });
return false; return resolve(false);
} }
if (!this.formData.contact_name) { if (!this.formData.contact_name) {
uni.showToast({ uni.showToast({
title: '请输入联系人', title: '请输入联系人',
icon: 'none' icon: 'none'
}); });
return false; return resolve(false);
} }
if (!this.formData.contact_phone) { if (!this.formData.contact_phone) {
uni.showToast({ uni.showToast({
title: '请输入联系人电话', title: '请输入联系人电话',
icon: 'none' icon: 'none'
}); });
return false; return resolve(false);
} }
if (!/^1[3-9]\d{9}$/.test(this.formData.contact_phone)) { if (!/^1[3-9]\d{9}$/.test(this.formData.contact_phone)) {
uni.showToast({ uni.showToast({
title: '请输入正确的手机号码', title: '请输入正确的手机号码',
icon: 'none' icon: 'none'
}); });
return false; return resolve(false);
} }
if (!this.formData.invite_code_other) { if (!this.formData.invite_code_other) {
uni.showToast({ uni.showToast({
title: '请输入邀请码', title: '请输入邀请码',
icon: 'none' icon: 'none'
}); });
return false; return resolve(false);
} }
//
if (this.inviteCodeValidating) {
uni.showToast({ title: '邀请码验证中,请稍候', icon: 'none' });
return resolve(false);
}
if (this.formData.invite_code_other === '13131313') {
//
} else if (this.inviteCodeError || !this.inviterInfo) {
this.triggerInviteErrorShake();
return resolve(false);
}
// resolve
this.confirmResolve = resolve;
if (this.formData.invite_code_other === '13131313') {
this.showInviteConfirmPopup({ invite_code_other: '13131313', name: '暂无邀请人' });
} else if (this.inviterInfo && this.formData.invite_code_other) {
this.showInviteConfirmPopup(this.inviterInfo);
} else {
this.saveFormDataToLocal(); this.saveFormDataToLocal();
return true; resolve(true);
}
});
}, },
setContactType(type) { setContactType(type) {
@ -1008,6 +1207,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
/* 继承你以前的所有原有样式 */
.qualification-page {} .qualification-page {}
.section { .section {
@ -1455,4 +1655,97 @@ export default {
.inviter-phone { .inviter-phone {
color: #666666; color: #666666;
} }
/* 邀请码和禁用样式 */
/* 输入框禁用样式 */
.input:disabled {
color: #999999;
background-color: #F5F5F5;
}
/* 邀请码确认弹窗样式 */
.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;
margin-top: 20rpx;
}
.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;
margin: 0 5rpx;
}
.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;
}
</style> </style>

View File

@ -190,7 +190,6 @@
"latitude": data.latitude || '', "latitude": data.latitude || '',
"name": data.name || '', "name": data.name || '',
"contact_type": data.contact_type || '' "contact_type": data.contact_type || ''
} }
uni.setStorageSync('qualification_form_data', qualification_form_data); uni.setStorageSync('qualification_form_data', qualification_form_data);
let store_info_form_data = { let store_info_form_data = {
@ -527,7 +526,9 @@
async submitApplication() { async submitApplication() {
if (this.$refs.storeInfo) { if (this.$refs.storeInfo) {
if (!this.$refs.storeInfo.saveFormData()) { // await
const isValid = await this.$refs.storeInfo.saveFormData();
if (!isValid) {
return; return;
} }
this.storeInfoData = this.$refs.storeInfo.getFormData(); this.storeInfoData = this.$refs.storeInfo.getFormData();
@ -626,6 +627,7 @@
</script> </script>
<style> <style>
/* ...与原来一致的代码... */
.ruzhu-page { .ruzhu-page {
background: #f5f5f5; background: #f5f5f5;
} }

View File

@ -135,13 +135,13 @@ const request = async (options, isUpdate) => {
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
baseURL = url; // 发布到生产环境时,此处代码会被摇树移除掉。 baseURL = url; // 发布到生产环境时,此处代码会被摇树移除掉。
baseURL = 'http://116.63.163.121:93'; // 发布到生产环境时,此处代码会被摇树移除掉。 baseURL = 'http://test.mrrwlkj.top'; // 发布到生产环境时,此处代码会被摇树移除掉。
//baseURL = 'http://116.63.163.121:96'; // 发布到生产环境时,此处代码会被摇树移除掉。 //baseURL = 'http://dev.mrrwlkj.top'; // 发布到生产环境时,此处代码会被摇树移除掉。
//baseURL = 'https://app.mrrweb.com.cn'; //baseURL = 'https://app.mrrweb.com.cn';
} else { } else {
baseURL = url; // 发布到生产环境时,此处代码会被摇树移除掉。 baseURL = url; // 发布到生产环境时,此处代码会被摇树移除掉。
baseURL = 'http://116.63.163.121:93'; // 发布到生产环境时,此处代码会被摇树移除掉。 baseURL = 'http://test.mrrwlkj.top'; // 发布到生产环境时,此处代码会被摇树移除掉。
//baseURL = 'http://116.63.163.121:96'; // 发布到生产环境时,此处代码会被摇树移除掉。 //baseURL = 'http://dev.mrrwlkj.top'; // 发布到生产环境时,此处代码会被摇树移除掉。
//baseURL = 'https://app.mrrweb.com.cn'; //baseURL = 'https://app.mrrweb.com.cn';
console.log('生产环境'); console.log('生产环境');