From 4a333db9a7f20b42748b964a30dd044c1e5df57e Mon Sep 17 00:00:00 2001 From: wangzimeng <3297159934@qq.com> Date: Wed, 30 Jul 2025 18:25:58 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E9=A1=B9=E7=9B=AE=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=B7=9FUI=E7=A1=AE=E5=AE=9A=E6=A0=B7=E5=BC=8F=E9=87=8D?= =?UTF-8?q?=E7=94=BB=EF=BC=9B=202=E3=80=81=E5=A4=84=E7=90=86=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=9B=BE=E7=89=87=E7=9A=84=E6=96=B9=E6=A1=88=EF=BC=88?= =?UTF-8?q?=E9=87=87=E7=94=A8=E5=8E=9F=E5=95=86=E5=9F=8E=E7=9A=84=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E7=BB=84=E4=BB=B6=E5=B9=B6=E6=A0=B9=E6=8D=AEUI?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=A0=B7=E5=BC=8F=EF=BC=89=EF=BC=9B=203?= =?UTF-8?q?=E3=80=81=E5=A4=84=E7=90=86=E9=80=89=E6=8B=A9=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E5=9B=9E=E6=98=BE=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/fabu.vue | 831 +++++++++++------- pages/index/index.vue | 10 + sheep/api/rent.js | 16 + sheep/components/s-uploader/s-uploader.vue | 12 +- sheep/components/s-uploader/upload-image.vue | 3 +- .../su-regionCity-picker.vue | 3 +- 6 files changed, 534 insertions(+), 341 deletions(-) diff --git a/pages/index/fabu.vue b/pages/index/fabu.vue index ad15f8c..49ffec0 100644 --- a/pages/index/fabu.vue +++ b/pages/index/fabu.vue @@ -1,6 +1,6 @@ @@ -277,6 +288,9 @@ address, region } from '@/sheep/validate/form'; + import { + baseUrl + } from '@/sheep/config'; const state = reactive({ showRegion: false, @@ -293,59 +307,68 @@ address, region, }, + formData: { + content: '', + phone: '', + images: [], + type: '', + }, + imageFiles: [], }); + const popupStyle = { + width: '620rpx', + padding: '50rpx 40rpx 42rpx 40rpx', + height: '984rpx', + margin: '0 auto', // 水平居中 + display: 'flex', + justifyContent: 'start', + alignItems: 'center', + flexColumn: 'column' + } const proCity = ref('') const form = ref({ - title: null, + title: '', area: '', - address_detail: null, - content: null, - stock: null, - cate_idsName: null, - address1: null, - categoryId: null, tags: '', + contacts: '', + contact_number: '', + content: '', + address_detail: '', + type: '', + images: '', + province: '', + city: '', cate_ids: '', - province: null, - district: null, - keywords: null, + cateName: '', + imageList: [], }) + const onRegionConfirm = (e) => { console.log('onRegionConfirm', e); state.model = { ...state.model, ...e, }; - proCity.value = state.model.province_name + " " + state.model.city_name + form.value.area = state.model.province_name + " " + state.model.city_name + + console.log('onRegionConfirm33', state.model, proCity.value); + form.value.province = state.model.province_id + form.value.city = state.model.city_id console.log('onRegionConfirm33', state.model, proCity.value); state.showRegion = false; }; - - - const show = ref(false) - const showPopbq = ref(false) - const tagList = ref(false) - const tagShowList = ref(false) - const priceShow = ref(false) - const cardShow = ref(false) - const list = ref([]);//已选择标签 - const current = ref(); + const show = ref(false) //发布须知显隐 + const agreeAdd = ref(false) //同意须知的勾选 + const agreeShow = ref(false) //须知的同意按钮 + const Negotiate = ref('') //富文本 + const cardShow = ref(false) //身份认证 const status = ref(0) - onShow(() => { getTagList(); + getTypeList(); }) - - //标签 - function openPopbq() { - showPopbq.value = true; - // getTagList(); - } - function closebq() { - showPopbq.value = false; - } async function getTagList() { const res = await sheep.$api.rent.tagsList({}); if (res.code == 1) { @@ -363,58 +386,226 @@ console.log('tagList', tagList.value, tagShowList.value); } } + async function getTypeList() { + const res = await sheep.$api.rent.listType({}); + if (res.code == 1) { + typeList.value = res.data + typeShowList.value = Object.values(typeList.value) + console.log('typeList', typeList.value, typeShowList.value); + } + } + + + //项目类型 + const showType = ref(false) + const typeList = ref([]) + const typeShowList = ref([]) + const typeName = ref('') + const typeIndex = ref(0); //已选择项目类型 + function closeType() { + console.log('取消type', typeIndex.value); + showType.value = false + } + + function selectType(e) { + console.log('选择项目类型', e); + typeIndex.value = e.detail.value; + form.value.type = typeShowList.value[typeIndex.value]; + showType.value = false; + } + + + //标签 + const showPopbq = ref(false) + const tagList = ref([]) + const tagShowList = ref([]) + const selectTagslist = ref([]); //已选择标签 + const tagSelectedNum = ref(0) + + function openPopbq() { + showPopbq.value = true; + } + + function closebq() { + showPopbq.value = false; + } //选中标签 function addbq(item, index) { - current.value = index; - - console.log('选择标签',current.value); - tagShowList.value[current.value].isSelect = true - // let arrbql = uni.getStorageSync("zjlist"); - // let arrbq = JSON.parse(arrbql); - // let isbq = true; - // for (let i = 0; i < arrbq.length; i++) { - // if (arrbq[i].id == val.id) { - // uni.showToast({ - // title: "已选择该标签", - // icon: "none", - // duration: 2000, - // }); - // return isbq = false; - // } - // } - // if (list.value.length < 3) { - // if (isbq) { - // list.value.push(val); - // uni.setStorageSync('zjlist', JSON.stringify(list.value)) - // } - // } else { - // uni.showToast({ - // title: "最多添加3个标签", - // icon: "none", - // duration: 2000, - // }); - // } - // let arr = list.value.map((item) => { - // return item.name - // }) - // form.value.cate_idsName = arr.join(','); + if (tagShowList.value[index].isSelect == false) { + if (tagSelectedNum.value < 3) { + tagSelectedNum.value += 1; + tagShowList.value[index].isSelect = true; + } else { + uni.showToast({ + title: '最多选择三个标签', + icon: 'none' + }) + } + } else { + if (tagSelectedNum.value > 0) { + tagSelectedNum.value -= 1; + tagShowList.value[index].isSelect = false; + } else { + uni.showToast({ + title: '至少选择一个', + icon: 'none' + }) + } + } + console.log('选择标签', tagSelectedNum.value); } - //删除标签(本地) - function removebq(i) { - list.value.splice(i, 1); - uni.setStorageSync('zjlist', JSON.stringify(list.value)) - let arr = list.value.map((item) => { - return item.name - }) - form.value.cate_idsName = arr.join(',') - } - + function checkTagTrue() { console.log('确定选择的标签'); + selectTagslist.value = [] + for (let i = 0; i < tagShowList.value.length; i++) { + if (tagShowList.value[i].isSelect == true) { + selectTagslist.value.push(tagShowList.value[i]) + } + } + console.log('selectTagslist', selectTagslist.value); + showPopbq.value = false + } + + //删除标签(本地) + function removebq(i) { + selectTagslist.value.splice(i, 1); + tagSelectedNum.value -= 1; + console.log('删除标签', tagSelectedNum.value); + let arr = selectTagslist.value.map((item) => { + return item.name + }) + } + + function change() { + agreeAdd.value = true; + show.value = false + } + //同意 + function handleScroll() { + console.log(123) + agreeShow.value = true + } + + function apply() { + if (agreeAdd.value == false) { + uni.showToast({ + title: '请先同意发布须知', + icon: 'none', + }) + return + } + form.value.cate_ids = selectTagslist.value.map((item) => item.id).join(',') + console.log('cate_ids', form.value.cate_ids, state.formData.images); + + form.value.images = state.formData.images.join(','); + console.log('images', form.value.images); + + if (form.value.title == '') { + uni.showToast({ + title: '请输入标题', + icon: 'none', + }) + return + } + if (form.value.province == '' && form.value.city == '') { + uni.showToast({ + title: '请选择地区', + icon: 'none', + }) + return + } + if (form.value.address_detail == '') { + uni.showToast({ + title: '请输入详细地址', + icon: 'none', + }) + return + } + if (form.value.contacts == '') { + uni.showToast({ + title: '请输入联系人', + icon: 'none', + }) + return + } + if (form.value.contact_number == '') { + uni.showToast({ + title: '请输入联系人电话', + icon: 'none', + }) + return + } + if (!/^1[3-9]\d{9}$/.test(form.value.contact_number)) { + uni.showToast({ + title: '请输入正确的手机号', + icon: 'none', + duration: 2000 + }) + return; + } + if (form.value.content == '') { + uni.showToast({ + title: '请输入详细信息', + icon: 'none', + }) + return + } + if (form.value.images == '') { + uni.showToast({ + title: '请上传图片', + icon: 'none', + }) + return + } + if (form.value.type == '') { + uni.showToast({ + title: '请选择项目类型', + icon: 'none', + }) + return + } + if (form.value.cate_ids == '') { + uni.showToast({ + title: '请选择标签', + icon: 'none', + }) + return + } + console.log('apply——form:', form.value); }