diff --git a/pages/artisan/profile.vue b/pages/artisan/profile.vue index a85a145..7c9d35d 100644 --- a/pages/artisan/profile.vue +++ b/pages/artisan/profile.vue @@ -47,14 +47,17 @@ + style="width:26rpx;margin-top: 26rpx;position: relative;top: 4rpx;left: -10rpx;" + v-if="!userInfo.business_time"> - 待完善 + + {{ userInfo.business_time ? '已设置' : '待完善' }} + - + style="width:26rpx;margin-top: 26rpx;position: relative;top: 4rpx;left: -10rpx;" + v-if="!userInfo.servers_kill_arr || userInfo.servers_kill_arr.length === 0"> - 已认证 + + {{ (userInfo.servers_kill_arr && userInfo.servers_kill_arr.length > 0) ? '已设置' : + '待完善' }} + @@ -153,9 +161,14 @@ + style="width:26rpx;margin-top: 26rpx;position: relative;top: 4rpx;left: -10rpx;" + v-if="userInfo.credentials_state === 0"> - 审核中 + + {{ userInfo.credentials_state === 0 ? '待完善' : userInfo.credentials_state === 1 ? '审核中' : + '已认证' }} + @@ -475,7 +488,7 @@ console.log('调用接口获取用户信息,type:', type) // 调用接口获取用户信息 - const result = await request.post('/user/getuser', { + const result = await request.post('/sj/user/getUser', { type }) @@ -494,6 +507,7 @@ // 降级方案:尝试从其他可能的位置获取用户ID this.tryAlternativeUserInfo() + uni.hideLoading(); } }, @@ -617,15 +631,15 @@ }, navigateToQualification() { // 商家手艺人:资质信息 - if (this.identity == '2') { + if (this.userInfo.credentials_state == '1') { // 商家跳转到资质信息页面 uni.navigateTo({ - url: '/pages/shop/qualification_sj_change' + url: '/pages/ruzhu/ruzhu?type=1' }) } else { // 手艺人跳转到资质信息页面 uni.navigateTo({ - url: '/pages/artisan/qualification_syr_change' + url: '/pages/shop/qualification_sj_change' }) } }, diff --git a/pages/my/my.vue b/pages/my/my.vue index 51468d0..67f1fac 100644 --- a/pages/my/my.vue +++ b/pages/my/my.vue @@ -177,13 +177,13 @@ export default { title: "店铺装修", url: "https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/4b558456-2e38-4185-8713-d1f0e6645820.png", // https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/e6e72039-eec4-414c-8a86-aad404602962.png - path: "/pages/shop/staff/distribution-service", + path: "/pages/shop/qualification_sj_change", go_id_type: 1, }, { title: "财务管理", url: "https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/edafae37-8258-4e1c-9dcc-019484117047.png", - path: "/pages/shop/staff/distribution-service", + path: "/pages/wallet/wallet", go_id_type: 1, }, ], diff --git a/pages/ruzhu/ruzhu.vue b/pages/ruzhu/ruzhu.vue index 92ee357..aa64e95 100644 --- a/pages/ruzhu/ruzhu.vue +++ b/pages/ruzhu/ruzhu.vue @@ -1,731 +1,813 @@ - - - - - \ No newline at end of file diff --git a/pages/ruzhu/sj-info.vue b/pages/ruzhu/sj-info.vue index ae76b31..b5496e2 100644 --- a/pages/ruzhu/sj-info.vue +++ b/pages/ruzhu/sj-info.vue @@ -10,9 +10,8 @@ 资质照片 请保证照片上的文字清晰、无遮挡、证件边角可见 - - + + 商户类型 - + 证件号码 - + + mode="aspectFit" @click.stop="showTipPopup('uscc_num')"> 营业名称 - + 注册地区 - - {{ formData.register_region || '请选择' }} + + {{ formData.uscc_dependency || '请选择' }} - + 注册详细地址 - + + {{ formData.uscc_address || '请选择' }} + + - - - 营业执照有效期至: - - - - - - 永久有效 - - - - - - 指定日期有效 - - - - - - 开始日期 - - - {{ formData.idcard_start_date || '选择日期' }} - - - - - - 结束日期 - - - {{ formData.idcard_end_date || '选择日期' }} - - - - - + @@ -117,8 +76,9 @@ 身份证照片 请保证照片上的文字清晰、无遮挡、证件边角可见 - - + + 请上传身份证正面(人像面) - - + + 法人代表 - + 法人联系方式 + class="input" /> 法人身份证号 - + - 营业执照有效期至: + 身份证有效期: - - - + + 永久有效 - - - + + @@ -182,20 +143,22 @@ 开始日期 - - {{ formData.idcard_start_date || '选择日期' }} + + {{ formData.legal_idcard_expiry_start || '选择日期' }} - 结束日期 - - {{ formData.idcard_end_date || '选择日期' }} + + {{ formData.legal_idcard_expiry_end || '选择日期' }} - @@ -212,30 +175,34 @@ 行业资质 - + - × + × - - + + 添加照片 - - 其他资质 - - - - × - - - - 添加照片 - - - + + 其他资质 + + + + × + + + + 添加照片 + + + @@ -319,35 +286,33 @@ - \ No newline at end of file diff --git a/pages/shop/business-time.vue b/pages/shop/business-time.vue index fdc0739..ed88f68 100644 --- a/pages/shop/business-time.vue +++ b/pages/shop/business-time.vue @@ -125,7 +125,7 @@ export default { // 加载当前营业时间 async loadCurrentTime() { try { - const res = await request.post('/user/getuser', { + const res = await request.post('/sj/user/getuser', { type: 3 // 商家类型 }) console.log('获取用户信息响应:', res) diff --git a/pages/shop/qualification_sj_change.vue b/pages/shop/qualification_sj_change.vue index 96630ee..de7f180 100644 --- a/pages/shop/qualification_sj_change.vue +++ b/pages/shop/qualification_sj_change.vue @@ -6,7 +6,7 @@ 请变更您需要变更的信息 - + @@ -23,8 +23,11 @@ - - + + 请上传营业执照原件 @@ -36,27 +39,57 @@ 商户类型 - + 证件号码 - + - + 企业名称 - + + + + + + + + 注册地区 + + + + {{ displayData.uscc_dependency || '请选择' }} + + + + + + + + 注册详细地址 + + + + {{ displayData.uscc_address || '请选择' }} + + - @@ -73,25 +106,31 @@ 身份证照片 请保证图片上的文字清晰、无遮挡、证件边角可见 - + - - + + 请上传身份证正面(人像面) - + - - + + 请上传身份证反面(国徽面) @@ -104,22 +143,24 @@ 法人代表 - + - + 法人联系方式 - + 法人身份证号 - + @@ -128,13 +169,17 @@ - + 长久有效 - + 指定日期有效 @@ -148,30 +193,72 @@ 开始日期 - {{formatDateForDisplay(displayData.idcard_start_date) || '请选择日期'}} + {{ formatDateForDisplay(displayData.idcard_start_date) || '请选择日期' }} - + 结束日期 - + - {{formatDateForDisplay(displayData.idcard_end_date) || '请选择日期'}} + {{ formatDateForDisplay(displayData.idcard_end_date) || '请选择日期' }} - - + + + + + + 其他信息 + + + + 行业资质 + + + + × + + + + 添加照片 + + + 其他资质 + + + + × + + + + 添加照片 + + + + + @@ -223,12 +310,14 @@ - + - + - {{item.label}} + {{ item.label }} @@ -250,16 +339,16 @@ 确定 - + - {{year}}年 + {{ year }}年 - {{month}}月 + {{ month }}月 - {{day}}日 + {{ day }}日 @@ -271,8 +360,10 @@ - - + + {{ tipTitle }} @@ -290,15 +381,55 @@ + + + + + + + 选择注册地区 + × + + + + + + {{ item.province }} + + + + + {{ item.city }} + + + + + {{ item.area }} + + + + + + + 取消 + + + 确定 + + + + + - 美融融plus 对储存空间/照片权限申请说明 - 便于您使用该功能上传您的照片/图片/视频以及用于更换头像、发布商品等场景中读取相册和文件内容。 + 美融融plus 对储存空间/照片权限申请说明 + 便于您使用该功能上传您的照片/图片/视频以及用于更换头像、发布商品等场景中读取相册和文件内容。 - 美融融plus 对相机拍摄权限申请说明 - 便于您使用该功能上传您的照片/图片/视频以及用于更换头像、发布商品等场景中所需内容。 + 美融融plus 对相机拍摄权限申请说明 + 便于您使用该功能上传您的照片/图片/视频以及用于更换头像、发布商品等场景中所需内容。 @@ -310,15 +441,16 @@ import uploadImage from '../../utils/uploadImage'; import permissionUtils from '../../utils/per'; import locationService from '../../utils/locationService'; import { recognizeIdCard, recognizeBusinessLicense, formatDateFromNumber, parseValidPeriod } from '../../utils/orc'; +import ChinaCitys from '../../static/data/ChinaCitys.json'; export default { data() { const currentDate = new Date(); const currentYear = new Date().getFullYear(); - const years = Array.from({length: 130}, (_, i) => 1970 + i); - const months = Array.from({length: 12}, (_, i) => i + 1); - const days = Array.from({length: 31}, (_, i) => i + 1); - + const years = Array.from({ length: 130 }, (_, i) => 1970 + i); + const months = Array.from({ length: 12 }, (_, i) => i + 1); + const days = Array.from({ length: 31 }, (_, i) => i + 1); + return { // 页面状态 editable: false, @@ -331,7 +463,7 @@ export default { buttonAreaHeight: 120, backText: '', hasResubmitted: false, - + // 数据管理 originalData: {}, pendingData: {}, @@ -364,6 +496,14 @@ export default { isShowStoragePer: false, isShowCameraPer: false, + + showRegionPopupFlag: false, + ChinaCitys: ChinaCitys, + regionCitys: [], + regionAreas: [], + regionValue: [0, 0, 0], + addressListener: null, + sjAddressListener: null, } }, computed: { @@ -374,10 +514,15 @@ export default { onLoad(options) { console.log('资质信息变更页面开始加载...'); this.identity = getApp().globalData.artisanType; - + this.hasResubmitted = false; this.backText = ''; - + + this.regionCitys = this.ChinaCitys[0].citys; + this.regionAreas = this.regionCitys[0].areas; + + this.setupAddressListener(); + this.getUserInfo().then(() => { this.loadApplyDetails(); }); @@ -386,19 +531,18 @@ export default { this.getButtonAreaHeight(); }, onShow() { - // 只有在非编辑状态下才重新加载数据 + this.checkAddressData(); if (!this.editable) { - console.log('非编辑状态,刷新数据'); this.loadApplyDetails(); - if (this.auditStatus !== 3) { this.backText = ''; this.hasResubmitted = false; } - } else { - console.log('编辑状态,保持当前状态不刷新'); } }, + onUnload() { + this.removeAddressListener(); + }, methods: { /** * 识别营业执照 @@ -407,7 +551,7 @@ export default { try { this.isRecognizing = true; this.recognizeType = 'business_license'; - + // 调用OCR接口 const result = await recognizeBusinessLicense(imageUrl); console.log('营业执照识别结果:', result); @@ -422,7 +566,7 @@ export default { this.isRecognizing = false; return; } - + // 填充营业执照信息 let recognizedFields = 0; @@ -434,12 +578,12 @@ export default { // 如果是"无"或空值,设置为空字符串 this.displayData.uscc_name = ''; } - + if (result.uscc_num && result.uscc_num.trim()) { this.displayData.uscc_num = result.uscc_num; recognizedFields++; } - + // if (result.legal_name && result.legal_name.trim()) { // this.displayData.legal_name = result.legal_name; // recognizedFields++; @@ -460,14 +604,14 @@ export default { duration: 3000 }); } - + } catch (error) { uni.showToast({ title: error.message || '识别失败,请手动填写', icon: 'none', }); console.error('营业执照识别失败:', error); - + } finally { this.isRecognizing = false; } @@ -476,16 +620,16 @@ export default { // 检查营业执照识别结果是否有效 checkBusinessLicenseRecognition(result) { const requiredFields = ['uscc_num', 'uscc_name', 'legal_name', 'uscc_type']; - + for (const field of requiredFields) { if (result[field] && result[field].trim()) { return true; } } - + return false; }, - + /** * 识别身份证正面 */ @@ -493,18 +637,18 @@ export default { try { this.isRecognizing = true; this.recognizeType = 'idcard_front'; - + uni.showLoading({ title: '正在识别身份证正面...', mask: true }); - + // 调用OCR接口 const result = await recognizeIdCard(imageUrl, 1); // 验证是否真的识别到了数据 const hasRecognizedData = this.checkIdCardFrontRecognition(result); - + if (!hasRecognizedData) { uni.hideLoading(); uni.showToast({ @@ -515,22 +659,22 @@ export default { this.isRecognizing = false; return; } - + // 填充身份证正面信息 if (result.name) { this.displayData.legal_name = result.name; } - + if (result.id_number) { this.displayData.legal_idcard_num = result.id_number; } - + uni.hideLoading(); uni.showToast({ title: '身份证正面识别成功', icon: 'none' }); - + } catch (error) { console.error('身份证正面识别失败:', error); uni.hideLoading(); @@ -548,7 +692,7 @@ export default { checkIdCardFrontRecognition(result) { return (result.name && result.name.trim()) || (result.id_number && result.id_number.trim()); }, - + /** * 识别身份证反面 */ @@ -556,18 +700,18 @@ export default { try { this.isRecognizing = true; this.recognizeType = 'idcard_back'; - + uni.showLoading({ title: '正在识别身份证反面...', mask: true }); - + // 调用OCR接口 const result = await recognizeIdCard(imageUrl, 2); // 验证是否真的识别到了数据 const hasRecognizedData = this.checkIdCardBackRecognition(result); - + if (!hasRecognizedData) { uni.hideLoading(); uni.showToast({ @@ -578,15 +722,15 @@ export default { this.isRecognizing = false; return; } - + // 解析有效期 const validPeriod = parseValidPeriod(result.start_date, result.end_date); - + // 填充有效期数据 if (validPeriod.startDate) { this.displayData.idcard_start_date = validPeriod.startDate; } - + if (validPeriod.isPermanent) { this.displayData.legal_idcard_expiry_type = 1; this.displayData.idcard_end_date = '长久有效'; @@ -594,20 +738,20 @@ export default { this.displayData.legal_idcard_expiry_type = 2; this.displayData.idcard_end_date = validPeriod.endDate; } - + // 如果是长期有效,自动选择对应的选项 if (validPeriod.isPermanent) { this.setIdcardValidType('permanent'); } else { this.setIdcardValidType('date'); } - + uni.hideLoading(); uni.showToast({ title: '身份证反面识别成功', icon: 'none' }); - + } catch (error) { console.error('身份证反面识别失败:', error); uni.hideLoading(); @@ -623,8 +767,8 @@ export default { // 检查身份证反面识别结果是否有效 checkIdCardBackRecognition(result) { - return (result.start_date && result.start_date.trim()) || - (result.end_date && result.end_date.trim()); + return (result.start_date && result.start_date.trim()) || + (result.end_date && result.end_date.trim()); }, // 获取商户类型文本 @@ -637,11 +781,11 @@ export default { getUserInfo() { return new Promise((resolve, reject) => { const userType = 3; - request.post('/user/getuser', { type: userType }).then(result => { + request.post('/sj/user/getUser', { type: userType }).then(result => { if (result.state === 1) { this.userId = result.data.id; console.log('用户ID获取成功:', this.userId); - + this.populateFormDataFromUserInfo(result.data); resolve(this.userId); } else { @@ -658,13 +802,20 @@ export default { // 从用户信息中填充表单数据 populateFormDataFromUserInfo(userData) { console.log('从用户信息填充表单数据:', userData); - + // 初始化老数据 this.originalData = { - uscc_type: userData.uscc_type ? String(userData.uscc_type) : null, // 转换为字符串 + uscc_type: userData.uscc_type ? String(userData.uscc_type) : null, uscc_photo: userData.uscc_photo || '', uscc_num: userData.uscc_num || '', uscc_name: userData.uscc_name || '', + uscc_dependency: userData.uscc_dependency || '', + uscc_address: userData.uscc_address || '', + uscc_province: userData.uscc_province || '', + uscc_city: userData.uscc_city || '', + uscc_area: userData.uscc_area || '', + longitude: userData.longitude || '', + latitude: userData.latitude || '', uscc_expiry_type: userData.uscc_expiry_type || null, uscc_expiry: userData.uscc_expiry || '', license_start_date: '', @@ -677,15 +828,30 @@ export default { idcard_start_date: '', idcard_end_date: '', legal_idcard_positive: userData.legal_idcard_positive || '', - legal_idcard_negative: userData.legal_idcard_negative || '' + legal_idcard_negative: userData.legal_idcard_negative || '', + qualifications_sector: [], + qualifications_other: [] }; - // 处理营业执照有效期显示 + if (userData.qualifications_sector) { + try { + this.originalData.qualifications_sector = typeof userData.qualifications_sector === 'string' ? JSON.parse(userData.qualifications_sector) : userData.qualifications_sector; + } catch (e) { + this.originalData.qualifications_sector = []; + } + } + if (userData.qualifications_other) { + try { + this.originalData.qualifications_other = typeof userData.qualifications_other === 'string' ? JSON.parse(userData.qualifications_other) : userData.qualifications_other; + } catch (e) { + this.originalData.qualifications_other = []; + } + } + if (this.originalData.uscc_expiry) { this.processLicenseExpiry(this.originalData.uscc_expiry, this.originalData); } - // 处理身份证有效期显示 if (this.originalData.legal_idcard_expiry) { this.processIdcardExpiry(this.originalData.legal_idcard_expiry, this.originalData); } @@ -704,18 +870,18 @@ export default { // 处理营业执照有效期 processLicenseExpiry(expiry, targetData) { if (!expiry) return; - + console.log('处理营业执照有效期:', expiry); - + // 处理多种可能的分隔符 if (expiry.includes('——') || expiry.includes('--') || expiry.includes('-')) { const separator = expiry.includes('——') ? '——' : (expiry.includes('--') ? '--' : '-'); const [startStr, endStr] = expiry.split(separator); const startDate = startStr.trim(); const endDate = endStr.trim(); - + console.log('营业执照开始日期:', startDate, '结束日期:', endDate); - + if (endDate === '长久' || !endDate) { targetData.uscc_expiry_type = 1; targetData.license_start_date = this.formatDateFromBackend(startDate); @@ -734,18 +900,18 @@ export default { // 处理身份证有效期 processIdcardExpiry(expiry, targetData) { if (!expiry) return; - + console.log('处理身份证有效期:', expiry); - + // 处理多种可能的分隔符 if (expiry.includes('——') || expiry.includes('--') || expiry.includes('-')) { const separator = expiry.includes('——') ? '——' : (expiry.includes('--') ? '--' : '-'); const [startStr, endStr] = expiry.split(separator); const startDate = startStr.trim(); const endDate = endStr.trim(); - + console.log('身份证开始日期:', startDate, '结束日期:', endDate); - + if (endDate === '长久' || !endDate) { targetData.legal_idcard_expiry_type = 1; targetData.idcard_start_date = this.formatDateFromBackend(startDate); @@ -780,19 +946,19 @@ export default { }); console.log('资质信息申请详情接口返回:', res); - + if (res.code === 200) { if (res.data) { const detail = res.data; console.log('找到申请记录:', detail); - + const statusCheck = this.intelligentStatusCheck(detail); - + if (statusCheck.isValid) { this.applyId = detail.id; this.auditStatus = statusCheck.status; this.backText = statusCheck.backText; - + console.log('申请记录状态:', { auditStatus: this.auditStatus, backText: this.backText @@ -803,9 +969,9 @@ export default { this.backText = ''; this.hasResubmitted = false; } - + this.updatePendingDataFromDetail(detail); - + if (this.auditStatus === 2) { this.originalData = { ...this.pendingData }; console.log('审核通过,同步originalData到pendingData'); @@ -832,10 +998,10 @@ export default { this.backText = ''; this.applyId = null; } - + await this.refreshUserData(); this.updatePageStatus(); - + } catch (error) { console.error('加载申请详情失败:', error); this.backText = ''; @@ -847,12 +1013,19 @@ export default { // 从申请记录详情更新 pendingData updatePendingDataFromDetail(detail) { console.log('从申请记录更新pendingData:', detail); - + this.pendingData = { uscc_type: detail.uscc_type ? String(detail.uscc_type) : this.originalData.uscc_type, uscc_photo: detail.uscc_photo || this.originalData.uscc_photo, uscc_num: detail.uscc_num || this.originalData.uscc_num, uscc_name: detail.uscc_name || this.originalData.uscc_name, + uscc_dependency: detail.uscc_dependency || this.originalData.uscc_dependency, + uscc_address: detail.uscc_address || this.originalData.uscc_address, + uscc_province: detail.uscc_province || this.originalData.uscc_province, + uscc_city: detail.uscc_city || this.originalData.uscc_city, + uscc_area: detail.uscc_area || this.originalData.uscc_area, + longitude: detail.longitude || this.originalData.longitude || '', + latitude: detail.latitude || this.originalData.latitude || '', uscc_expiry_type: detail.uscc_expiry_type || this.originalData.uscc_expiry_type, uscc_expiry: detail.uscc_expiry || this.originalData.uscc_expiry, license_start_date: '', @@ -865,9 +1038,26 @@ export default { idcard_start_date: '', idcard_end_date: '', legal_idcard_positive: detail.legal_idcard_positive || this.originalData.legal_idcard_positive, - legal_idcard_negative: detail.legal_idcard_negative || this.originalData.legal_idcard_negative + legal_idcard_negative: detail.legal_idcard_negative || this.originalData.legal_idcard_negative, + qualifications_sector: this.originalData.qualifications_sector || [], + qualifications_other: this.originalData.qualifications_other || [] }; + if (detail.qualifications_sector) { + try { + this.pendingData.qualifications_sector = typeof detail.qualifications_sector === 'string' ? JSON.parse(detail.qualifications_sector) : detail.qualifications_sector; + } catch (e) { + this.pendingData.qualifications_sector = this.originalData.qualifications_sector || []; + } + } + if (detail.qualifications_other) { + try { + this.pendingData.qualifications_other = typeof detail.qualifications_other === 'string' ? JSON.parse(detail.qualifications_other) : detail.qualifications_other; + } catch (e) { + this.pendingData.qualifications_other = this.originalData.qualifications_other || []; + } + } + console.log('处理前的pendingData日期字段:', { uscc_expiry: this.pendingData.uscc_expiry, legal_idcard_expiry: this.pendingData.legal_idcard_expiry @@ -891,14 +1081,14 @@ export default { try { console.log('刷新商家最新数据...'); const userType = 3; - const result = await request.post('/user/getuser', { type: userType }); + const result = await request.post('/sj/user/getUser', { type: userType }); if (result.state === 1 && result.data) { const userData = result.data; console.log('获取到商家最新数据:', userData); - + this.updateOriginalDataFromUser(userData); - + // 只有在审核通过时才同步 pendingData 到 originalData if (this.auditStatus === 2) { this.pendingData = { ...this.originalData }; @@ -906,7 +1096,7 @@ export default { } else { console.log('非审核通过状态,保持pendingData不变'); } - + console.log('刷新后的数据状态:', { originalData: this.originalData, pendingData: this.pendingData, @@ -930,12 +1120,19 @@ export default { // 从用户数据更新原始数据 updateOriginalDataFromUser(userData) { console.log('从用户数据更新原始数据:', userData); - + this.originalData = { uscc_type: userData.uscc_type ? String(userData.uscc_type) : null, uscc_photo: userData.uscc_photo || '', uscc_num: userData.uscc_num || '', uscc_name: userData.uscc_name || '', + uscc_dependency: userData.uscc_dependency || '', + uscc_address: userData.uscc_address || '', + uscc_province: userData.uscc_province || '', + uscc_city: userData.uscc_city || '', + uscc_area: userData.uscc_area || '', + longitude: userData.longitude || '', + latitude: userData.latitude || '', uscc_expiry_type: userData.uscc_expiry_type || null, uscc_expiry: userData.uscc_expiry || '', license_start_date: '', @@ -948,15 +1145,30 @@ export default { idcard_start_date: '', idcard_end_date: '', legal_idcard_positive: userData.legal_idcard_positive || '', - legal_idcard_negative: userData.legal_idcard_negative || '' + legal_idcard_negative: userData.legal_idcard_negative || '', + qualifications_sector: [], + qualifications_other: [] }; - // 处理营业执照有效期显示 + if (userData.qualifications_sector) { + try { + this.originalData.qualifications_sector = typeof userData.qualifications_sector === 'string' ? JSON.parse(userData.qualifications_sector) : userData.qualifications_sector; + } catch (e) { + this.originalData.qualifications_sector = []; + } + } + if (userData.qualifications_other) { + try { + this.originalData.qualifications_other = typeof userData.qualifications_other === 'string' ? JSON.parse(userData.qualifications_other) : userData.qualifications_other; + } catch (e) { + this.originalData.qualifications_other = []; + } + } + if (this.originalData.uscc_expiry) { this.processLicenseExpiry(this.originalData.uscc_expiry, this.originalData); } - // 处理身份证有效期显示 if (this.originalData.legal_idcard_expiry) { this.processIdcardExpiry(this.originalData.legal_idcard_expiry, this.originalData); } @@ -976,12 +1188,12 @@ export default { backText: '' }; } - + if (detail.apply_time) { const applyDate = new Date(detail.apply_time); const now = new Date(); const daysDiff = (now - applyDate) / (1000 * 60 * 60 * 24); - + if (daysDiff > 7 && this.originalData.uscc_name !== detail.uscc_name) { console.log('智能判断:申请记录已过期,忽略历史记录'); return { @@ -991,7 +1203,7 @@ export default { }; } } - + return { isValid: true, status: detail.apply_state, @@ -1043,7 +1255,7 @@ export default { } this.updateNavTitle(); - + console.log('最终页面状态:', { auditStatus: this.auditStatus, backText: this.backText, @@ -1067,7 +1279,7 @@ export default { startChange() { this.editable = true; this.buttonType = 'edit'; - this.displayData = { ...this.pendingData }; + this.displayData = { ...this.pendingData }; this.updateNavTitle(); }, @@ -1083,7 +1295,7 @@ export default { togglePendingData() { this.showPendingData = !this.showPendingData; console.log('切换显示待审核数据:', this.showPendingData); - + if (this.showPendingData) { // 显示待审核数据 this.displayData = { ...this.pendingData }; @@ -1099,11 +1311,11 @@ export default { // 提交变更 async submitChange() { console.log('开始提交资质信息变更...'); - + if (!this.validateForm()) { return; } - + try { uni.showLoading({ title: '提交中...' @@ -1114,7 +1326,7 @@ export default { name: this.displayData.legal_name, idcard: this.displayData.legal_idcard_num }); - + if (checkRes.Code == '401') { uni.hideLoading(); uni.showToast({ @@ -1123,7 +1335,7 @@ export default { }); return; } - + if (checkRes.ResultObject?.BizCode != '1') { uni.hideLoading(); uni.showToast({ @@ -1132,13 +1344,18 @@ export default { }); return; } - + const submitData = { apply_type: this.applyType, uscc_type: this.displayData.uscc_type, uscc_photo: this.displayData.uscc_photo, uscc_num: this.displayData.uscc_num, uscc_name: this.displayData.uscc_name, + uscc_dependency: this.displayData.uscc_dependency, + uscc_address: this.displayData.uscc_address, + uscc_province: this.displayData.uscc_province, + uscc_city: this.displayData.uscc_city, + uscc_area: this.displayData.uscc_area, uscc_expiry_type: this.displayData.uscc_expiry_type, uscc_expiry: this.displayData.uscc_expiry, legal_name: this.displayData.legal_name, @@ -1147,7 +1364,9 @@ export default { legal_idcard_expiry_type: this.displayData.legal_idcard_expiry_type, legal_idcard_expiry: this.displayData.legal_idcard_expiry, legal_idcard_positive: this.displayData.legal_idcard_positive, - legal_idcard_negative: this.displayData.legal_idcard_negative + legal_idcard_negative: this.displayData.legal_idcard_negative, + qualifications_sector: JSON.stringify(this.displayData.qualifications_sector || []), + qualifications_other: JSON.stringify(this.displayData.qualifications_other || []) }; // 处理营业执照有效期 @@ -1169,17 +1388,17 @@ export default { } console.log('提交的数据:', submitData); - + const res = await request.post('/sj/userSjAuth/apply', submitData); - + uni.hideLoading(); - + if (res.code === 200) { uni.showToast({ title: '提交成功', icon: 'none' }); - + // 先更新 pendingData,再设置其他状态 this.pendingData = { ...this.displayData }; console.log('提交成功,更新pendingData:', this.pendingData); @@ -1188,21 +1407,21 @@ export default { this.backText = ''; this.hasResubmitted = true; this.applyId = res.data?.id || this.applyId; - + console.log('申请ID:', this.applyId); - + this.editable = false; this.buttonType = 'view'; this.showAuditTip = true; this.showPendingData = false; this.displayData = { ...this.originalData }; - + this.updateNavTitle(); - + setTimeout(() => { this.loadApplyDetails(); }, 1500); - + } else { uni.showToast({ title: res.msg || '提交失败', @@ -1220,16 +1439,95 @@ export default { }, showPermissionDialog(title, content) { - return new Promise((resolve) => { - uni.showModal({ - title, - content, - confirmText: '去开启', - success(res) { - resolve(res.confirm); - } - }); + return new Promise((resolve) => { + uni.showModal({ + title, + content, + confirmText: '去开启', + success(res) { + resolve(res.confirm); + } }); + }); + }, + + showRegionPicker() { + this.regionCitys = this.ChinaCitys[0].citys; + this.regionAreas = this.regionCitys[0].areas; + this.showRegionPopupFlag = true; + }, + + hideRegionPopup() { + this.showRegionPopupFlag = false; + }, + + bindChangeRegion(e) { + this.regionValue = e.detail.value; + let index1 = e.detail.value[0] || 0; + let index2 = e.detail.value[1] || 0; + this.regionCitys = this.ChinaCitys[index1].citys; + this.regionAreas = this.regionCitys[index2].areas; + }, + + confirmRegionSelect() { + let valueArr = this.regionValue; + let index1 = valueArr[0] || 0; + let index2 = valueArr[1] || 0; + let index3 = valueArr[2] || 0; + let province = this.ChinaCitys[index1].province; + let city = this.regionCitys[index2].city; + let area = this.regionAreas[index3].area; + this.$set(this.displayData, 'uscc_dependency', province + '-' + city + '-' + area); + if (this.ChinaCitys[index1] && this.ChinaCitys[index1].code) { + this.$set(this.displayData, 'uscc_province', String(this.ChinaCitys[index1].code).substring(0, 6)); + } + if (this.regionCitys[index2] && this.regionCitys[index2].code) { + this.$set(this.displayData, 'uscc_city', String(this.regionCitys[index2].code).substring(0, 6)); + } + if (this.regionAreas[index3] && this.regionAreas[index3].code) { + this.$set(this.displayData, 'uscc_area', String(this.regionAreas[index3].code).substring(0, 6)); + } + this.$set(this.displayData, 'uscc_address', ''); + this.$set(this.displayData, 'longitude', ''); + this.$set(this.displayData, 'latitude', ''); + this.hideRegionPopup(); + }, + + chooseMultiImage(type) { + const current = this.displayData[type] || []; + const remaining = 9 - current.length; + if (remaining <= 0) { + uni.showToast({ title: '最多上传9张图片', icon: 'none' }); + return; + } + uni.chooseImage({ + count: remaining, + sizeType: ['compressed'], + sourceType: ['album', 'camera'], + success: async (res) => { + if (!res.tempFilePaths || res.tempFilePaths.length === 0) return; + uni.showLoading({ title: '上传中...' }); + for (const tempFilePath of res.tempFilePaths) { + const file = { path: tempFilePath, size: 0 }; + try { + const url = await this.directUpload(file, this.userId, 3, type); + if (url) { + current.push(url); + } + } catch (e) { + console.error('上传失败:', e); + } + } + this.$set(this.displayData, type, [...current]); + uni.hideLoading(); + } + }); + }, + + removeImage(type, index) { + const list = [...(this.displayData[type] || [])]; + list.splice(index, 1); + this.$set(this.displayData, type, list); }, // 表单验证 @@ -1239,18 +1537,20 @@ export default { { field: 'uscc_type', message: '请输入商户类型' }, { field: 'uscc_num', message: '请输入营业执照号码' }, { field: 'uscc_name', message: '请输入企业名称' }, + { field: 'uscc_dependency', message: '请选择注册地区' }, + { field: 'uscc_address', message: '请输入注册详细地址' }, { field: 'legal_idcard_positive', message: '请上传身份证正面照片' }, { field: 'legal_idcard_negative', message: '请上传身份证反面照片' }, { field: 'legal_name', message: '请输入法人代表' }, { field: 'legal_phone', message: '请输入法人联系方式' }, { field: 'legal_idcard_num', message: '请输入法人身份证号' }, - { - condition: () => !this.displayData.legal_idcard_expiry_type, - message: '请选择身份证有效期类型' + { + condition: () => !this.displayData.legal_idcard_expiry_type, + message: '请选择身份证有效期类型' }, - { - condition: () => !this.displayData.idcard_start_date, - message: '请选择身份证开始日期' + { + condition: () => !this.displayData.idcard_start_date, + message: '请选择身份证开始日期' }, { condition: () => { @@ -1260,14 +1560,14 @@ export default { // 如果选择长久有效,则不需要结束日期 return false; }, - message: '请选择身份证结束日期' + message: '请选择身份证结束日期' }, ]; for (let rule of validationRules) { let isValid = true; - + if (rule.field) { if (!this.displayData[rule.field]) { isValid = false; @@ -1277,7 +1577,7 @@ export default { isValid = false; } } - + if (!isValid) { uni.showToast({ title: rule.message, @@ -1286,7 +1586,7 @@ export default { return false; } } - + // 验证手机号格式 if (!/^1[3-9]\d{9}$/.test(this.displayData.legal_phone)) { uni.showToast({ @@ -1295,7 +1595,7 @@ export default { }); return false; } - + // 验证身份证格式 if (!/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(this.displayData.legal_idcard_num)) { uni.showToast({ @@ -1304,7 +1604,7 @@ export default { }); return false; } - + return true; }, @@ -1332,7 +1632,7 @@ export default { } } }, - + // 设置身份证有效期类型 setIdcardValidType(type) { if (type === 'permanent') { @@ -1350,12 +1650,12 @@ export default { formatDateForDisplay(dateStr) { if (!dateStr) return ''; if (dateStr === '长久有效') return '长久有效'; - + if (dateStr.includes('-')) { const [year, month, day] = dateStr.split('-'); return `${year}年${parseInt(month)}月${parseInt(day)}日`; } - + return dateStr; }, @@ -1363,7 +1663,7 @@ export default { formatDateForBackend(dateStr) { if (!dateStr) return ''; if (dateStr === '长久有效') return ''; - + const match = dateStr.match(/(\d+)年(\d+)月(\d+)日/); if (match) { const year = match[1]; @@ -1371,17 +1671,17 @@ export default { const day = match[3].padStart(2, '0'); return `${year}-${month}-${day}`; } - + return dateStr; }, // 打开日期选择器 openDatePicker(field) { this.currentDateField = field; - + const currentDate = new Date(); let initialDate = currentDate; - + if (this.displayData[field] && this.displayData[field] !== '长久有效') { const dateStr = this.displayData[field]; const match = dateStr.match(/(\d+)年(\d+)月(\d+)日/); @@ -1389,28 +1689,28 @@ export default { initialDate = new Date(parseInt(match[1]), parseInt(match[2]) - 1, parseInt(match[3])); } } - + const yearIndex = this.years.indexOf(initialDate.getFullYear()); const monthIndex = initialDate.getMonth(); const dayIndex = initialDate.getDate() - 1; - + this.dateValue = [ yearIndex >= 0 ? yearIndex : 0, monthIndex, dayIndex ]; - + this.showDatePickerFlag = true; }, - + hideDatePicker() { this.showDatePickerFlag = false; }, - + bindDateChange(e) { this.dateValue = e.detail.value; }, - + confirmDate() { const [yearIndex, monthIndex, dayIndex] = this.dateValue; const year = this.years[yearIndex]; @@ -1420,7 +1720,7 @@ export default { const selectedDate = new Date(year, month - 1, day); const today = new Date(); today.setHours(0, 0, 0, 0); - + if (this.currentDateField.endsWith('_start_date')) { if (selectedDate > today) { uni.showToast({ @@ -1429,7 +1729,7 @@ export default { }); return; } - + const relatedEndField = this.currentDateField.replace('_start_date', '_end_date'); if (this.displayData[relatedEndField] && this.displayData[relatedEndField] !== '长久有效') { const endDateStr = this.displayData[relatedEndField]; @@ -1445,7 +1745,7 @@ export default { } } } - + // 如果是身份证开始日期,自动计算20年后的结束日期 if (this.currentDateField === 'idcard_start_date') { const endYear = year + 20; @@ -1478,7 +1778,7 @@ export default { } } } - + this.displayData[this.currentDateField] = dateStr; this.hideDatePicker(); }, @@ -1487,15 +1787,15 @@ export default { showMerchantTypePicker() { this.showMerchantTypePickerFlag = true; }, - + hideMerchantTypePicker() { this.showMerchantTypePickerFlag = false; }, - + selectMerchantType(item) { this.displayData.uscc_type = item.value; }, - + confirmMerchantType() { this.hideMerchantTypePicker(); }, @@ -1516,7 +1816,7 @@ export default { image: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/24859872-da37-4beb-8e33-7743813bb5a1' } }; - + if (tipConfig[field]) { this.tipTitle = tipConfig[field].title; this.tipImage = tipConfig[field].image; @@ -1528,6 +1828,163 @@ export default { this.showTipPopupFlag = false; }, + buildRegionTextForSearch() { + const dependency = String(this.displayData.uscc_dependency || '').trim(); + if (!dependency) return ''; + const parts = dependency.split('-'); + const province = parts[0] || ''; + const city = parts[1] || ''; + const district = parts[2] || ''; + let regionText = ''; + if (province) regionText += province; + if (city && city !== province) regionText += city; + if (district) regionText += district; + return regionText; + }, + + getAddressValueForSearch() { + const rawAddress = String(this.displayData.uscc_address || '').trim(); + if (!rawAddress) return ''; + const dependencyText = String(this.displayData.uscc_dependency || '').trim(); + const regionText = this.buildRegionTextForSearch(); + let detail = rawAddress; + if (regionText && detail.indexOf(regionText) === 0) { + detail = detail.slice(regionText.length).trim(); + } else if (dependencyText && detail.indexOf(dependencyText) === 0) { + detail = detail.slice(dependencyText.length).trim(); + } + detail = detail.replace(/^[\s,-]+/, '').trim(); + return detail || rawAddress; + }, + + getAddressInfo() { + const dependency = String(this.displayData.uscc_dependency || '').trim(); + const dependencyCode = String(this.displayData.uscc_area || '').trim(); + const address = this.getAddressValueForSearch(); + const longitude = String(this.displayData.longitude || '').trim(); + const latitude = String(this.displayData.latitude || '').trim(); + + const hasDependency = !!dependency; + const hasAddress = !!address; + const hasLocation = !!(longitude && latitude); + + let params = 'source=sj_change'; + + if (hasDependency) { + params += `&dependency=${encodeURIComponent(dependency)}`; + if (dependencyCode) { + params += `&dependency_code=${dependencyCode}`; + } + } + if (hasAddress) { + params += `&address=${encodeURIComponent(address)}`; + } + if (hasLocation) { + params += `&longitude=${longitude}&latitude=${latitude}`; + } + if (!hasDependency && !hasAddress && !hasLocation) { + params += '&init_current_location=1&silent_locate=1'; + } + + uni.navigateTo({ + url: `/pages/address/search?${params}` + }); + }, + + setupAddressListener() { + this.addressListener = (addressData) => { + this.handleAddressSelected(addressData); + }; + this.sjAddressListener = (addressData) => { + this.handleAddressSelected(addressData); + }; + uni.$on('address-selected', this.addressListener); + uni.$on('address-selected-for-sj', this.sjAddressListener); + }, + + removeAddressListener() { + if (this.addressListener) { + uni.$off('address-selected', this.addressListener); + this.addressListener = null; + } + if (this.sjAddressListener) { + uni.$off('address-selected-for-sj', this.sjAddressListener); + this.sjAddressListener = null; + } + }, + + checkAddressData() { + try { + const storedAddress = uni.getStorageSync('sj_selected_address'); + if (storedAddress) { + this.handleAddressSelected(storedAddress); + uni.removeStorageSync('sj_selected_address'); + return; + } + } catch (e) { } + + if (getApp().globalData && getApp().globalData.selectedAddress) { + this.handleAddressSelected(getApp().globalData.selectedAddress); + delete getApp().globalData.selectedAddress; + } + + try { + const selectedAddress = uni.getStorageSync('selectedAddress'); + if (selectedAddress) { + this.handleAddressSelected(selectedAddress); + uni.removeStorageSync('selectedAddress'); + } + } catch (e) { } + }, + + handleAddressSelected(addressData) { + if (!addressData) return; + + let detailAddress = ''; + if (addressData.address) { + detailAddress = String(addressData.address).trim(); + } else if (addressData.name) { + detailAddress = String(addressData.name).trim(); + const regionParts = []; + if (addressData.pname) regionParts.push(addressData.pname); + if (addressData.cityname && addressData.cityname !== addressData.pname) regionParts.push(addressData.cityname); + if (addressData.adname) regionParts.push(addressData.adname); + const regionText = regionParts.join(''); + if (regionText && detailAddress.indexOf(regionText) === 0) { + detailAddress = detailAddress.slice(regionText.length).trim(); + } + detailAddress = detailAddress.replace(/^[\s,-]+/, '').trim(); + } + + this.$set(this.displayData, 'uscc_address', detailAddress); + + if (addressData.location) { + const [longitude, latitude] = String(addressData.location).split(','); + this.$set(this.displayData, 'longitude', longitude || ''); + this.$set(this.displayData, 'latitude', latitude || ''); + } + + if (addressData.pname || addressData.cityname || addressData.adname) { + const locationParts = []; + if (addressData.pname) locationParts.push(addressData.pname); + if (addressData.cityname) locationParts.push(addressData.cityname); + if (addressData.adname) locationParts.push(addressData.adname); + this.$set(this.displayData, 'uscc_dependency', locationParts.join('-')); + } + + if (addressData.provinceCode) { + this.$set(this.displayData, 'uscc_province', String(addressData.provinceCode).substring(0, 6)); + } + if (addressData.cityCode) { + this.$set(this.displayData, 'uscc_city', String(addressData.cityCode).substring(0, 6)); + } + if (addressData.districtCode) { + this.$set(this.displayData, 'uscc_area', String(addressData.districtCode).substring(0, 6)); + } + + this.$forceUpdate(); + }, + // 图片上传方法 async chooseImage(type) { if (!this.editable) return; @@ -1626,12 +2083,12 @@ export default { console.log('_openCamera - 开始上传图片,字段类型:', type, '用户ID:', this.userId); const result = await this.directUpload(file, this.userId, 3, type); - + uni.hideLoading(); if (result) { this.displayData[type] = result; - + // 上传成功后自动识别 if (type === 'uscc_photo') { await this.recognizeBusinessLicense(result); @@ -1644,7 +2101,7 @@ export default { } catch (err) { uni.hideLoading(); console.log('上传图片错误:', err); - + if (!err.errMsg || !err.errMsg.includes('cancel')) { uni.showToast({ title: '上传失败,请重试', @@ -1661,7 +2118,7 @@ export default { let artisan = type == 1 ? 'yh' : type == 2 ? 'syr' : type == 3 ? 'sj' : ''; console.log('directUpload - artisan类型:', artisan, '原始type:', type); - + let fileExtension = 'jpg'; if (file.path.includes('.')) { let parts = file.path.split('.'); @@ -1670,15 +2127,15 @@ export default { fileExtension = ext; } } - + // 添加时间戳确保文件名唯一 const timestamp = Date.now(); const random = Math.floor(Math.random() * 10000); let name = `${userId}_${artisan}_${fieldName}_${timestamp}_${random}.${fileExtension}`; console.log('唯一文件名(包含时间戳):', name); - const ossConfig = await request.post('/user/getalioss', {type: type, kind: 1}); - + const ossConfig = await request.post('/user/getalioss', { type: type, kind: 1 }); + return await new Promise((resolve, reject) => { uni.uploadFile({ url: ossConfig.host, @@ -1703,7 +2160,7 @@ export default { fail: reject }); }); - + } catch (error) { console.error('直接上传失败:', error); throw error; @@ -1960,8 +2417,13 @@ export default { } @keyframes spin { - 0% { transform: rotate(0deg); } - 100% { transform: rotate(360deg); } + 0% { + transform: rotate(0deg); + } + + 100% { + transform: rotate(360deg); + } } .picker-content { @@ -2149,7 +2611,9 @@ export default { margin-top: 20rpx; } -.change-info-btn, .view-change-btn, .resubmit-btn { +.change-info-btn, +.view-change-btn, +.resubmit-btn { background: linear-gradient(180deg, #f52540 0%, #e8101e 100%); } @@ -2277,7 +2741,8 @@ export default { color: #FFFFFF; } -.cancel-text, .confirm-text { +.cancel-text, +.confirm-text { font-size: 32rpx; padding: 16rpx; } @@ -2407,8 +2872,83 @@ export default { } .permission.transform { - top: calc(var(--status-bar-height) + 88rpx + 20rpx); - opacity: 1; - visibility: visible; + top: calc(var(--status-bar-height) + 88rpx + 20rpx); + opacity: 1; + visibility: visible; +} + +.image-list { + display: flex; + flex-wrap: wrap; + gap: 16rpx; + margin-top: 16rpx; +} + +.image-item { + position: relative; + width: 200rpx; + height: 200rpx; +} + +.qualification-image { + width: 200rpx; + height: 200rpx; + border-radius: 12rpx; +} + +.image-delete { + position: absolute; + top: -10rpx; + right: -10rpx; + width: 36rpx; + height: 36rpx; + background: #E8101E; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + color: #FFFFFF; + font-size: 28rpx; +} + +.image-add { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + border: 2rpx dashed #DDDDDD; + width: 214rpx; + height: 214rpx; + background: #F5F5F5; + border-radius: 20rpx; +} + +.upload-icon-small { + width: 48rpx; + height: 48rpx; + margin-bottom: 8rpx; +} + +.add-text { + font-size: 22rpx; + color: #999999; +} + +.region-body { + margin-top: 20rpx; +} + +.region-body .picker-scroll { + height: 400rpx; +} + +.form-item-image-box { + display: flex; + flex-direction: column; + padding: 24rpx; +} + +.form-item-image-box .label { + margin-bottom: 16rpx; } \ No newline at end of file diff --git a/utils/request.js b/utils/request.js index 5f05fbc..50b9276 100644 --- a/utils/request.js +++ b/utils/request.js @@ -187,13 +187,22 @@ const request = async (options, isUpdate) => { uni.request({ ...options, success: (res) => { - // #ifdef H5 - if (!options.hideLoading) { - uni.hideLoading() + // #ifdef H5 + if (!options.hideLoading) { + uni.hideLoading() + } + // #endif + try { + const result = responseInterceptor(options, res, resolve, reject) + if (result && typeof result.then === 'function') { + result.then(data => resolve(data)).catch(err => reject(err)) + } else { + resolve(result) } - // #endif - resolve(responseInterceptor(options, res, resolve, reject)) - }, + } catch (err) { + reject(err) + } + }, fail: (err) => { // #ifdef H5 if (!options.hideLoading) { @@ -221,6 +230,7 @@ const request = async (options, isUpdate) => { // 处理 401 未授权 async function handleUnauthorized(originalRequest, resolve, reject) { if (!getToken()) { + reject(new Error('未登录')) return redirectToLogin() } // 如果正在刷新 Token,将请求加入队列 @@ -246,7 +256,7 @@ async function handleUnauthorized(originalRequest, resolve, reject) { } catch (error) { removeToken() redirectToLogin() - // reject(error) + reject(error) return error } finally { isRefreshing = false