Browse Source

refactor(publish): 移除cases页面,优化tags和moment页面

EvilDragon 5 months ago
parent
commit
a4832af9c6

+ 11 - 4
packages/app/src/components/section-heading.vue

@@ -1,5 +1,5 @@
 <script lang="ts" setup>
-import { right } from '@/core/libs/svgs'
+import { right } from '../core/libs/svgs'
 
 const props = defineProps({
   customClass: {
@@ -19,6 +19,10 @@ const props = defineProps({
     type: String as PropType<'base' | 'xl'>,
     default: () => 'xl',
   },
+  endText: {
+    type: String,
+    default: () => '',
+  },
 })
 const handleMore = async () => {
   await uni.navigateTo({ url: props.path })
@@ -32,13 +36,16 @@ const handleMore = async () => {
     >
       {{ title }}
     </div>
-    <!-- <div
+    <div class="overflow-hidden flex-1">
+      <slot name="start"></slot>
+    </div>
+    <div
       v-if="path"
       class="text-right text-black/30 text-sm font-normal leading-tight"
       @click="handleMore"
     >
-      查看全部
+      {{ endText }}
       <wd-img :src="right" width="10" height="10"></wd-img>
-    </div> -->
+    </div>
   </view>
 </template>

+ 11 - 0
packages/app/src/core/libs/requests.ts

@@ -264,6 +264,17 @@ export const getTasks = (query) =>
       status: number
     }[]
   }>('/app-api/basicsetting/set-task-center/page', query)
+export const getCircleTags = (query) =>
+  httpGet<{
+    list: {
+      id: number
+      labelName: string
+      labelType: number
+      usageCount: number
+      creator: string
+      createTime: number
+    }[]
+  }>('/app-api/basicsetting/set-label/page', query)
 export const refreshToken = (refreshToken: string) =>
   httpPost<any>('/app-api/member/auth/refresh-token', {}, { refreshToken })
 export const httpGetMock = <T>(data: T) =>

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

@@ -60,6 +60,10 @@ export enum DictType {
    * 设计风格
    */
   memberDesignStyle = 'member_design_style_type',
+  /**
+   * 圈子标签
+   */
+  circleTag = 'basic_set_label_type',
 }
 export enum CircleType {
   moment = '1',

+ 0 - 8
packages/app/src/pages.json

@@ -238,14 +238,6 @@
       }
     },
     {
-      "path": "pages/publish/cases/index",
-      "type": "page",
-      "style": {
-        "navigationBarTitleText": "设计案例",
-        "navigationBarBackgroundColor": "#fff"
-      }
-    },
-    {
       "path": "pages/publish/moment/index",
       "type": "page",
       "style": {

+ 0 - 48
packages/app/src/pages/publish/cases/index.vue

@@ -1,48 +0,0 @@
-<route lang="yaml">
-style:
-  navigationBarTitleText: 设计案例
-  navigationBarBackgroundColor: '#fff'
-</route>
-<script setup lang="ts">
-import SectionHeading from '@/components/section-heading.vue'
-
-const value = ref('')
-const fileList = ref([])
-const action = ref('')
-const handleChange = (e: any) => {
-  console.log(e)
-}
-</script>
-<template>
-  <div class="flex-grow bg-white p-3.5 flex flex-col">
-    <wd-form ref="form">
-      <wd-cell-group border>
-        <wd-picker label="空间类型:" v-model="value" />
-        <wd-picker label="设计风格:" v-model="value" />
-        <wd-input label="空间位置:" v-model="value" placeholder="填写位置" />
-        <wd-textarea
-          label="客户需求:"
-          v-model="value"
-          placeholder="请简单描述客户的生活需求和您的设计理念"
-        />
-      </wd-cell-group>
-    </wd-form>
-
-    <wd-upload
-      :file-list="fileList"
-      image-mode="aspectFill"
-      :action="action"
-      @change="handleChange"
-    ></wd-upload>
-    <SectionHeading
-      title="标签"
-      custom-class="my-6"
-      size="base"
-      path="/pages/publish/tags/index"
-    ></SectionHeading>
-    <div class="flex-1"></div>
-    <div class="w-full">
-      <wd-button type="primary" :round="false" block>发布</wd-button>
-    </div>
-  </div>
-</template>

+ 36 - 3
packages/app/src/pages/publish/moment/index.vue

@@ -28,6 +28,7 @@ const schema = ref({
 })
 const formData = ref({})
 const formInited = ref(false)
+const tagName = ref('')
 const handleChange = ({ fileList: files }) => {
   fileList.value = files
   console.log(fileList.value)
@@ -37,7 +38,7 @@ const handleSubmit = async () => {
     stylistId: userInfo.value.userId,
     stylistName: userInfo.value.nickname,
     bannerUrls: fileList.value.map(({ response }) => JSON.parse(response).data),
-    tagName: '',
+    tagName: tagName.value,
     headUrl: userInfo.value.avatar,
     circleDesc: content.value,
     circleType: circleType.value,
@@ -50,6 +51,19 @@ const handleSubmit = async () => {
     title: '发布成功',
   })
 }
+const updateTagName = (tagNames: string[]) => {
+  if (tagNames.length === 0) {
+    tagName.value = ''
+    return
+  }
+  tagName.value = tagNames.join(',')
+}
+onMounted(() => {
+  uni.$on('updateTagName', updateTagName)
+})
+onUnmounted(() => {
+  uni.$off('updateTagName', updateTagName)
+})
 onLoad(async (query: { circleType: '1' | '2' }) => {
   circleType.value = query.circleType as CircleType
   uni.setNavigationBarTitle({ title: { '1': '个人动态', '2': '设计案例' }[circleType.value] })
@@ -93,8 +107,27 @@ onLoad(async (query: { circleType: '1' | '2' }) => {
     <SectionHeading
       title="标签"
       custom-class="my-6"
-      path="/pages/publish/tags/index"
-    ></SectionHeading>
+      :path="`/pages/publish/tags/index?tagName=${tagName}`"
+      size="base"
+    >
+      <template #start>
+        <div class="flex gap-2.5">
+          <template v-if="tagName !== ''">
+            <template v-for="it of tagName.split(',')" :key="it">
+              <div
+                class="h-6 px-2 py-0.5 bg-[#f3f3f3] rounded-[3px] justify-center items-center gap-2 inline-flex"
+              >
+                <div
+                  class="text-center text-black/90 text-xs font-normal font-['PingFang SC'] leading-tight"
+                >
+                  #{{ it }}
+                </div>
+              </div>
+            </template>
+          </template>
+        </div>
+      </template>
+    </SectionHeading>
     <div class="flex-1"></div>
     <div class="w-full">
       <wd-button type="primary" :round="false" block @click="handleSubmit">发布</wd-button>

+ 63 - 5
packages/app/src/pages/publish/tags/index.vue

@@ -5,15 +5,73 @@ style:
 </route>
 <script setup lang="ts">
 import SectionHeading from '@/components/section-heading.vue'
+import { getByDictType, getCircleTags } from '../../../core/libs/requests'
+import { DictType } from '../../../core/models/moment'
 import { ref } from 'vue'
 
+const { data: tagTypes, run: setTagTypes } = useRequest(() => getByDictType(DictType.circleTag), {
+  initialData: [],
+})
+const { data: tagsData, run: setTagsData } = useRequest(() => getCircleTags({}), {
+  initialData: { list: [] },
+})
+const selected = ref<string[]>([])
 const tags = ref<string[]>(['中国园林游学', '东方艺术设计研习营', '早稻田大学深度设计游学'])
 const tags2 = ref<string[]>(['中国园林游学', '东方艺术设计研习营', '早稻田大学深度设计游学'])
 const tags3 = ref<string[]>(['中国园林游学', '东方艺术设计研习营', '早稻田大学深度设计游学'])
+
+const handleClick = (tagName: string) => {
+  if (selected.value.includes(tagName)) {
+    selected.value = selected.value.filter((it) => it !== tagName)
+  } else {
+    selected.value.push(tagName)
+  }
+}
+const handleSubmit = async () => {
+  // uniapp修改前一页的数据
+  // const page = getCurrentPages()
+  // const prevPage = page[page.length - 2]
+  // prevPage.setData({
+  //   tags: tags.value,
+  // })
+  // console.log(prevPage.$vm)
+  // prevPage.$vm
+  // console.log(prevPage.$vm?.updateTagName(1))
+  await uni.navigateBack()
+  uni.$emit('updateTagName', selected.value)
+}
+onMounted(async () => {
+  await setTagTypes()
+  await setTagsData()
+})
+onLoad(async (query: { tagName: string }) => {
+  console.log(query)
+  if (query.tagName !== '') {
+    selected.value = query.tagName.split(',')
+  }
+})
 </script>
 <template>
   <div class="bg-white flex-grow p-3.5 flex flex-col">
-    <SectionHeading title="游学标签" custom-class="my-6" size="base"></SectionHeading>
+    <template v-for="{ value, label } of tagTypes" :key="value">
+      <SectionHeading :title="label" custom-class="my-6" size="base"></SectionHeading>
+      <div class="flex flex-wrap gap-2">
+        <template
+          v-for="{ id, labelName } of tagsData.list.filter(
+            ({ labelType }) => labelType.toString() === value.toString(),
+          )"
+          :key="id"
+        >
+          <wd-tag
+            @click="handleClick(labelName)"
+            :type="selected.includes(labelName) ? 'primary' : 'default'"
+          >
+            {{ labelName }}
+          </wd-tag>
+        </template>
+      </div>
+    </template>
+    <!-- <SectionHeading title="游学标签" custom-class="my-6" size="base"></SectionHeading>
     <div class="flex flex-wrap">
       <template v-for="(it, i) in tags" :key="i">
         <wd-tag custom-class="m-1">{{ it }}</wd-tag>
@@ -24,8 +82,8 @@ const tags3 = ref<string[]>(['中国园林游学', '东方艺术设计研习营'
       <template v-for="(it, i) in tags2" :key="i">
         <wd-tag custom-class="m-1" type="primary">{{ it }}</wd-tag>
       </template>
-    </div>
-    <SectionHeading title="自定义标签" custom-class="my-6" size="base"></SectionHeading>
+    </div> -->
+    <!-- <SectionHeading title="自定义标签" custom-class="my-6" size="base"></SectionHeading>
     <div class="flex flex-wrap">
       <template v-for="(it, i) in tags3" :key="i">
         <wd-tag custom-class="m-1">{{ it }}</wd-tag>
@@ -33,8 +91,8 @@ const tags3 = ref<string[]>(['中国园林游学', '东方艺术设计研习营'
       <wd-tag custom-class="m-1">
         <wd-icon name="add"></wd-icon>
       </wd-tag>
-    </div>
+    </div> -->
     <div class="flex-1"></div>
-    <div><wd-button block :round="false">确定</wd-button></div>
+    <div><wd-button block :round="false" @click="handleSubmit()">确定</wd-button></div>
   </div>
 </template>

+ 0 - 1
packages/app/src/types/uni-pages.d.ts

@@ -25,7 +25,6 @@ interface NavigateToOptions {
        "/pages/material/recommend/index" |
        "/pages/mine/authentication/index" |
        "/pages/mine/homepage/index" |
-       "/pages/publish/cases/index" |
        "/pages/publish/moment/index" |
        "/pages/publish/tags/index" |
        "/pages/mine/authentication/submit/success/index";