Browse Source

feat: 添加获取用户标签接口,更新标签页面以支持用户标签显示

EvilDragon 3 months ago
parent
commit
125bf0cbe0

+ 23 - 0
packages/app/src/components/form-message-box.vue

@@ -0,0 +1,23 @@
+<script setup lang="ts">
+import { DataFormSchema } from './data-form'
+import DataForm from './data-form.vue'
+withDefaults(defineProps<{ selector?: string; schema?: DataFormSchema }>(), {
+  selector: 'wd-message-box-slot',
+  schema: () => ({ test: { type: 'TextField', label: 'Test' } }),
+})
+</script>
+<template>
+  <wd-message-box :selector="selector">
+    <!-- <wd-rate custom-class="custom-rate-class" v-model="rate" /> -->
+    <DataForm :schema="schema"></DataForm>
+    <wd-config-provider :themeVars="{ textareaBg: 'transparent', textareaCellHeight: '100rpx' }">
+      <!-- <wd-textarea
+        custom-class="bg-[#f6f6f6]! rounded-lg border border-solid border-[#9f9f9f]/20"
+        v-model=""
+        line="2"
+        height="100rpx"
+        placeholder="请输入驳回原因"
+      /> -->
+    </wd-config-provider>
+  </wd-message-box>
+</template>

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

@@ -271,6 +271,19 @@ export const getCircleTags = (query) =>
       createTime: number
     }[]
   }>('/app-api/basicsetting/set-label/page', query)
+/**
+ * 获取用户标签
+ */
+export const getMemberTags = (query: { stylistId: string }) =>
+  httpGet<
+    {
+      id: number
+      stylistId: number
+      stylistName: string
+      tagName: string
+      createTime: string
+    }[]
+  >('/app-api/member/circle/pageUerTag', query)
 export const getSetIndexConfigs = (query = {}) =>
   httpGet<{
     list: {

+ 44 - 31
packages/app/src/pages/publish/tags/index.vue

@@ -5,20 +5,30 @@ style:
 </route>
 <script setup lang="ts">
 import SectionHeading from '@/components/section-heading.vue'
-import { getByDictType, getCircleTags } from '../../../core/libs/requests'
+import { getByDictType, getCircleTags, getMemberTags } from '../../../core/libs/requests'
 import { DictType } from '../../../core/libs/models'
 import { ref } from 'vue'
+import { useUserStore } from '../../../store'
+import { storeToRefs } from 'pinia'
+import { useMessage } from 'wot-design-uni'
+import FormMessageBox from '@/components/form-message-box.vue'
 
+const userStore = useUserStore()
+const { userInfo } = storeToRefs(userStore)
+const { confirm } = useMessage('wd-message-box-slot')
 const { data: tagTypes, run: setTagTypes } = useRequest(() => getByDictType(DictType.circleTag), {
   initialData: [],
 })
 const { data: tagsData, run: setTagsData } = useRequest(() => getCircleTags({}), {
   initialData: { list: [] },
 })
+const { data: memberTags, run: setMemberTags } = useRequest(
+  () => getMemberTags({ stylistId: userInfo.value?.userId.toString() }),
+  {
+    initialData: [],
+  },
+)
 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)) {
@@ -28,24 +38,36 @@ const handleClick = (tagName: string) => {
   }
 }
 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)
 }
+const handleAddTag = async () => {
+  await confirm({
+    title: '添加标签',
+    beforeConfirm: async ({ resolve }) => {
+      // if (!cancelReason.value) {
+      //   resolve(false)
+      //   uni.showToast({ title: '请输入驳回原因', icon: 'none' })
+      //   return
+      // }
+      // await requestToast(
+      //   () =>
+      //     orderPointsCancel({
+      //       id: message.businessId.toString(),
+      //       cancelReason: cancelReason.value,
+      //     }),
+      //   { success: true, successTitle: '积分确认已驳回' },
+      // )
+      resolve(false)
+    },
+  })
+}
 onMounted(async () => {
   await setTagTypes()
   await setTagsData()
+  await setMemberTags()
 })
 onLoad(async (query: { tagName: string }) => {
-  console.log(query)
   if (query.tagName !== '') {
     selected.value = query.tagName.split(',')
   }
@@ -71,28 +93,19 @@ onLoad(async (query: { tagName: string }) => {
         </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>
-      </template>
-    </div>
-    <SectionHeading title="活动标签" custom-class="my-6" size="base"></SectionHeading>
+    <SectionHeading title="自定义标签" custom-class="my-6" size="base"></SectionHeading>
     <div class="flex flex-wrap">
-      <template v-for="(it, i) in tags2" :key="i">
-        <wd-tag custom-class="m-1" type="primary">{{ it }}</wd-tag>
+      <template v-for="(it, i) in memberTags" :key="i">
+        <div>
+          <wd-tag custom-class="m-1">{{ it.tagName }}</wd-tag>
+        </div>
       </template>
-    </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>
-      </template>
-      <wd-tag custom-class="m-1">
+      <wd-tag custom-class="m-1" @click="handleAddTag">
         <wd-icon name="add"></wd-icon>
       </wd-tag>
-    </div> -->
+    </div>
     <div class="flex-1"></div>
     <div><wd-button block :round="false" @click="handleSubmit()">确定</wd-button></div>
+    <FormMessageBox :schema="{ test: { type: 'TextField' } }"></FormMessageBox>
   </div>
 </template>