Browse Source

fix(app): 发布功能优化:支持选择发布类型及添加表单

EvilDragon 5 months ago
parent
commit
5dd4f46f9f

+ 8 - 0
packages/app/src/core/models/moment.ts

@@ -56,4 +56,12 @@ export enum DictType {
    *  擅长空间类型
    */
   memberSpatialExpertiseType = 'member_spatial_expertise_type',
+  /**
+   * 设计风格
+   */
+  memberDesignStyle = 'member_design_style_type',
+}
+export enum CircleType {
+  moment = '1',
+  case = '2',
 }

+ 2 - 2
packages/app/src/layouts/tabbar.vue

@@ -57,11 +57,11 @@ const handleTabbarItemClick = (path: string) => {
   uni.switchTab({ url: path })
 }
 const toPublishMoment = () => {
-  uni.navigateTo({ url: '/pages/publish/moment/index' })
+  uni.navigateTo({ url: '/pages/publish/moment/index?circleType=1' })
   publishState.value = false
 }
 const toPublishCase = () => {
-  uni.navigateTo({ url: '/pages/publish/cases/index' })
+  uni.navigateTo({ url: '/pages/publish/moment/index?circleType=2' })
   publishState.value = false
 }
 </script>

+ 35 - 5
packages/app/src/pages/publish/moment/index.vue

@@ -5,17 +5,29 @@ style:
 </route>
 <script setup lang="ts">
 import SectionHeading from '@/components/section-heading.vue'
-import { createCircle } from '../../../core/libs/requests'
+import { createCircle, getByDictType } from '../../../core/libs/requests'
 import { useUserStore } from '../../../store'
 import { storeToRefs } from 'pinia'
 import { useToast } from 'wot-design-uni'
+import { CircleType, DictType } from '../../../core/models/moment'
+import DataForm from '@/components/data-form.vue'
+import { zipToObject } from 'radash'
 
 const userStore = useUserStore()
 const { userInfo } = storeToRefs(userStore)
 const { error } = useToast()
+const circleType = ref<CircleType>()
 const content = ref('')
 const fileList = ref([])
 const action = ref(`${import.meta.env.VITE_SERVER_BASEURL}/app-api/infra/file/upload`)
+const schema = ref({
+  spaceType: { label: '空间类型', type: 'Select', props: { columns: [] } },
+  designStyle: { label: '设计风格', type: 'Select', props: { columns: [] } },
+  spaceAddr: { label: '空间位置', type: 'TextField' },
+  customerDemand: { label: '客户需求', type: 'TextField' },
+})
+const formData = ref({})
+const formInited = ref(false)
 const handleChange = ({ fileList: files }) => {
   fileList.value = files
   console.log(fileList.value)
@@ -28,7 +40,8 @@ const handleSubmit = async () => {
     tagName: '',
     headUrl: userInfo.value.avatar,
     circleDesc: content.value,
-    circleType: '1',
+    circleType: circleType.value,
+    ...formData.value,
   })
   if (code !== 0) {
     error(msg)
@@ -37,13 +50,30 @@ const handleSubmit = async () => {
     title: '发布成功',
   })
 }
-onMounted(() => {
-  console.log(action.value)
+onLoad(async (query: { circleType: '1' | '2' }) => {
+  circleType.value = query.circleType as CircleType
+  uni.setNavigationBarTitle({ title: { '1': '个人动态', '2': '设计案例' }[circleType.value] })
+  const optionsSchema = {
+    designStyle: getByDictType(DictType.memberDesignStyle).then(({ data }) => data),
+    spaceType: getByDictType(DictType.memberSpatialExpertiseType).then(({ data }) => data),
+  }
+  const res = await zipToObject(
+    Object.keys(optionsSchema),
+    await Promise.all(Object.values(optionsSchema)),
+  )
+  schema.value.designStyle.props.columns = res.designStyle
+  schema.value.spaceType.props.columns = res.spaceType
+  formInited.value = true
 })
 </script>
 <template>
   <div class="flex-grow bg-white p-3.5 flex flex-col">
-    <wd-textarea v-model="content" placeholder="分享你此刻的想法" />
+    <template v-if="circleType === CircleType.case && formInited">
+      <DataForm v-model="formData" :schema="schema" direction="horizontal"></DataForm>
+    </template>
+    <template v-if="circleType === CircleType.moment">
+      <wd-textarea v-model="content" placeholder="分享你此刻的想法" />
+    </template>
 
     <!-- <div class="flex items-center">
       <img