|
|
|
|
// pages/settlement/settlement.js
|
|
|
|
|
const API = require('../../utils/api.js');
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
// 是否显示引导页
|
|
|
|
|
showGuidePage: true,
|
|
|
|
|
// 当前步骤
|
|
|
|
|
currentStep: 0,
|
|
|
|
|
|
|
|
|
|
// 身份选择
|
|
|
|
|
collaborationid: '', // 合作商身份ID (原selectedIdentity)
|
|
|
|
|
showIdentityError: false,
|
|
|
|
|
|
|
|
|
|
// 基本信息
|
|
|
|
|
company: '', // 客户公司名称 (原companyName)
|
|
|
|
|
showCompanyNameError: false,
|
|
|
|
|
companyNameError: '',
|
|
|
|
|
province: '',
|
|
|
|
|
city: '',
|
|
|
|
|
district: '',
|
|
|
|
|
detailedaddress: '', // 详细地址 (原detailAddress)
|
|
|
|
|
showRegionError: false,
|
|
|
|
|
regionError: '',
|
|
|
|
|
cooperation: '', // 合作模式 (原selectedCooperation)
|
|
|
|
|
showCooperationError: false,
|
|
|
|
|
cooperationError: '',
|
|
|
|
|
|
|
|
|
|
// 上传资料
|
|
|
|
|
businesslicenseurl: null, // 营业执照URL (原businessLicenseFile)
|
|
|
|
|
proofurl: null, // 动物检疫证明URL (原animalQuarantineFile)
|
|
|
|
|
// idCardFile: null, // 已移除,法人身份证现在使用proofurl字段
|
|
|
|
|
brandurl: null, // 品牌授权链URL (原brandAuthFile)
|
|
|
|
|
|
|
|
|
|
// 审核状态
|
|
|
|
|
partnerstatus: '', // 合作商状态 (原auditStatus),初始为空而不是默认审核中
|
|
|
|
|
reasonforfailure: '营业执照图片不清晰,无法识别关键信息。请重新上传清晰的LICENSE照片。',
|
|
|
|
|
|
|
|
|
|
// 登录弹窗相关
|
|
|
|
|
showAuthModal: false,
|
|
|
|
|
loginModalTitle: '请先登录',
|
|
|
|
|
loginModalContent: '为了您的账户安全,请先完成手机号登录',
|
|
|
|
|
showLoginButton: true
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onLoad(options) {
|
|
|
|
|
console.log('settlement页面加载,options:', options);
|
|
|
|
|
|
|
|
|
|
// 检查是否有status参数,如果有则显示审核状态
|
|
|
|
|
if (options.status) {
|
|
|
|
|
console.log('检测到status参数:', options.status);
|
|
|
|
|
// 检查是否有preSubmitData
|
|
|
|
|
const preSubmitData = wx.getStorageSync('preSubmitData');
|
|
|
|
|
if (preSubmitData) {
|
|
|
|
|
console.log('找到preSubmitData,显示审核状态页面');
|
|
|
|
|
this.setData({
|
|
|
|
|
showGuidePage: false,
|
|
|
|
|
currentStep: 3,
|
|
|
|
|
partnerstatus: options.status
|
|
|
|
|
});
|
|
|
|
|
// 同步服务器状态,确保显示最新状态
|
|
|
|
|
this.syncSettlementStatus();
|
|
|
|
|
return; // 直接返回,不执行后续逻辑
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查是否有保存的入驻进度
|
|
|
|
|
this.loadSettlementProgress();
|
|
|
|
|
|
|
|
|
|
// 如果有保存的进度,直接跳过引导页
|
|
|
|
|
if (this.data.currentStep > 0) {
|
|
|
|
|
this.setData({
|
|
|
|
|
showGuidePage: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查是否是从首页登录返回的
|
|
|
|
|
const pendingReturnPath = wx.getStorageSync('pendingReturnPath');
|
|
|
|
|
if (pendingReturnPath === 'settlement') {
|
|
|
|
|
console.log('检测到从首页登录返回,清除标记并自动提交申请');
|
|
|
|
|
// 清除返回路径标记
|
|
|
|
|
wx.removeStorageSync('pendingReturnPath');
|
|
|
|
|
|
|
|
|
|
// 延迟一下确保页面完全加载
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
// 检查是否有保存的表单数据
|
|
|
|
|
const savedProgress = wx.getStorageSync('settlementProgress');
|
|
|
|
|
if (savedProgress && savedProgress.formData) {
|
|
|
|
|
console.log('发现保存的表单数据,自动提交申请');
|
|
|
|
|
// 恢复表单数据
|
|
|
|
|
this.setData(savedProgress.formData);
|
|
|
|
|
// 自动提交申请
|
|
|
|
|
this.submitApplication();
|
|
|
|
|
}
|
|
|
|
|
}, 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 同步服务器状态,确保显示最新的partnerstatus
|
|
|
|
|
this.syncSettlementStatus();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onUnload() {
|
|
|
|
|
// 页面卸载时保存进度(除了审核通过状态)
|
|
|
|
|
if (this.data.partnerstatus !== 'approved') {
|
|
|
|
|
this.saveSettlementProgress();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 加载入驻进度
|
|
|
|
|
loadSettlementProgress() {
|
|
|
|
|
const settlementData = wx.getStorageSync('settlement_data');
|
|
|
|
|
if (settlementData) {
|
|
|
|
|
// 映射旧字段名到新字段名(兼容性处理)
|
|
|
|
|
const mappedData = {
|
|
|
|
|
currentStep: settlementData.currentStep,
|
|
|
|
|
collaborationid: settlementData.collaborationid || settlementData.selectedIdentity,
|
|
|
|
|
company: settlementData.company || settlementData.companyName,
|
|
|
|
|
province: settlementData.province,
|
|
|
|
|
city: settlementData.city,
|
|
|
|
|
district: settlementData.district,
|
|
|
|
|
detailedaddress: settlementData.detailedaddress || settlementData.detailAddress,
|
|
|
|
|
cooperation: settlementData.cooperation || settlementData.selectedCooperation,
|
|
|
|
|
businesslicenseurl: settlementData.businesslicenseurl || settlementData.businessLicenseFile,
|
|
|
|
|
proofurl: settlementData.proofurl || settlementData.animalQuarantineFile,
|
|
|
|
|
// idCardFile: settlementData.idCardFile, // 已移除,法人身份证现在使用proofurl字段
|
|
|
|
|
brandurl: settlementData.brandurl || settlementData.brandAuthFile,
|
|
|
|
|
agreementChecked: settlementData.agreementChecked,
|
|
|
|
|
partnerstatus: settlementData.partnerstatus || settlementData.auditStatus
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.setData(mappedData);
|
|
|
|
|
console.log('加载入驻进度:', mappedData);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 保存入驻进度
|
|
|
|
|
saveSettlementProgress() {
|
|
|
|
|
const settlementData = {
|
|
|
|
|
currentStep: this.data.currentStep,
|
|
|
|
|
collaborationid: this.data.collaborationid, // 合作商身份ID (原selectedIdentity)
|
|
|
|
|
company: this.data.company, // 客户公司名称 (原companyName)
|
|
|
|
|
province: this.data.province,
|
|
|
|
|
city: this.data.city,
|
|
|
|
|
district: this.data.district,
|
|
|
|
|
detailedaddress: this.data.detailedaddress, // 详细地址 (原detailAddress)
|
|
|
|
|
cooperation: this.data.cooperation, // 合作模式 (原selectedCooperation)
|
|
|
|
|
businesslicenseurl: this.data.businesslicenseurl, // 营业执照URL (原businessLicenseFile)
|
|
|
|
|
proofurl: this.data.proofurl, // 动物检疫证明或法人身份证URL (原animalQuarantineFile)
|
|
|
|
|
brandurl: this.data.brandurl, // 品牌授权链URL (原brandAuthFile)
|
|
|
|
|
agreementChecked: this.data.agreementChecked,
|
|
|
|
|
partnerstatus: this.data.partnerstatus // 合作商状态 (原auditStatus)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
wx.setStorageSync('settlement_data', settlementData);
|
|
|
|
|
console.log('保存入驻进度');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 清除入驻进度
|
|
|
|
|
clearSettlementProgress() {
|
|
|
|
|
wx.removeStorageSync('settlement_data');
|
|
|
|
|
console.log('清除入驻进度');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 更新全局入驻状态
|
|
|
|
|
updateGlobalSettlementStatus(status) {
|
|
|
|
|
// 可以在这里调用全局状态管理
|
|
|
|
|
const app = getApp();
|
|
|
|
|
if (app && app.updateSettlementStatus) {
|
|
|
|
|
app.updateSettlementStatus(status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 同时保存到本地存储
|
|
|
|
|
wx.setStorageSync('settlement_status', status);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 开始入驻流程
|
|
|
|
|
startSettlement: async function() {
|
|
|
|
|
console.log('开始入驻流程');
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 检查数据库中是否存在入驻信息
|
|
|
|
|
console.log('检查入驻信息');
|
|
|
|
|
await this.syncSettlementStatus();
|
|
|
|
|
|
|
|
|
|
// 根据入驻状态处理
|
|
|
|
|
if (this.data.partnerstatus === 'approved' || this.data.partnerstatus === 'underreview') {
|
|
|
|
|
console.log('用户已入驻或审核中,直接进入相应页面');
|
|
|
|
|
this.setData({
|
|
|
|
|
showGuidePage: false,
|
|
|
|
|
currentStep: 3 // 审核状态页面
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
console.log('用户未入驻,正常进行入驻流程');
|
|
|
|
|
this.setData({
|
|
|
|
|
showGuidePage: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('检查入驻状态时出错:', error);
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '系统繁忙,请稍后再试',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 下一步
|
|
|
|
|
nextStep() {
|
|
|
|
|
switch (this.data.currentStep) {
|
|
|
|
|
case 0:
|
|
|
|
|
// 验证身份选择
|
|
|
|
|
if (!this.data.collaborationid) { // 使用数据库字段名
|
|
|
|
|
this.setData({ showIdentityError: true });
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
currentStep: 1,
|
|
|
|
|
showIdentityError: false
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
// 验证基本信息
|
|
|
|
|
let valid = true;
|
|
|
|
|
|
|
|
|
|
if (!this.data.company || !this.data.company.trim()) { // 使用数据库字段名,添加空值检查
|
|
|
|
|
this.setData({ showCompanyNameError: true });
|
|
|
|
|
valid = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.setData({ showCompanyNameError: false });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.data.province || !this.data.city || !this.data.district) {
|
|
|
|
|
this.setData({ showRegionError: true });
|
|
|
|
|
valid = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.setData({ showRegionError: false });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.data.cooperation) { // 使用数据库字段名
|
|
|
|
|
this.setData({ showCooperationError: true });
|
|
|
|
|
valid = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.setData({ showCooperationError: false });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
this.setData({ currentStep: 2 });
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 上一步
|
|
|
|
|
prevStep() {
|
|
|
|
|
if (this.data.currentStep > 0) {
|
|
|
|
|
this.setData({ currentStep: this.data.currentStep - 1 });
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 选择身份
|
|
|
|
|
selectIdentity(e) {
|
|
|
|
|
const identity = e.currentTarget.dataset.identity;
|
|
|
|
|
this.setData({
|
|
|
|
|
collaborationid: identity, // 使用数据库字段名
|
|
|
|
|
showIdentityError: false
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 公司名称输入(带实时验证)
|
|
|
|
|
onCompanyNameInput(e) {
|
|
|
|
|
const value = e.detail.value.trim();
|
|
|
|
|
let showError = false;
|
|
|
|
|
let errorMessage = '';
|
|
|
|
|
|
|
|
|
|
if (value.length > 0) {
|
|
|
|
|
if (value.length < 2) {
|
|
|
|
|
showError = true;
|
|
|
|
|
errorMessage = '公司名称至少需要2个字符';
|
|
|
|
|
} else if (value.length > 50) {
|
|
|
|
|
showError = true;
|
|
|
|
|
errorMessage = '公司名称不能超过50个字符';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
company: value, // 使用数据库字段名
|
|
|
|
|
showCompanyNameError: showError,
|
|
|
|
|
companyNameError: errorMessage
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 公司名称获得焦点
|
|
|
|
|
onCompanyNameFocus(e) {
|
|
|
|
|
// 清除错误状态,让用户重新输入
|
|
|
|
|
if (this.data.showCompanyNameError) {
|
|
|
|
|
this.setData({
|
|
|
|
|
showCompanyNameError: false,
|
|
|
|
|
companyNameError: ''
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 公司名称失去焦点验证
|
|
|
|
|
onCompanyNameBlur() {
|
|
|
|
|
if (!this.data.company || !this.data.company.trim()) { // 使用数据库字段名,添加空值检查
|
|
|
|
|
this.setData({
|
|
|
|
|
showCompanyNameError: true,
|
|
|
|
|
companyNameError: '请输入公司名称'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 地区选择(带验证)
|
|
|
|
|
onRegionChange(e) {
|
|
|
|
|
const value = e.detail.value;
|
|
|
|
|
const province = value[0] || '';
|
|
|
|
|
const city = value[1] || '';
|
|
|
|
|
const district = value[2] || '';
|
|
|
|
|
|
|
|
|
|
let showError = false;
|
|
|
|
|
let errorMessage = '';
|
|
|
|
|
|
|
|
|
|
if (!province || !city || !district) {
|
|
|
|
|
showError = true;
|
|
|
|
|
errorMessage = '请选择完整的省市区信息';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
province: province,
|
|
|
|
|
city: city,
|
|
|
|
|
district: district,
|
|
|
|
|
showRegionError: showError,
|
|
|
|
|
regionError: errorMessage
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 详细地址输入
|
|
|
|
|
onDetailAddressInput(e) {
|
|
|
|
|
this.setData({ detailedaddress: e.detail.value }); // 使用数据库字段名
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 详细地址获得焦点
|
|
|
|
|
onDetailAddressFocus(e) {
|
|
|
|
|
// 可以在这里添加焦点处理逻辑,比如滚动到视图等
|
|
|
|
|
console.log('详细地址输入框获得焦点');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 选择合作模式(带验证)
|
|
|
|
|
selectCooperation(e) {
|
|
|
|
|
const value = e.currentTarget.dataset.value;
|
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
cooperation: value, // 使用数据库字段名
|
|
|
|
|
showCooperationError: false,
|
|
|
|
|
cooperationError: ''
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 上传LICENSE
|
|
|
|
|
uploadBusinessLicense() {
|
|
|
|
|
wx.chooseImage({
|
|
|
|
|
count: 1,
|
|
|
|
|
sizeType: ['compressed'],
|
|
|
|
|
sourceType: ['album', 'camera'],
|
|
|
|
|
success: (res) => {
|
|
|
|
|
const tempFilePaths = res.tempFilePaths;
|
|
|
|
|
this.setData({
|
|
|
|
|
businesslicenseurl: { // 使用数据库字段名
|
|
|
|
|
path: tempFilePaths[0],
|
|
|
|
|
name: `营业执照_${new Date().getTime()}.jpg`
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 删除LICENSE
|
|
|
|
|
deleteBusinessLicense() {
|
|
|
|
|
this.setData({ businesslicenseurl: null }); // 使用数据库字段名
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 上传动物检疫合格证明
|
|
|
|
|
uploadAnimalQuarantine() {
|
|
|
|
|
wx.chooseImage({
|
|
|
|
|
count: 1,
|
|
|
|
|
sizeType: ['compressed'],
|
|
|
|
|
sourceType: ['album', 'camera'],
|
|
|
|
|
success: (res) => {
|
|
|
|
|
const tempFilePaths = res.tempFilePaths;
|
|
|
|
|
this.setData({
|
|
|
|
|
proofurl: { // 使用数据库字段名
|
|
|
|
|
path: tempFilePaths[0],
|
|
|
|
|
name: `动物检疫合格证明_${new Date().getTime()}.jpg`
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 删除动物检疫合格证明
|
|
|
|
|
deleteAnimalQuarantine() {
|
|
|
|
|
this.setData({ proofurl: null }); // 使用数据库字段名
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 上传法人身份证
|
|
|
|
|
uploadIdCard() {
|
|
|
|
|
wx.chooseImage({
|
|
|
|
|
count: 1,
|
|
|
|
|
sizeType: ['compressed'],
|
|
|
|
|
sourceType: ['album', 'camera'],
|
|
|
|
|
success: (res) => {
|
|
|
|
|
const tempFilePaths = res.tempFilePaths;
|
|
|
|
|
this.setData({
|
|
|
|
|
proofurl: { // 使用与动物检疫合格证明相同的字段名
|
|
|
|
|
path: tempFilePaths[0],
|
|
|
|
|
name: `法人身份证_${new Date().getTime()}.jpg`
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 删除法人身份证
|
|
|
|
|
deleteIdCard() {
|
|
|
|
|
this.setData({ proofurl: null }); // 使用与动物检疫合格证明相同的字段名
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 上传品牌授权链文件
|
|
|
|
|
uploadBrandAuth() {
|
|
|
|
|
wx.chooseImage({
|
|
|
|
|
count: 1,
|
|
|
|
|
sizeType: ['compressed'],
|
|
|
|
|
sourceType: ['album', 'camera'],
|
|
|
|
|
success: (res) => {
|
|
|
|
|
const tempFilePaths = res.tempFilePaths;
|
|
|
|
|
this.setData({
|
|
|
|
|
brandurl: { // 使用数据库字段名
|
|
|
|
|
path: tempFilePaths[0],
|
|
|
|
|
name: `品牌授权链_${new Date().getTime()}.jpg`
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 删除品牌授权链文件
|
|
|
|
|
deleteBrandAuth() {
|
|
|
|
|
this.setData({ brandurl: null }); // 使用数据库字段名
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 获取文件类型显示名称
|
|
|
|
|
getFileTypeDisplayName(fileType) {
|
|
|
|
|
const typeNames = {
|
|
|
|
|
'businessLicense': '营业执照',
|
|
|
|
|
'animalQuarantine': '动物检疫合格证明',
|
|
|
|
|
'idCard': '法人身份证',
|
|
|
|
|
'brandAuth': '品牌授权链文件'
|
|
|
|
|
};
|
|
|
|
|
return typeNames[fileType] || '文件';
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 上传文件到服务器
|
|
|
|
|
async uploadFileToServer(filePath, fileType) {
|
|
|
|
|
try {
|
|
|
|
|
const API = require('../../utils/api.js');
|
|
|
|
|
console.log(`开始上传${this.getFileTypeDisplayName(fileType)}文件:`, filePath);
|
|
|
|
|
|
|
|
|
|
const result = await API.uploadSettlementFile(filePath, fileType);
|
|
|
|
|
|
|
|
|
|
// 修正返回值处理 - API.uploadSettlementFile直接返回data对象
|
|
|
|
|
if (result && result.fileUrl) {
|
|
|
|
|
console.log(`${this.getFileTypeDisplayName(fileType)}上传成功:`, result.fileUrl);
|
|
|
|
|
return result.fileUrl;
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(`${this.getFileTypeDisplayName(fileType)}上传失败`);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(`${this.getFileTypeDisplayName(fileType)}上传失败:`, error);
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: `${this.getFileTypeDisplayName(fileType)}上传失败`,
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 提交申请
|
|
|
|
|
async submitApplication() {
|
|
|
|
|
// 检查用户是否已登录
|
|
|
|
|
const openid = wx.getStorageSync('openid');
|
|
|
|
|
const userId = wx.getStorageSync('userId');
|
|
|
|
|
|
|
|
|
|
// 如果未登录,显示登录弹窗
|
|
|
|
|
if (!openid || !userId) {
|
|
|
|
|
console.log('用户未登录,显示授权弹窗');
|
|
|
|
|
// 保存当前表单数据
|
|
|
|
|
this.saveSettlementProgress();
|
|
|
|
|
// 显示登录弹窗
|
|
|
|
|
this.setData({
|
|
|
|
|
showAuthModal: true
|
|
|
|
|
});
|
|
|
|
|
return; // 取消提交申请
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log('使用已登录用户信息提交申请:', openid, userId);
|
|
|
|
|
|
|
|
|
|
// 先上传所有文件
|
|
|
|
|
wx.showLoading({
|
|
|
|
|
title: '正在上传文件...',
|
|
|
|
|
mask: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const uploadedFiles = {};
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 上传LICENSE
|
|
|
|
|
if (this.data.businesslicenseurl) { // 使用数据库字段名
|
|
|
|
|
uploadedFiles.businessLicenseFile = await this.uploadFileToServer(
|
|
|
|
|
this.data.businesslicenseurl.path,
|
|
|
|
|
'businessLicense'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 上传动物检疫合格证明或法人身份证(两者共用一个字段)
|
|
|
|
|
if (this.data.proofurl) { // 使用数据库字段名
|
|
|
|
|
uploadedFiles.animalQuarantineFile = await this.uploadFileToServer(
|
|
|
|
|
this.data.proofurl.path,
|
|
|
|
|
'animalQuarantine' // 保持原有的文件类型,或者可以根据实际情况调整
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 上传品牌授权链文件
|
|
|
|
|
if (this.data.brandurl) { // 使用数据库字段名
|
|
|
|
|
uploadedFiles.brandAuthFile = await this.uploadFileToServer(
|
|
|
|
|
this.data.brandurl.path,
|
|
|
|
|
'brandAuth'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log('所有文件上传完成:', uploadedFiles);
|
|
|
|
|
// 移除return语句,让代码继续执行到提交数据部分
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('文件上传失败:', error);
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '文件上传失败',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
return; // 修改为return而不是return null
|
|
|
|
|
} finally {
|
|
|
|
|
// 确保无论成功失败都会隐藏loading
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 准备提交数据(与后端API要求的字段名匹配)
|
|
|
|
|
// 尝试多种方式获取手机号,确保contactPhone不为空
|
|
|
|
|
// 1. 先尝试直接获取常见的手机号存储键
|
|
|
|
|
let contactPhone = wx.getStorageSync('phone') ||
|
|
|
|
|
wx.getStorageSync('userPhone') ||
|
|
|
|
|
wx.getStorageSync('mobile') ||
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
// 2. 如果上述方式没获取到,尝试从userInfo对象中获取
|
|
|
|
|
if (!contactPhone) {
|
|
|
|
|
const userInfo = wx.getStorageSync('userInfo');
|
|
|
|
|
if (userInfo && userInfo.phoneNumber && userInfo.phoneNumber !== '未绑定') {
|
|
|
|
|
contactPhone = userInfo.phoneNumber;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log('最终获取到的手机号:', contactPhone);
|
|
|
|
|
|
|
|
|
|
// 根据后端API要求构建submitData对象(使用独立的省市区字段)
|
|
|
|
|
const submitData = {
|
|
|
|
|
openid: openid,
|
|
|
|
|
collaborationid: this.data.collaborationid, // 合作商身份ID
|
|
|
|
|
company: this.data.company || '', // 客户公司名称
|
|
|
|
|
province: this.data.province, // 省份
|
|
|
|
|
city: this.data.city, // 城市
|
|
|
|
|
district: this.data.district, // 区县
|
|
|
|
|
detailedaddress: this.data.detailedaddress || '', // 详细地址(即使为空也要传递)
|
|
|
|
|
cooperation: this.data.cooperation === '货源委托' ? 'wholesale' : this.data.cooperation, // 合作模式映射为后端期望的值
|
|
|
|
|
phoneNumber: contactPhone, // 后端期望的字段名是phoneNumber
|
|
|
|
|
businesslicenseurl: uploadedFiles.businessLicenseFile || '', // 营业执照URL
|
|
|
|
|
proofurl: uploadedFiles.animalQuarantineFile || '', // 动物检疫证明或法人身份证URL(两者共用一个字段)
|
|
|
|
|
brandurl: uploadedFiles.brandAuthFile || '', // 品牌授权链URL
|
|
|
|
|
userId: userId
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 特别记录详细地址字段,确保它被正确提交
|
|
|
|
|
console.log('详细地址字段值:', submitData.detailedaddress);
|
|
|
|
|
console.log('详细地址字段类型:', typeof submitData.detailedaddress);
|
|
|
|
|
console.log('详细地址字段是否存在:', 'detailedaddress' in submitData);
|
|
|
|
|
|
|
|
|
|
// 记录省市区字段内容
|
|
|
|
|
console.log('省市区字段内容(提交数据):', submitData.province, submitData.city, submitData.district);
|
|
|
|
|
|
|
|
|
|
// 保存提交数据到本地存储,供首页检查使用
|
|
|
|
|
wx.setStorageSync('preSubmitData', submitData);
|
|
|
|
|
console.log('已保存preSubmitData:', submitData);
|
|
|
|
|
|
|
|
|
|
// 检查必填字段是否为空
|
|
|
|
|
console.log('提交数据检查 - contactPhone:', contactPhone);
|
|
|
|
|
console.log('提交数据检查 - identityType:', this.data.collaborationid);
|
|
|
|
|
console.log('提交数据检查 - cooperationMode:', this.data.cooperation);
|
|
|
|
|
console.log('提交数据检查 - cooperationValue:', submitData.cooperation); // 检查映射后的值
|
|
|
|
|
console.log('提交数据检查 - contactName:', this.data.company);
|
|
|
|
|
console.log('提交数据检查 - 省市区:', submitData.province, submitData.city, submitData.district);
|
|
|
|
|
// 检查所有字段是否完整
|
|
|
|
|
console.log('提交数据完整性检查:', {
|
|
|
|
|
hasOpenid: !!submitData.openid,
|
|
|
|
|
hasCollaborationid: !!submitData.collaborationid,
|
|
|
|
|
hasCompany: !!submitData.company,
|
|
|
|
|
hasProvince: !!submitData.province,
|
|
|
|
|
hasCity: !!submitData.city,
|
|
|
|
|
hasDistrict: !!submitData.district,
|
|
|
|
|
hasDetailedAddress: !!submitData.detailedaddress,
|
|
|
|
|
hasCooperation: !!submitData.cooperation,
|
|
|
|
|
hasPhoneNumber: !!submitData.phoneNumber,
|
|
|
|
|
hasBusinessLicense: !!submitData.businesslicenseurl,
|
|
|
|
|
hasProofUrl: !!submitData.proofurl,
|
|
|
|
|
hasBrandUrl: !!submitData.brandurl
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 表单验证 - 检查必填字段
|
|
|
|
|
if (!openid) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请先登录',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.data.collaborationid) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请选择合作商身份',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.data.cooperation) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请选择合作模式',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.data.company) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请填写公司名称',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 手机号为空时使用默认值,不再强制要求
|
|
|
|
|
if (!contactPhone) {
|
|
|
|
|
contactPhone = 'default_phone';
|
|
|
|
|
console.log('使用默认手机号:', contactPhone);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证省市区字段是否填写完整(用于构建region字段)
|
|
|
|
|
if (!this.data.province || !this.data.city || !this.data.district) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请填写完整地址',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 记录省市区字段内容
|
|
|
|
|
console.log('省市区字段内容:', this.data.province, this.data.city, this.data.district);
|
|
|
|
|
|
|
|
|
|
// 文件上传现在为选填,不再强制要求
|
|
|
|
|
console.log('文件上传状态:', {
|
|
|
|
|
businessLicenseFile: !!uploadedFiles.businessLicenseFile,
|
|
|
|
|
animalQuarantineFile: !!uploadedFiles.animalQuarantineFile,
|
|
|
|
|
brandAuthFile: !!uploadedFiles.brandAuthFile
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 调用后端API提交入驻申请
|
|
|
|
|
// 使用API.BASE_URL构建正确的请求路径
|
|
|
|
|
const API = require('../../utils/api');
|
|
|
|
|
console.log('开始提交入驻申请,API地址:', API.BASE_URL + '/api/settlement/submit');
|
|
|
|
|
console.log('提交的完整数据:', submitData);
|
|
|
|
|
// 详细检查后端必需的关键字段(使用独立的省市区字段)
|
|
|
|
|
const requiredFieldsCheck = {
|
|
|
|
|
openid: { value: submitData.openid, exists: !!submitData.openid },
|
|
|
|
|
collaborationid: { value: submitData.collaborationid, exists: !!submitData.collaborationid },
|
|
|
|
|
cooperation: { value: submitData.cooperation, exists: !!submitData.cooperation },
|
|
|
|
|
company: { value: submitData.company, exists: !!submitData.company },
|
|
|
|
|
phoneNumber: { value: submitData.phoneNumber, exists: !!submitData.phoneNumber },
|
|
|
|
|
province: { value: submitData.province, exists: !!submitData.province },
|
|
|
|
|
city: { value: submitData.city, exists: !!submitData.city },
|
|
|
|
|
district: { value: submitData.district, exists: !!submitData.district }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
console.log('后端必需字段详细检查:', requiredFieldsCheck);
|
|
|
|
|
|
|
|
|
|
// 检查是否所有必需字段都已填写
|
|
|
|
|
const allRequiredFieldsExist = Object.values(requiredFieldsCheck).every(field => field.exists);
|
|
|
|
|
console.log('是否所有后端必需字段都已填写:', allRequiredFieldsExist);
|
|
|
|
|
|
|
|
|
|
const result = await new Promise((resolve, reject) => {
|
|
|
|
|
wx.request({
|
|
|
|
|
url: API.BASE_URL + '/api/settlement/submit',
|
|
|
|
|
method: 'POST',
|
|
|
|
|
data: submitData,
|
|
|
|
|
success: (res) => {
|
|
|
|
|
console.log('API请求成功,原始响应:', res);
|
|
|
|
|
resolve(res.data);
|
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
console.error('API请求失败:', err);
|
|
|
|
|
reject(err);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
console.log('入驻申请提交结果:', result);
|
|
|
|
|
console.log('请求状态码:', result.code);
|
|
|
|
|
console.log('请求消息:', result.message);
|
|
|
|
|
|
|
|
|
|
if (result && result.success) {
|
|
|
|
|
// 更新本地状态
|
|
|
|
|
wx.setStorageSync('settlementStatus', 'underreview');
|
|
|
|
|
// 保存applicationId到本地存储,供撤回功能使用
|
|
|
|
|
const appId = result.data?.id || null;
|
|
|
|
|
if (appId) {
|
|
|
|
|
wx.setStorageSync('applicationId', appId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '提交成功,等待审核',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 2000
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 跳转到审核状态页面 - 立即执行
|
|
|
|
|
this.setData({
|
|
|
|
|
currentStep: 3, // 设置为第4步(审核状态页面)
|
|
|
|
|
partnerstatus: 'underreview', // 使用数据库字段名 (原auditStatus)
|
|
|
|
|
applicationId: appId
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 调用API获取用户完整数据 - 异步执行,不影响跳转
|
|
|
|
|
const API = require('../../utils/api.js');
|
|
|
|
|
API.getUserInfo().then(userRes => {
|
|
|
|
|
console.log('用户完整数据:', userRes.data);
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
console.error('获取用户数据失败:', err);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 清除进度数据,因为已经提交了
|
|
|
|
|
this.clearSettlementProgress();
|
|
|
|
|
} else {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: result.message || '提交失败',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('提交入驻申请失败:', error);
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '提交失败,请重试',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 跳转到首页进行授权登录
|
|
|
|
|
async goToAuthLogin() {
|
|
|
|
|
// 保存当前表单数据
|
|
|
|
|
this.saveSettlementProgress();
|
|
|
|
|
|
|
|
|
|
console.log('用户未登录,在当前页面调用登录方法');
|
|
|
|
|
|
|
|
|
|
// 显示登录提示
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请先登录',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 1500,
|
|
|
|
|
complete: () => {
|
|
|
|
|
// 直接在当前页面调用首页的登录逻辑
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.performDirectLogin();
|
|
|
|
|
}, 1500);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 在当前页面直接执行登录逻辑
|
|
|
|
|
async performDirectLogin() {
|
|
|
|
|
console.log('显示登录弹窗,让用户主动授权');
|
|
|
|
|
|
|
|
|
|
// 显示登录弹窗
|
|
|
|
|
this.setData({
|
|
|
|
|
showAuthModal: true
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 关闭登录弹窗
|
|
|
|
|
closeAuthModal() {
|
|
|
|
|
this.setData({
|
|
|
|
|
showAuthModal: false
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 处理手机号授权
|
|
|
|
|
async onGetPhoneNumber(e) {
|
|
|
|
|
console.log('用户点击了手机号授权按钮', e.detail);
|
|
|
|
|
|
|
|
|
|
// 关闭登录弹窗
|
|
|
|
|
this.setData({
|
|
|
|
|
showAuthModal: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (e.detail.errMsg === 'getPhoneNumber:ok') {
|
|
|
|
|
// 用户同意授权
|
|
|
|
|
wx.showLoading({
|
|
|
|
|
title: '登录中...',
|
|
|
|
|
mask: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 调用API解密手机号
|
|
|
|
|
const app = getApp();
|
|
|
|
|
if (app && app.uploadPhoneNumberData) {
|
|
|
|
|
const result = await app.uploadPhoneNumberData(e.detail);
|
|
|
|
|
|
|
|
|
|
if (result && result.success) {
|
|
|
|
|
// 保存用户信息到全局和本地存储
|
|
|
|
|
const userInfo = {
|
|
|
|
|
nickName: '微信用户',
|
|
|
|
|
avatarUrl: '/images/default-avatar.png',
|
|
|
|
|
phoneNumber: result.phoneNumber || '未绑定',
|
|
|
|
|
gender: 0,
|
|
|
|
|
country: '',
|
|
|
|
|
province: '',
|
|
|
|
|
city: '',
|
|
|
|
|
language: 'zh_CN'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 保存到全局数据
|
|
|
|
|
app.globalData.userInfo = userInfo;
|
|
|
|
|
|
|
|
|
|
// 保存到本地存储
|
|
|
|
|
wx.setStorageSync('userInfo', userInfo);
|
|
|
|
|
|
|
|
|
|
console.log('用户信息已保存:', userInfo);
|
|
|
|
|
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '登录成功',
|
|
|
|
|
icon: 'success',
|
|
|
|
|
duration: 1500,
|
|
|
|
|
complete: () => {
|
|
|
|
|
// 登录成功后继续提交申请
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.submitApplication();
|
|
|
|
|
}, 1500);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(result.message || '登录失败');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 备用方案:模拟登录
|
|
|
|
|
await this.performBackupLogin();
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
console.error('手机号授权登录失败:', error);
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '登录失败,请重试',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 用户拒绝授权
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '需要手机号授权才能继续',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 备用登录方案
|
|
|
|
|
async performBackupLogin() {
|
|
|
|
|
wx.showLoading({
|
|
|
|
|
title: '登录中...',
|
|
|
|
|
mask: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 模拟登录流程
|
|
|
|
|
const mockOpenid = 'settlement_login_' + Date.now();
|
|
|
|
|
const mockUserId = 'settlement_user_' + Date.now();
|
|
|
|
|
|
|
|
|
|
// 存储模拟登录信息
|
|
|
|
|
wx.setStorageSync('openid', mockOpenid);
|
|
|
|
|
wx.setStorageSync('userId', mockUserId);
|
|
|
|
|
|
|
|
|
|
// 保存用户信息到全局和本地存储
|
|
|
|
|
const userInfo = {
|
|
|
|
|
nickName: '微信用户',
|
|
|
|
|
avatarUrl: '/images/default-avatar.png',
|
|
|
|
|
phoneNumber: '未绑定',
|
|
|
|
|
gender: 0,
|
|
|
|
|
country: '',
|
|
|
|
|
province: '',
|
|
|
|
|
city: '',
|
|
|
|
|
language: 'zh_CN'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 保存到全局数据
|
|
|
|
|
const app = getApp();
|
|
|
|
|
if (app) {
|
|
|
|
|
app.globalData.userInfo = userInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保存到本地存储
|
|
|
|
|
wx.setStorageSync('userInfo', userInfo);
|
|
|
|
|
|
|
|
|
|
console.log('备用登录用户信息已保存:', userInfo);
|
|
|
|
|
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '登录成功',
|
|
|
|
|
icon: 'success',
|
|
|
|
|
duration: 1500,
|
|
|
|
|
complete: () => {
|
|
|
|
|
// 登录成功后继续提交申请
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.submitApplication();
|
|
|
|
|
}, 1500);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
console.error('备用登录失败:', error);
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '登录失败,请重试',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 撤回备案
|
|
|
|
|
async withdrawApplication() {
|
|
|
|
|
// 检查用户是否已登录
|
|
|
|
|
const openid = wx.getStorageSync('openid');
|
|
|
|
|
if (!openid) {
|
|
|
|
|
console.log('用户未登录,显示授权弹窗');
|
|
|
|
|
// 显示登录弹窗
|
|
|
|
|
this.setData({
|
|
|
|
|
showAuthModal: true
|
|
|
|
|
});
|
|
|
|
|
return; // 取消撤回申请
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '确认撤回',
|
|
|
|
|
content: '确定要撤回备案申请吗?撤回后可以重新提交。',
|
|
|
|
|
success: async (res) => {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
try {
|
|
|
|
|
console.log('使用已登录用户openid撤回申请:', openid);
|
|
|
|
|
|
|
|
|
|
// 调用API撤回申请,不再需要applicationId,只需要用户openid
|
|
|
|
|
const API = require('../../utils/api.js');
|
|
|
|
|
const result = await API.withdrawSettlementApplication(openid);
|
|
|
|
|
|
|
|
|
|
if (result && result.success) {
|
|
|
|
|
// 清除本地状态
|
|
|
|
|
wx.removeStorageSync('preSubmitData');
|
|
|
|
|
wx.removeStorageSync('applicationId');
|
|
|
|
|
wx.setStorageSync('hasSubmittedSettlement', false);
|
|
|
|
|
wx.removeStorageSync('settlementStatus');
|
|
|
|
|
|
|
|
|
|
// 重置页面状态
|
|
|
|
|
this.setData({
|
|
|
|
|
currentStep: 0,
|
|
|
|
|
partnerstatus: '', // 使用数据库字段名 (原auditStatus)
|
|
|
|
|
applicationId: null
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '已撤回申请',
|
|
|
|
|
icon: 'success'
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: result.message || '撤回失败',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('撤回申请失败:', error);
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '撤回失败,请重试',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 审核中我知道了
|
|
|
|
|
knowAudit() {
|
|
|
|
|
// 获取用户openid
|
|
|
|
|
const openid = wx.getStorageSync('openid');
|
|
|
|
|
console.log('使用openid获取用户数据:', openid);
|
|
|
|
|
|
|
|
|
|
// 调用API获取用户完整数据
|
|
|
|
|
API.getUserInfo(openid).then(res => {
|
|
|
|
|
console.log('用户完整数据:', res.data);
|
|
|
|
|
|
|
|
|
|
// 更新本地状态
|
|
|
|
|
if (res.data && res.data.partnerstatus) {
|
|
|
|
|
wx.setStorageSync('settlementStatus', res.data.partnerstatus);
|
|
|
|
|
this.setData({
|
|
|
|
|
partnerstatus: res.data.partnerstatus
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 跳转到seller页面,不显示提示
|
|
|
|
|
wx.reLaunch({
|
|
|
|
|
url: '/pages/seller/index'
|
|
|
|
|
});
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
console.error('获取用户数据失败:', err);
|
|
|
|
|
// 即使获取失败也跳转到seller页面
|
|
|
|
|
wx.reLaunch({
|
|
|
|
|
url: '/pages/seller/index'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 重新提交备案
|
|
|
|
|
async resubmitApplication() {
|
|
|
|
|
try {
|
|
|
|
|
// 检查用户是否已登录
|
|
|
|
|
const openid = wx.getStorageSync('openid');
|
|
|
|
|
if (!openid) {
|
|
|
|
|
console.log('用户未登录,显示授权弹窗');
|
|
|
|
|
// 显示登录弹窗
|
|
|
|
|
this.setData({
|
|
|
|
|
showAuthModal: true
|
|
|
|
|
});
|
|
|
|
|
return; // 取消重新提交申请
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const API = require('../../utils/api.js');
|
|
|
|
|
const applicationId = wx.getStorageSync('applicationId');
|
|
|
|
|
|
|
|
|
|
if (!applicationId) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '未找到申请记录',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wx.showLoading({
|
|
|
|
|
title: '正在重新提交...',
|
|
|
|
|
mask: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const result = await API.resubmitSettlementApplication(applicationId);
|
|
|
|
|
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
|
|
|
|
|
if (result && result.success) {
|
|
|
|
|
// 更新本地状态
|
|
|
|
|
wx.setStorageSync('settlementStatus', 'underreview');
|
|
|
|
|
|
|
|
|
|
// 确保页面显示审核状态页面
|
|
|
|
|
this.setData({
|
|
|
|
|
currentStep: 3, // 确保显示审核状态页面
|
|
|
|
|
partnerstatus: 'underreview' // 使用数据库字段名 (原auditStatus)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '重新提交成功',
|
|
|
|
|
icon: 'success'
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: result.message || '重新提交失败',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
console.error('重新提交申请失败:', error);
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '重新提交失败,请重试',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 完成申请
|
|
|
|
|
completeApplication() {
|
|
|
|
|
// 更新入驻状态为审核通过
|
|
|
|
|
this.updateGlobalSettlementStatus('approved');
|
|
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '感谢您的提交,我们将尽快与您联系!',
|
|
|
|
|
icon: 'success'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 延迟跳转到seller页面
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
wx.reLaunch({
|
|
|
|
|
url: '/pages/seller/index'
|
|
|
|
|
});
|
|
|
|
|
}, 1500);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 重置申请流程
|
|
|
|
|
resetApplication() {
|
|
|
|
|
this.setData({
|
|
|
|
|
currentStep: 0,
|
|
|
|
|
collaborationid: '', // 使用数据库字段名 (原selectedIdentity)
|
|
|
|
|
showIdentityError: false,
|
|
|
|
|
company: '', // 使用数据库字段名 (原companyName)
|
|
|
|
|
showCompanyNameError: false,
|
|
|
|
|
province: '',
|
|
|
|
|
city: '',
|
|
|
|
|
district: '',
|
|
|
|
|
showRegionError: false,
|
|
|
|
|
detailedaddress: '', // 使用数据库字段名 (原detailAddress)
|
|
|
|
|
cooperation: '', // 使用数据库字段名 (原selectedCooperation)
|
|
|
|
|
showCooperationError: false,
|
|
|
|
|
businesslicenseurl: null, // 使用数据库字段名 (原businessLicenseFile)
|
|
|
|
|
proofurl: null, // 使用数据库字段名 (原animalQuarantineFile)
|
|
|
|
|
// idCardFile: null, // 已移除,法人身份证现在使用proofurl字段
|
|
|
|
|
brandurl: null, // 使用数据库字段名 (原brandAuthFile)
|
|
|
|
|
partnerstatus: 'underreview', // 使用数据库字段名 (原auditStatus)
|
|
|
|
|
showAuthModal: false,
|
|
|
|
|
applicationId: null,
|
|
|
|
|
auditFailedReason: ''
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 清除保存的进度
|
|
|
|
|
this.clearSettlementProgress();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 从服务器同步入驻状态
|
|
|
|
|
async syncSettlementStatus() {
|
|
|
|
|
try {
|
|
|
|
|
// 获取用户openid
|
|
|
|
|
const openid = wx.getStorageSync('openid');
|
|
|
|
|
if (!openid) {
|
|
|
|
|
console.log('未登录,无法同步入驻状态');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log('使用openid同步状态:', openid);
|
|
|
|
|
|
|
|
|
|
const result = await API.getUserInfo(openid);
|
|
|
|
|
|
|
|
|
|
if (result && result.success && result.data) {
|
|
|
|
|
const userData = result.data;
|
|
|
|
|
|
|
|
|
|
// 更新本地状态
|
|
|
|
|
wx.setStorageSync('hasSubmittedSettlement', true);
|
|
|
|
|
// 只有在有实际状态值时才设置,避免空值时默认为审核中
|
|
|
|
|
wx.setStorageSync('settlementStatus', userData.partnerstatus || '');
|
|
|
|
|
|
|
|
|
|
// 更新页面状态
|
|
|
|
|
this.setData({
|
|
|
|
|
partnerstatus: userData.partnerstatus || '', // 使用数据库字段名,不设置默认值
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log('已同步服务器入驻状态:', userData.partnerstatus);
|
|
|
|
|
|
|
|
|
|
// 根据partnerstatus更新页面步骤
|
|
|
|
|
if (userData.partnerstatus === 'approved') {
|
|
|
|
|
this.setData({
|
|
|
|
|
showGuidePage: false,
|
|
|
|
|
currentStep: 3
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('同步入驻状态失败:', error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|