1240 lines
38 KiB
Vue
1240 lines
38 KiB
Vue
<template>
|
||
<view class="ruzhu-page">
|
||
<!-- 顶部导航栏 - 根据身份动态显示标题 -->
|
||
<custom-navbar :title="navTitle" :showBack="true"></custom-navbar>
|
||
|
||
<!-- 步骤切换 -->
|
||
<step-tab :currentStep="currentStep" :identity="identity"></step-tab>
|
||
|
||
<!-- 内容区域根据身份和步骤显示不同内容 -->
|
||
<view class="content">
|
||
<!-- 入驻协议内容 -->
|
||
<view class="xieyi_content" v-if="currentStep === 0">
|
||
<rich-text :nodes="textData.text"></rich-text>
|
||
</view>
|
||
|
||
<!-- 步骤1: 根据身份显示不同内容 -->
|
||
<view v-else-if="currentStep === 1">
|
||
<!-- 手艺人显示个人信息,商家显示资质信息 -->
|
||
<qualification-info ref="qualificationInfo" v-if="identity === 2"></qualification-info>
|
||
<SyrInfo ref="personalInfo" v-else-if="identity === 1"></SyrInfo>
|
||
</view>
|
||
<!-- 步骤2: 根据身份显示不同内容 -->
|
||
<view v-else-if="currentStep === 2">
|
||
<!-- 手艺人显示资质信息,商家显示门店信息 -->
|
||
<store-info ref="storeInfo" v-if="identity === 2"></store-info>
|
||
<qualification-syr ref="qualificationSyr" v-else-if="identity === 1"></qualification-syr>
|
||
</view>
|
||
</view>
|
||
<view class="kong"></view>
|
||
|
||
<!-- 底部按钮区域 -->
|
||
<view class="bottom-fixed">
|
||
<!-- 步骤0: 入驻协议 - 只显示下一步 -->
|
||
<view v-if="currentStep === 0" class="step-0-buttons">
|
||
<view class="agree">
|
||
<image v-if="!isAgree" src="/static/images/agree_n.png" class="agree-btn" mode="aspectFit"
|
||
@click="isAgree = true"></image>
|
||
<image v-else src="/static/images/agree_y.png" class="agree-btn" mode="aspectFit"
|
||
@click="isAgree = false"></image>
|
||
<text class="agree-tip">我已阅读并同意以上协议</text>
|
||
</view>
|
||
<view class="next-btn" @click="goNext">
|
||
<text class="next-text">{{ identity === 1 ? '下一步,填写个人信息' : '下一步,填写资质信息' }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 步骤1: 资质信息 - 显示上一步和下一步 -->
|
||
<view v-else-if="currentStep === 1" class="step-1-buttons">
|
||
<view class="button-row">
|
||
<view class="prev-btn" @click="goPrev">
|
||
<text class="prev-text">上一步</text>
|
||
</view>
|
||
<view class="next-btn" @click="goNext">
|
||
<text class="next-text">{{ identity === 1 ? '下一步,填写资质信息' : '下一步,填写门店信息' }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 步骤2: 门店信息 - 显示上一步和提交申请 -->
|
||
<view v-else-if="currentStep === 2" class="step-2-buttons">
|
||
<view class="button-row">
|
||
<view class="prev-btn" @click="goPrev">
|
||
<text class="prev-text">上一步</text>
|
||
</view>
|
||
<view class="submit-btn" @click="submitApplication">
|
||
<text class="submit-text">提交申请</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import request from '../../utils/request';
|
||
import StepTab from '@/components/step-tab/step-tab.vue';
|
||
import QualificationInfo from './qualification_sj.vue';
|
||
import QualificationSyr from './qualification_syr.vue';
|
||
import StoreInfo from './sj-info.vue';
|
||
import SyrInfo from './syr-info.vue';
|
||
|
||
export default {
|
||
components: {
|
||
StepTab,
|
||
QualificationInfo,
|
||
QualificationSyr,
|
||
StoreInfo,
|
||
SyrInfo
|
||
},
|
||
data() {
|
||
return {
|
||
currentStep: 0, // 当前步骤索引
|
||
isAgree: false,
|
||
identity: null,
|
||
textData: {},
|
||
loading: false,
|
||
error: null,
|
||
navTitle: '商家入驻', // 默认标题
|
||
qualificationData: null, // 新增:保存资质信息
|
||
storeInfoData: null, // 新增:保存门店信息
|
||
// 新增:缓存手艺人数据
|
||
artisanDataCache: {
|
||
personalInfo: null,
|
||
qualificationInfo: null
|
||
}
|
||
}
|
||
},
|
||
async onLoad(options) {
|
||
this.identity = getApp().globalData.artisanType;
|
||
await this.getUserInfoSync()
|
||
// 确保子组件也能访问到 identity
|
||
if (this.$refs.qualificationInfo) {
|
||
this.$refs.qualificationInfo.identity = this.identity;
|
||
}
|
||
if (this.$refs.storeInfo) {
|
||
this.$refs.storeInfo.identity = this.identity;
|
||
}
|
||
|
||
// 根据身份设置导航栏标题
|
||
if (this.identity === 1) {
|
||
this.navTitle = '手艺人入驻';
|
||
} else if (this.identity === 2) {
|
||
this.navTitle = '商家入驻';
|
||
}
|
||
|
||
if (this.identity) {
|
||
const protocolType = this.identity === 1 ? 2 : 1;
|
||
this.getXieyi(protocolType);
|
||
}
|
||
},
|
||
|
||
onShow() {
|
||
console.log('入驻页面 onShow - 检查地址数据');
|
||
// 检查手艺人地址数据
|
||
this.checkAndPassAddressToSyr();
|
||
|
||
// 检查商家地址数据
|
||
this.checkAndPassAddressToSj();
|
||
},
|
||
|
||
methods: {
|
||
// 获取用户信息(复用不可服务时间页面的方法)
|
||
async getUserInfoSync() {
|
||
await request.post('/User/getUser', {
|
||
type: getApp().globalData.artisanType==2?3:2
|
||
}).then(result => {
|
||
if (result.state == 1 && result.data) {
|
||
let data = result.data
|
||
if(getApp().globalData.artisanType==2){
|
||
|
||
//储存已有的商家入驻信息
|
||
let qualification_form_data = {
|
||
"license_number": data.uscc_num,
|
||
"company_name": data.uscc_name,
|
||
"legal_person": data.legal_name,
|
||
"legal_phone": data.legal_phone,
|
||
"legal_idcard": data.legal_idcard_num,
|
||
"business_license": data.uscc_photo,
|
||
"idcard_front": data.legal_idcard_positive,
|
||
"idcard_back": data.legal_idcard_negative,
|
||
"merchant_type": data.uscc_type,
|
||
"license_valid_type": data.uscc_expiry_type,
|
||
}
|
||
if (data.uscc_expiry) {
|
||
let expirys = data.uscc_expiry.split(' —— ')
|
||
qualification_form_data.license_start_date = expirys[0]
|
||
qualification_form_data.license_end_date = expirys[1]
|
||
}
|
||
if (data.legal_idcard_expiry) {
|
||
let expirys = data.legal_idcard_expiry.split(' —— ')
|
||
qualification_form_data.idcard_start_date = expirys[0]
|
||
if (expirys[1]) {
|
||
qualification_form_data.idcard_valid_type = "date"
|
||
qualification_form_data.idcard_end_date = expirys[1]
|
||
} else {
|
||
qualification_form_data.idcard_valid_type = "permanent"
|
||
qualification_form_data.idcard_end_date = ""
|
||
}
|
||
|
||
}
|
||
uni.setStorageSync('qualification_form_data', qualification_form_data);
|
||
let store_invite_state = {
|
||
"currentValidatingCode": data.invite_code_other
|
||
}
|
||
uni.setStorageSync('store_invite_state', store_invite_state);
|
||
let store_info_form_data = {
|
||
"store_logo": data.head_photo,
|
||
"store_name": data.name,
|
||
"business_hours": data.business_time,
|
||
"service_skills": data.servers_kill,
|
||
"store_location": data.dependency,
|
||
"store_address": data.address,
|
||
"get_message_method": data.apply_state,
|
||
"invite_code": data.invite_code_other,
|
||
"professional_experience": data.major,
|
||
"dependency_code": data.dependency_code,
|
||
"dependency_province": data.dependency_province,
|
||
"dependency_city": data.dependency_city,
|
||
"longitude": data.longitude,
|
||
"latitude": data.latitude
|
||
}
|
||
uni.setStorageSync('store_info_form_data', store_info_form_data);
|
||
}else{
|
||
let artisan_qualification_form_data = {
|
||
"health_card": data.health_card,
|
||
"health_card_expiry_type": data.health_expiry_type,
|
||
"qualifications": data.qualifications,
|
||
"uscc_type": data.uscc_type,
|
||
"uscc_photo": data.uscc_photo,
|
||
"shop_photo": data.shop_photo,
|
||
"uscc_num": data.uscc_num,
|
||
"uscc_name": data.uscc_name,
|
||
"for_shop": data.for_shop,
|
||
"uscc_expiry_type": data.uscc_expiry_type,
|
||
}
|
||
if (data.uscc_expiry) {
|
||
let expirys = data.uscc_expiry.split(' —— ')
|
||
artisan_qualification_form_data.license_start_date = expirys[0]
|
||
artisan_qualification_form_data.license_end_date = expirys[1]
|
||
}
|
||
if (data.health_expiry) {
|
||
let expirys = data.health_expiry.split(' —— ')
|
||
artisan_qualification_form_data.health_card_start_date = expirys[0]
|
||
if (expirys[1]) {
|
||
artisan_qualification_form_data.health_card_end_date = "长久有效"
|
||
artisan_qualification_form_data.health_card_end_date = expirys[1]
|
||
} else {
|
||
artisan_qualification_form_data.health_card_end_date = ""
|
||
}
|
||
|
||
}
|
||
uni.setStorageSync('artisan_qualification_form_data',
|
||
artisan_qualification_form_data);
|
||
let personal_invite_state = {
|
||
"currentValidatingCode": data.invite_code_other
|
||
}
|
||
uni.setStorageSync('personal_invite_state', personal_invite_state);
|
||
let personal_info_form_data = {
|
||
"head_photo": data.head_photo,
|
||
"real_name": data.name,
|
||
"phone": data.account,
|
||
"backup_phone": data.second_phone,
|
||
"id_card": data.idcard_num,
|
||
"id_card_front": data.idcard_positive,
|
||
"id_card_back": data.idcard_negative,
|
||
"id_card_handheld": "",
|
||
"detail_address": data.address,
|
||
"introduction": data.detail,
|
||
"region": data.dependency,
|
||
"dependency_code": data.dependency_code,
|
||
"dependency_province": data.dependency_province,
|
||
"dependency_city": data.dependency_city,
|
||
"longitude": data.longitude,
|
||
"latitude": data.latitude,
|
||
"service_skills": data.servers_kill,
|
||
"service_area": data.servers_region,
|
||
"service_time": data.default_times,
|
||
"get_message_method": data.get_msg_method,
|
||
"invite_code": data.invite_code_other,
|
||
"professional_experience": data.major,
|
||
"work_status": data.work_state,
|
||
}
|
||
if (data.idcard_expiry) {
|
||
let expirys = this.parseIdCardExpiry(data.idcard_expiry)
|
||
personal_info_form_data.id_card_start_date = expirys.id_card_start_date
|
||
if (expirys.id_card_end_date) {
|
||
personal_info_form_data.id_card_valid_type = "date"
|
||
personal_info_form_data.id_card_end_date = expirys.id_card_end_date
|
||
} else {
|
||
personal_info_form_data.id_card_valid_type = "permanent"
|
||
personal_info_form_data.id_card_end_date = ""
|
||
}
|
||
|
||
}
|
||
uni.setStorageSync('personal_info_form_data', personal_info_form_data);
|
||
}
|
||
|
||
}
|
||
}).catch(error => {
|
||
console.error('获取用户信息接口错误:', error);
|
||
});
|
||
},
|
||
/**
|
||
* 解析身份证有效期字符串,转换为中文日期格式(兼容低版本iOS,支持结束日期为空/长期)
|
||
* @param {string} expiryStr 原有效期字符串,格式如:"2016-01-29 —— 2026-01-29" | "2016-01-29 —— " | "2016-01-29 —— 长期"
|
||
* @returns {Object} 包含开始和结束日期的对象
|
||
*/
|
||
parseIdCardExpiry(expiryStr) {
|
||
// 初始化默认值
|
||
let id_card_start_date = '';
|
||
let id_card_end_date = '';
|
||
|
||
try {
|
||
// 1. 分割字符串:兼容多种分隔符(——、--、—、-),并去除前后空格
|
||
const dateParts = expiryStr.split(/\s*[-—]{1,2}\s*/).map(str => str.trim());
|
||
// 提取开始和结束日期部分(处理分割后长度不足的情况)
|
||
const startStr = dateParts[0] || '';
|
||
const endStr = dateParts[1] || '';
|
||
|
||
// 2. 日期解析函数(核心:兼容低版本iOS)
|
||
const formatDateToChinese = (dateStr) => {
|
||
// 若为空,直接返回空
|
||
if (!dateStr) return '';
|
||
// 若为“长期”,直接返回“长期”
|
||
if (dateStr === '长期') return '长期';
|
||
|
||
// 关键:低版本iOS不支持“yyyy-mm-dd”,替换为“yyyy/mm/dd”
|
||
const compatibleStr = dateStr.replace(/-/g, '/');
|
||
const date = new Date(compatibleStr);
|
||
|
||
// 检查日期是否有效
|
||
if (isNaN(date.getTime())) {
|
||
return ''; // 解析失败则返回空
|
||
}
|
||
|
||
// 获取年、月、日(去掉前导零)
|
||
const year = date.getFullYear();
|
||
const month = date.getMonth() + 1;
|
||
const day = date.getDate();
|
||
|
||
return `${year}年${month}月${day}日`;
|
||
};
|
||
|
||
// 3. 解析开始日期(必须有值,否则置空)
|
||
if (startStr) {
|
||
id_card_start_date = formatDateToChinese(startStr);
|
||
}
|
||
|
||
// 4. 解析结束日期(支持空、长期、正常日期)
|
||
id_card_end_date = formatDateToChinese(endStr);
|
||
|
||
} catch (err) {
|
||
console.error('解析身份证有效期失败:', err);
|
||
}
|
||
|
||
// 5. 返回结果
|
||
return {
|
||
id_card_start_date,
|
||
id_card_end_date
|
||
};
|
||
},
|
||
// 检查并传递地址给商家组件
|
||
checkAndPassAddressToSj() {
|
||
try {
|
||
const sjAddress = uni.getStorageSync('sj_selected_address');
|
||
if (sjAddress) {
|
||
console.log('找到商家地址数据,准备传递:', sjAddress);
|
||
|
||
// 延迟执行,确保组件已渲染
|
||
setTimeout(() => {
|
||
if (this.identity === 2 && this.$refs.storeInfo) {
|
||
console.log('传递地址给商家组件');
|
||
|
||
// 传递给商家组件
|
||
if (typeof this.$refs.storeInfo.handleAddressSelected === 'function') {
|
||
this.$refs.storeInfo.handleAddressSelected(sjAddress);
|
||
} else if (this.$refs.storeInfo.formData) {
|
||
// 直接设置数据
|
||
this.$refs.storeInfo.formData.store_address = sjAddress.address || sjAddress
|
||
.name;
|
||
this.$refs.storeInfo.formData.longitude = sjAddress.longitude;
|
||
this.$refs.storeInfo.formData.latitude = sjAddress.latitude;
|
||
|
||
// 设置省市区信息
|
||
if (sjAddress.pname || sjAddress.cityname || sjAddress.adname) {
|
||
const locationParts = [];
|
||
if (sjAddress.pname) locationParts.push(sjAddress.pname);
|
||
if (sjAddress.cityname) locationParts.push(sjAddress.cityname);
|
||
if (sjAddress.adname) locationParts.push(sjAddress.adname);
|
||
this.$refs.storeInfo.formData.store_location = locationParts.join('-');
|
||
}
|
||
|
||
this.$refs.storeInfo.saveFormDataToLocal();
|
||
this.$refs.storeInfo.$forceUpdate();
|
||
}
|
||
|
||
// 清理存储
|
||
uni.removeStorageSync('sj_selected_address');
|
||
}
|
||
}, 300);
|
||
}
|
||
} catch (e) {
|
||
console.error('处理商家地址失败:', e);
|
||
}
|
||
},
|
||
// 检查并传递地址给手艺人组件
|
||
checkAndPassAddressToSyr() {
|
||
try {
|
||
const syrAddress = uni.getStorageSync('syr_selected_address');
|
||
if (syrAddress && syrAddress.source === 'syr_info') {
|
||
console.log('找到手艺人地址数据,准备传递');
|
||
|
||
// 延迟执行,确保组件已渲染
|
||
setTimeout(() => {
|
||
if (this.$refs.personalInfo) {
|
||
console.log('传递给手艺人组件');
|
||
|
||
// 准备地址数据格式
|
||
const addressData = {
|
||
name: syrAddress.name,
|
||
address: syrAddress.address,
|
||
location: syrAddress.location,
|
||
longitude: syrAddress.longitude,
|
||
latitude: syrAddress.latitude
|
||
};
|
||
|
||
// 传递给组件
|
||
if (typeof this.$refs.personalInfo.handleAddressSelected === 'function') {
|
||
this.$refs.personalInfo.handleAddressSelected(addressData);
|
||
} else if (this.$refs.personalInfo.formData) {
|
||
// 直接设置数据
|
||
this.$refs.personalInfo.formData.detail_address = addressData.address;
|
||
this.$refs.personalInfo.formData.longitude = addressData.longitude;
|
||
this.$refs.personalInfo.formData.latitude = addressData.latitude;
|
||
this.$refs.personalInfo.saveFormDataToLocal();
|
||
this.$refs.personalInfo.$forceUpdate();
|
||
}
|
||
|
||
// 清理存储
|
||
uni.removeStorageSync('syr_selected_address');
|
||
}
|
||
}, 300);
|
||
}
|
||
} catch (e) {
|
||
console.error('处理手艺人地址失败:', e);
|
||
}
|
||
},
|
||
|
||
onStepChange() {
|
||
// 当步骤切换时,重新检查地址数据
|
||
if (this.currentStep === 1 && this.identity === 1) {
|
||
// 手艺人个人信息步骤
|
||
setTimeout(() => {
|
||
this.checkAndPassAddressData();
|
||
}, 300);
|
||
}
|
||
},
|
||
|
||
// 新增方法:检查并传递地址数据
|
||
checkAndPassAddressData() {
|
||
try {
|
||
const syrAddress = uni.getStorageSync('syr_selected_address');
|
||
if (syrAddress && this.$refs.personalInfo) {
|
||
console.log('步骤切换时发现地址数据,传递给组件');
|
||
|
||
// 传递给组件
|
||
if (typeof this.$refs.personalInfo.handleAddressSelected === 'function') {
|
||
this.$refs.personalInfo.handleAddressSelected(syrAddress);
|
||
} else {
|
||
// 直接设置
|
||
this.$refs.personalInfo.formData.detail_address = syrAddress.address;
|
||
this.$refs.personalInfo.formData.longitude = syrAddress.longitude;
|
||
this.$refs.personalInfo.formData.latitude = syrAddress.latitude;
|
||
this.$refs.personalInfo.saveFormDataToLocal();
|
||
this.$refs.personalInfo.$forceUpdate();
|
||
}
|
||
|
||
// 清理
|
||
uni.removeStorageSync('syr_selected_address');
|
||
}
|
||
} catch (e) {
|
||
console.error('检查地址数据失败:', e);
|
||
}
|
||
},
|
||
|
||
// 检查用户信息
|
||
checkUserInfo() {
|
||
console.log('检查用户信息...');
|
||
|
||
// 从多种可能的存储位置检查用户信息
|
||
const sources = [
|
||
{
|
||
name: '本地存储-userInfo',
|
||
data: uni.getStorageSync('userInfo')
|
||
},
|
||
{
|
||
name: '本地存储-loginInfo',
|
||
data: uni.getStorageSync('loginInfo')
|
||
},
|
||
{
|
||
name: '本地存储-token',
|
||
data: uni.getStorageSync('token')
|
||
}
|
||
];
|
||
|
||
sources.forEach(source => {
|
||
console.log(`${source.name}:`, source.data);
|
||
});
|
||
|
||
// 检查是否有token(确认登录状态)
|
||
const token = uni.getStorageSync('token');
|
||
if (!token) {
|
||
console.warn('未检测到登录token');
|
||
uni.showToast({
|
||
title: '请先登录',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
},
|
||
|
||
// 获取用户信息(复用不可服务时间页面的方法)
|
||
getUserInfo() {
|
||
return new Promise((resolve, reject) => {
|
||
request.post('/user/getuser', {
|
||
type: 1
|
||
}).then(result => {
|
||
if (result.state == 1) {
|
||
// 保存用户信息到全局数据和本地存储
|
||
uni.setStorageSync('userInfo', result.data);
|
||
console.log('用户信息获取成功:', result.data);
|
||
resolve(result.data);
|
||
} else {
|
||
console.error('获取用户信息失败:', result.msg);
|
||
reject(result.msg);
|
||
}
|
||
}).catch(error => {
|
||
console.error('获取用户信息接口错误:', error);
|
||
reject(error);
|
||
});
|
||
});
|
||
},
|
||
|
||
// 检查并获取用户信息
|
||
async checkAndGetUserInfo() {
|
||
// 先检查是否已有用户信息
|
||
const existingUserInfo = uni.getStorageSync('userInfo');
|
||
if (existingUserInfo && existingUserInfo.account) {
|
||
console.log('已有用户信息:', existingUserInfo);
|
||
return existingUserInfo;
|
||
}
|
||
|
||
// 如果没有,则调用接口获取
|
||
try {
|
||
const userInfo = await this.getUserInfo();
|
||
return userInfo;
|
||
} catch (error) {
|
||
console.error('获取用户信息失败:', error);
|
||
uni.showModal({
|
||
title: '提示',
|
||
content: '获取用户信息失败,请重新登录',
|
||
showCancel: false,
|
||
success: () => {
|
||
uni.navigateTo({
|
||
url: '/pages/login/login'
|
||
});
|
||
}
|
||
});
|
||
return null;
|
||
}
|
||
},
|
||
|
||
// 审核提交方法
|
||
async submitForReview() {
|
||
// 提交前确保有用户信息
|
||
const userInfo = await this.checkAndGetUserInfo();
|
||
if (!userInfo) {
|
||
return;
|
||
}
|
||
|
||
uni.showLoading({
|
||
title: '提交中...'
|
||
});
|
||
|
||
try {
|
||
console.log('=== 提交审核调试信息 ===');
|
||
console.log('身份类型:', this.identity);
|
||
console.log('门店信息数据:', this.storeInfoData);
|
||
console.log('资质信息数据:', this.qualificationData);
|
||
console.log('个人信息数据:', this.personalInfoData);
|
||
|
||
|
||
// 重新获取最新数据,确保数据是最新的
|
||
if (this.identity === 1) {
|
||
// 手艺人:重新验证并获取两个步骤的数据
|
||
this.personalInfoData = this.artisanDataCache.personalInfo;
|
||
this.qualificationData = this.artisanDataCache.qualificationInfo;
|
||
|
||
console.log('手艺人个人信息数据:', this.personalInfoData);
|
||
console.log('手艺人资质信息数据:', this.qualificationData);
|
||
|
||
if (!this.personalInfoData || !this.qualificationData) {
|
||
uni.hideLoading();
|
||
uni.showToast({
|
||
title: '请完成所有步骤的填写',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
}
|
||
|
||
let apiUrl = '';
|
||
let formData = {};
|
||
|
||
|
||
|
||
if (this.identity === 2) {
|
||
// 商家入驻
|
||
apiUrl = '/user/usersjadd';
|
||
|
||
// 确保重新获取最新数据
|
||
if (this.$refs.storeInfo) {
|
||
if (!this.$refs.storeInfo.saveFormData()) {
|
||
uni.hideLoading();
|
||
return;
|
||
}
|
||
this.storeInfoData = this.$refs.storeInfo.getFormData();
|
||
console.log('重新获取的门店信息:', this.storeInfoData);
|
||
}
|
||
|
||
// 验证服务技能是否存在
|
||
if (!this.storeInfoData || !this.storeInfoData.service_skills || this.storeInfoData
|
||
.service_skills.length === 0) {
|
||
uni.hideLoading();
|
||
uni.showToast({
|
||
title: '请选择服务技能',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
formData = this.buildBusinessData(this.qualificationData, this.storeInfoData);
|
||
} else if (this.identity === 1) {
|
||
// 手艺人入驻
|
||
apiUrl = '/user/usersyradd';
|
||
formData = this.buildArtisanData(this.personalInfoData, this.qualificationData);
|
||
|
||
// 添加账号信息
|
||
if (userInfo && userInfo.account) {
|
||
formData.account = userInfo.account;
|
||
}
|
||
}
|
||
|
||
console.log('提交的数据:', formData);
|
||
console.log('API URL:', apiUrl);
|
||
|
||
const res = await request.post(apiUrl, formData);
|
||
|
||
uni.hideLoading();
|
||
|
||
if (res.state == 1) {
|
||
// 提交成功后清除缓存数据
|
||
if (this.identity === 1) {
|
||
getApp().globalData.personalInfoData = null;
|
||
getApp().globalData.qualificationData = null;
|
||
this.artisanDataCache.personalInfo = null;
|
||
this.artisanDataCache.qualificationInfo = null;
|
||
}
|
||
|
||
uni.showToast({
|
||
title: '提交成功',
|
||
icon: 'none',
|
||
duration: 1500,
|
||
success: () => {
|
||
setTimeout(() => {
|
||
uni.redirectTo({
|
||
url: `./submitres?identity=${this.identity}&applyState=1`
|
||
});
|
||
}, 1500);
|
||
}
|
||
});
|
||
} else {
|
||
uni.showToast({
|
||
title: res.msg || '提交失败',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
} catch (error) {
|
||
uni.hideLoading();
|
||
console.error('提交审核失败:', error);
|
||
uni.showToast({
|
||
title: '提交失败,请重试',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
},
|
||
|
||
// 优化日期格式化方法
|
||
formatDateForBackend(dateStr) {
|
||
if (!dateStr) return '';
|
||
if (dateStr === '长久有效' || dateStr === '长久有效') return '';
|
||
|
||
// 将 年月日 格式转换为 YYYY-MM-DD
|
||
const match = dateStr.match(/(\d+)年(\d+)月(\d+)日/);
|
||
if (match) {
|
||
const year = match[1];
|
||
const month = match[2].padStart(2, '0');
|
||
const day = match[3].padStart(2, '0');
|
||
return `${year}-${month}-${day}`;
|
||
}
|
||
|
||
// 如果已经是 YYYY-MM-DD 格式,直接返回
|
||
return dateStr;
|
||
},
|
||
|
||
// 构建商家数据
|
||
buildBusinessData(qualificationData, storeData) {
|
||
// 根据接口文档构建数据
|
||
const formData = {};
|
||
|
||
// 服务技能处理 - 添加更严格的验证
|
||
if (storeData && storeData.service_skills && storeData.service_skills.length > 0) {
|
||
// 确保 service_skills 是数组
|
||
formData.servers_kill = Array.isArray(storeData.service_skills) ?
|
||
storeData.service_skills :
|
||
[storeData.service_skills];
|
||
|
||
console.log('服务技能数组:', formData.servers_kill);
|
||
} else {
|
||
console.warn('警告:没有服务技能数据');
|
||
formData.servers_kill = [];
|
||
}
|
||
|
||
// 营业执照信息
|
||
if (qualificationData.merchant_type) {
|
||
formData.uscc_type = qualificationData.merchant_type === 'individual' ? 1 : 2;
|
||
}
|
||
if (qualificationData.business_license) {
|
||
formData.uscc_photo = qualificationData.business_license;
|
||
}
|
||
if (qualificationData.license_number) {
|
||
formData.uscc_num = qualificationData.license_number;
|
||
}
|
||
if (qualificationData.company_name) {
|
||
formData.uscc_name = qualificationData.company_name;
|
||
}
|
||
if (qualificationData.license_valid_type) {
|
||
formData.uscc_expiry_type = qualificationData.license_valid_type === 'permanent' ? 1 : 2;
|
||
}
|
||
|
||
// 格式化有效期
|
||
if (qualificationData.license_start_date) {
|
||
const startDate = this.formatDateForBackend(qualificationData.license_start_date);
|
||
|
||
if (qualificationData.license_valid_type === 'permanent') {
|
||
// 长久有效格式:开始日期 + " —— "
|
||
formData.uscc_expiry = `${startDate} —— `;
|
||
} else if (qualificationData.license_end_date) {
|
||
// 指定日期格式:开始日期 + " —— " + 结束日期
|
||
const endDate = this.formatDateForBackend(qualificationData.license_end_date);
|
||
formData.uscc_expiry = `${startDate} —— ${endDate}`;
|
||
}
|
||
}
|
||
|
||
// 法人信息
|
||
if (qualificationData.legal_person) {
|
||
formData.legal_name = qualificationData.legal_person;
|
||
}
|
||
if (qualificationData.legal_phone) {
|
||
formData.legal_phone = qualificationData.legal_phone;
|
||
}
|
||
if (qualificationData.legal_idcard) {
|
||
formData.legal_idcard_num = qualificationData.legal_idcard;
|
||
}
|
||
if (qualificationData.idcard_valid_type) {
|
||
formData.legal_idcard_expiry_type = qualificationData.idcard_valid_type === 'permanent' ? 1 : 2;
|
||
}
|
||
|
||
// 格式化有效期
|
||
if (qualificationData.idcard_start_date) {
|
||
const idcardStartDate = this.formatDateForBackend(qualificationData.idcard_start_date);
|
||
|
||
if (qualificationData.idcard_valid_type === 'permanent') {
|
||
formData.legal_idcard_expiry = `${idcardStartDate} —— `;
|
||
} else if (qualificationData.idcard_end_date) {
|
||
const idcardEndDate = this.formatDateForBackend(qualificationData.idcard_end_date);
|
||
formData.legal_idcard_expiry = `${idcardStartDate} —— ${idcardEndDate}`;
|
||
}
|
||
}
|
||
|
||
if (qualificationData.idcard_front) {
|
||
formData.legal_idcard_positive = qualificationData.idcard_front;
|
||
}
|
||
if (qualificationData.idcard_back) {
|
||
formData.legal_idcard_negative = qualificationData.idcard_back;
|
||
}
|
||
|
||
// 门店信息
|
||
if (storeData.store_logo) {
|
||
formData.head_photo = storeData.store_logo;
|
||
}
|
||
if (storeData.store_name) {
|
||
formData.name = storeData.store_name;
|
||
}
|
||
if (storeData.business_hours) {
|
||
formData.business_time = storeData.business_hours;
|
||
}
|
||
if (storeData.service_skills && storeData.service_skills.length > 0) {
|
||
// 直接传递数组
|
||
formData.servers_kill = storeData.service_skills;
|
||
console.log('服务技能数组:', formData.servers_kill);
|
||
} else {
|
||
formData.servers_kill = [];
|
||
console.warn('警告:没有服务技能数据');
|
||
}
|
||
|
||
console.log('最终 formData 中的 servers_kill:', formData.servers_kill);
|
||
console.log('=== 调试结束 ===');
|
||
|
||
if (storeData.store_location) {
|
||
formData.dependency = storeData.store_location;
|
||
|
||
// 地址编码
|
||
if (storeData.dependency_code) {
|
||
formData.dependency_code = storeData.dependency_code;
|
||
}
|
||
if (storeData.dependency_province) {
|
||
formData.dependency_province = storeData.dependency_province;
|
||
}
|
||
if (storeData.dependency_city) {
|
||
formData.dependency_city = storeData.dependency_city;
|
||
}
|
||
}
|
||
if (storeData.store_address) {
|
||
formData.address = storeData.store_address;
|
||
}
|
||
// 经纬度
|
||
if (storeData.longitude) formData.longitude = storeData.longitude;
|
||
if (storeData.latitude) formData.latitude = storeData.latitude;
|
||
|
||
// 其他信息
|
||
if (storeData.get_message_method) {
|
||
formData.get_msg_method = storeData.get_message_method;
|
||
}
|
||
if (storeData.invite_code) {
|
||
formData.invite_code_other = storeData.invite_code;
|
||
}
|
||
if (storeData.professional_experience) {
|
||
formData.major = storeData.professional_experience;
|
||
}
|
||
|
||
// 账号信息 - 直接从登录时输入的手机号获取
|
||
// 注意:这里使用 qualificationData 或 storeData 中的手机号,或者从全局获取
|
||
const userInfo = uni.getStorageSync('userInfo');
|
||
|
||
if (userInfo && userInfo.account) {
|
||
formData.account = userInfo.account;
|
||
} else {
|
||
// 如果全局没有,尝试从本地存储的登录信息获取
|
||
const loginAccount = uni.getStorageSync('loginAccount');
|
||
if (loginAccount) {
|
||
formData.account = loginAccount;
|
||
} else {
|
||
// 最后尝试:从资质信息或门店信息中获取手机号
|
||
if (qualificationData.legal_phone) {
|
||
formData.account = qualificationData.legal_phone;
|
||
} else {
|
||
console.error('无法获取账号信息');
|
||
uni.showToast({
|
||
title: '无法获取用户账号',
|
||
icon: 'none'
|
||
});
|
||
return null;
|
||
}
|
||
}
|
||
}
|
||
|
||
console.log('使用的账号:', formData.account);
|
||
return formData;
|
||
|
||
},
|
||
|
||
// 构建手艺人数据
|
||
buildArtisanData(personalData, qualificationData) {
|
||
console.log('手艺人数据调试');
|
||
console.log('personalData:', personalData);
|
||
console.log('qualificationData:', qualificationData);
|
||
|
||
const formData = {
|
||
...personalData,
|
||
...qualificationData
|
||
};
|
||
|
||
// 修复字段名映射
|
||
const fieldMappings = {
|
||
'service_area': 'servers_region', // 服务区域
|
||
'service_time': 'default_times', // 服务时间
|
||
'work_status': 'work_state', // 工作状态
|
||
'invite_code': 'invite_code_other', // 邀请码
|
||
// 健康证相关字段映射
|
||
'health_card_expiry_type': 'health_expiry_type',
|
||
'health_card_start_date': 'health_expiry_start',
|
||
'health_card_end_date': 'health_expiry_end'
|
||
};
|
||
Object.keys(fieldMappings).forEach(oldKey => {
|
||
if (formData[oldKey] !== undefined) {
|
||
formData[fieldMappings[oldKey]] = formData[oldKey];
|
||
// 可以保留原字段,也可以删除
|
||
delete formData[oldKey];
|
||
}
|
||
});
|
||
|
||
// 服务区域直接传递数组格式(后端会处理序列化)
|
||
if (formData.servers_region && typeof formData.servers_region === 'string') {
|
||
// 将字符串转换为数组格式
|
||
formData.servers_region = [formData.servers_region];
|
||
} else if (!formData.servers_region) {
|
||
// 如果没有服务区域数据,设置为空数组
|
||
formData.servers_region = [];
|
||
}
|
||
|
||
// 确保必要的字段都有值
|
||
const requiredFields = [
|
||
'head_photo', 'name', 'account', 'idcard_num', 'idcard_positive',
|
||
'idcard_negative', 'idcard_hands', 'dependency', 'address',
|
||
'servers_kill', 'get_msg_method', 'invite_code_other', 'major', 'work_status'
|
||
];
|
||
|
||
requiredFields.forEach(field => {
|
||
if (!formData[field]) {
|
||
console.warn(`警告:字段 ${field} 为空`);
|
||
}
|
||
});
|
||
|
||
console.log('手艺人最终提交数据:', formData);
|
||
return formData;
|
||
},
|
||
|
||
async goNext() {
|
||
console.log('当前步骤:', this.currentStep);
|
||
console.log('身份类型:', this.identity);
|
||
|
||
// 步骤0需要同意协议
|
||
if (this.currentStep === 0 && !this.isAgree) {
|
||
uni.showToast({
|
||
title: '请阅读并同意以上协议',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
// 步骤1需要验证信息
|
||
if (this.currentStep === 1) {
|
||
if (this.identity === 1) {
|
||
console.log('手艺人验证个人信息');
|
||
// 手艺人验证个人信息
|
||
if (this.$refs.personalInfo) {
|
||
// 等待异步验证完成
|
||
const isValid = await this.$refs.personalInfo.saveFormData();
|
||
if (!isValid) {
|
||
console.log('手艺人个人信息验证失败');
|
||
return;
|
||
}
|
||
// 保存到缓存
|
||
this.artisanDataCache.personalInfo = this.$refs.personalInfo.getFormData();
|
||
this.personalInfoData = this.artisanDataCache.personalInfo;
|
||
console.log('手艺人个人信息验证通过');
|
||
}
|
||
} else if (this.identity === 2) {
|
||
console.log('商家验证资质信息');
|
||
// 商家验证资质信息
|
||
if (this.$refs.qualificationInfo) {
|
||
const isValid = await this.$refs.qualificationInfo.saveFormData();
|
||
if (!isValid) {
|
||
console.log('商家资质信息验证失败');
|
||
return;
|
||
}
|
||
this.qualificationData = this.$refs.qualificationInfo.getFormData();
|
||
console.log(' 商家资质信息验证通过 ');
|
||
}
|
||
}
|
||
}
|
||
|
||
// 步骤2需要验证信息
|
||
if (this.currentStep === 2) {
|
||
if (this.identity === 1) {
|
||
// 手艺人验证资质信息
|
||
if (this.$refs.qualificationSyr) {
|
||
const isValid = await this.$refs.qualificationSyr.saveFormData();
|
||
if (!isValid) {
|
||
console.log('手艺人资质信息验证失败');
|
||
return;
|
||
}
|
||
this.artisanDataCache.qualificationInfo = this.$refs.qualificationSyr.getFormData();
|
||
this.qualificationData = this.artisanDataCache.qualificationInfo;
|
||
console.log('手艺人资质信息验证通过');
|
||
}
|
||
} else if (this.identity === 2) {
|
||
// 商家验证门店信息
|
||
if (this.$refs.storeInfo) {
|
||
const isValid = await this.$refs.storeInfo.saveFormData();
|
||
if (!isValid) {
|
||
console.log('商家门店信息验证失败');
|
||
return;
|
||
}
|
||
this.storeInfoData = this.$refs.storeInfo.getFormData();
|
||
console.log('商家门店信息验证通过');
|
||
}
|
||
}
|
||
}
|
||
|
||
if (this.currentStep < 2) {
|
||
this.currentStep++;
|
||
console.log('切换到步骤:', this.currentStep);
|
||
|
||
// 步骤切换后滚动到顶部
|
||
setTimeout(() => {
|
||
this.scrollToTop();
|
||
}, 100);
|
||
|
||
} else {
|
||
this.completeRegistration();
|
||
}
|
||
},
|
||
|
||
submitApplication() {
|
||
// 商家验证门店信息
|
||
if (this.$refs.storeInfo) {
|
||
if (!this.$refs.storeInfo.saveFormData()) {
|
||
return;
|
||
}
|
||
this.storeInfoData = this.$refs.storeInfo.getFormData();
|
||
console.log('商家门店信息数据:', this.storeInfoData);
|
||
} else if (this.identity === 1) {
|
||
// 手艺人验证资质信息
|
||
if (this.$refs.qualificationSyr) {
|
||
if (!this.$refs.qualificationSyr.saveFormData()) {
|
||
return;
|
||
}
|
||
this.artisanDataCache.qualificationInfo = this.$refs.qualificationSyr.getFormData();
|
||
this.qualificationData = this.$refs.qualificationSyr.getFormData();
|
||
console.log('手艺人资质信息数据:', this.qualificationData);
|
||
}
|
||
}
|
||
|
||
// 执行提交逻辑
|
||
this.completeRegistration();
|
||
},
|
||
|
||
goPrev() {
|
||
if (this.currentStep > 0) {
|
||
this.currentStep--;
|
||
}
|
||
},
|
||
completeRegistration() {
|
||
// 提交审核的逻辑
|
||
this.submitForReview();
|
||
},
|
||
// 添加滚动到顶部的方法
|
||
scrollToTop() {
|
||
uni.pageScrollTo({
|
||
scrollTop: 0,
|
||
duration: 0
|
||
});
|
||
},
|
||
async getXieyi(type) {
|
||
this.loading = true;
|
||
this.error = null;
|
||
try {
|
||
const res = await request.post('/user/getsystemtext', {
|
||
type
|
||
});
|
||
this.textData = res.data;
|
||
} catch (err) {
|
||
console.error('获取协议失败:', err);
|
||
this.error = '获取协议内容失败,请重试';
|
||
uni.showToast({
|
||
title: '获取协议内容失败',
|
||
icon: 'none'
|
||
});
|
||
} finally {
|
||
this.loading = false;
|
||
}
|
||
},
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
.ruzhu-page {
|
||
background: #f5f5f5;
|
||
}
|
||
|
||
.content {
|
||
padding: 20rpx 20rpx 50rpx 20rpx;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.xieyi_content {
|
||
padding: 20rpx;
|
||
background: #ffffff;
|
||
border-radius: 20rpx;
|
||
}
|
||
|
||
.ruzhu-cont {
|
||
padding: 24rpx;
|
||
background-color: #fff;
|
||
}
|
||
|
||
.ruzhu-text {
|
||
font-size: 28rpx;
|
||
color: #3D3D3D;
|
||
font-weight: 400;
|
||
}
|
||
|
||
.kong {
|
||
width: 100vw;
|
||
height: 180rpx;
|
||
}
|
||
|
||
/* 底部按钮区域样式 */
|
||
.bottom-fixed {
|
||
position: fixed;
|
||
left: 0;
|
||
bottom: 0;
|
||
right: 0;
|
||
background-color: #ffffff;
|
||
padding: 24rpx 0;
|
||
}
|
||
|
||
/* 步骤0按钮布局 */
|
||
.step-0-buttons {
|
||
display: flex;
|
||
flex-flow: column nowrap;
|
||
justify-content: center;
|
||
align-items: center;
|
||
}
|
||
|
||
/* 步骤0中的下一步按钮*/
|
||
.step-0-buttons .next-btn {
|
||
width: 702rpx;
|
||
height: 98rpx !important;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
background: linear-gradient(180deg, #f52540 0%, #e8101e 100%);
|
||
border-radius: 49rpx;
|
||
}
|
||
|
||
.step-0-buttons .next-text {
|
||
color: #ffffff;
|
||
font-size: 32rpx;
|
||
font-weight: 500;
|
||
}
|
||
|
||
/* 步骤1和步骤2按钮布局 */
|
||
.step-1-buttons,
|
||
.step-2-buttons {
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
}
|
||
|
||
/* 步骤1中的按钮 */
|
||
.step-1-buttons .next-btn {
|
||
flex: 1;
|
||
height: 98rpx;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
background: linear-gradient(180deg, #f52540 0%, #e8101e 100%);
|
||
border-radius: 49rpx;
|
||
}
|
||
|
||
.step-1-buttons .next-text {
|
||
color: #ffffff;
|
||
font-size: 32rpx;
|
||
font-weight: 500;
|
||
}
|
||
|
||
/* 步骤2中的提交按钮 */
|
||
.step-2-buttons .submit-btn {
|
||
flex: 1;
|
||
height: 98rpx;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
background: linear-gradient(180deg, #f52540 0%, #e8101e 100%);
|
||
border-radius: 49rpx;
|
||
}
|
||
|
||
.step-2-buttons .submit-text {
|
||
color: #ffffff;
|
||
font-size: 32rpx;
|
||
font-weight: 500;
|
||
}
|
||
|
||
/* 上一步按钮 - 统一所有步骤中的样式 */
|
||
.prev-btn {
|
||
width: 249rpx;
|
||
height: 98rpx;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
background-color: #f8f8f8;
|
||
border-radius: 60rpx;
|
||
}
|
||
|
||
.prev-text {
|
||
color: #E8101E;
|
||
font-size: 36rpx;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.button-row {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
width: 702rpx;
|
||
height: 147rpx;
|
||
gap: 20rpx;
|
||
}
|
||
|
||
.agree {
|
||
display: flex;
|
||
flex-flow: row nowrap;
|
||
justify-content: center;
|
||
align-items: center;
|
||
margin-bottom: 24rpx;
|
||
}
|
||
|
||
.agree-btn {
|
||
width: 32rpx;
|
||
height: 32rpx;
|
||
margin-right: 13rpx;
|
||
}
|
||
|
||
.agree-tip {
|
||
font-size: 26rpx;
|
||
font-weight: 400;
|
||
color: #666666;
|
||
}
|
||
|
||
.next-text {
|
||
color: #ffffff;
|
||
font-size: 32rpx;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.prev-text {
|
||
color: #333;
|
||
font-size: 32rpx;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.submit-text {
|
||
color: #ffffff;
|
||
font-size: 32rpx;
|
||
font-weight: 500;
|
||
}
|
||
</style> |