Forráskód Böngészése

feat: 添加积分页面,优化任务卡片导航逻辑;更新相关数据模型和请求接口

EvilDragon 1 hónapja
szülő
commit
f2ebbebaec

+ 15 - 0
packages/app/src/core/libs/models.ts

@@ -517,6 +517,7 @@ export interface PointsOrder {
   completeTime: number
   turnDownTime: any
   cancelTime: number
+  cancelUser?: string
   cancelReason: any
   turnDownReason: any
   remark: any
@@ -726,6 +727,7 @@ export interface Agent {
   inviteCode: string
   customer: any
   customerName: string
+  points: number
 }
 export interface Designer {
   id: string
@@ -914,6 +916,19 @@ export interface Address {
   longitude: string
   latitude: string
 }
+export interface AgentPoint {
+  id: number
+  bizId: number
+  bizType: string
+  sourceId: number
+  sourceType: string
+  targetId: number
+  taskName: string
+  targetType: string
+  points: number
+  remark: string
+  createTime: string
+}
 
 export enum DictType {
   /**

+ 15 - 1
packages/app/src/pages/mine/orders/detail/index.vue

@@ -75,10 +75,24 @@ onLoad((query: { id: string }) => {
       :end-text="dayjs(data.createTime).format('YYYY-MM-DD hh:mm')"
     ></SectionHeading>
     <SectionHeading title="支付方式" size="sm" :end-text="payTypes[data.payType]"></SectionHeading>
+    <template v-if="data.orderStatus === '3'">
+      <SectionHeading
+        title="取消时间"
+        size="sm"
+        :end-text="dayjs(data.cancelTime).format('YYYY-MM-DD hh:mm')"
+      ></SectionHeading>
+      <SectionHeading title="返还积分" size="sm" :end-text="`${data.payPoints}`"></SectionHeading>
+      <SectionHeading title="取消人" size="sm" :end-text="data.cancelUser"></SectionHeading>
+    </template>
     <div class="flex-1"></div>
     <BottomAppBar fixed>
       <div>
-        <wd-button :round="false" block v-if="data.orderStatus === '0'" @click="handleSubmit">
+        <wd-button
+          :round="false"
+          block
+          v-if="['2', '4'].includes(data.orderStatus)"
+          @click="handleSubmit"
+        >
           取消订单
         </wd-button>
       </div>

+ 7 - 1
packages/merchant/src/core/libs/agent-requests.ts

@@ -11,6 +11,7 @@ import {
   DesignerBasicInfo,
   DesignerEvent,
   DesignerFamilyInfo,
+  AgentPoint,
 } from '@designer-hub/app/src/core/libs/models'
 /**
  * 通过ID获取用户信息
@@ -62,7 +63,7 @@ export const updateDesignerBasicInfo = (data: Partial<DesignerBasicInfo>) =>
 /**
  * 获取设计师家庭信息
  */
-export const getDesignerFamilyInfo = (query) =>
+export const getDesignerFamilyInfo = (query = {}) =>
   httpGet<ResPageData<DesignerFamilyInfo>>('/app-api/member/stylist-family/list', query)
 /**
  * 保存设计师家庭信息
@@ -126,3 +127,8 @@ export const updateFollowUp = (data: Partial<FollowUp>) =>
  */
 export const focusOrCancel = (data: { brokerId: number; userId: number }) =>
   httpPost('/app-api/member/user-auth-info/focus', data)
+/**
+ * /app-api/member/task/points_flow 积分流水
+ */
+export const getPointsFlow = (query = {}) =>
+  httpGet<ResPageData<AgentPoint>>('/app-api/member/task/points_flow', query)

+ 1 - 0
packages/merchant/src/core/libs/enums.ts

@@ -34,4 +34,5 @@ export enum NetImages {
   ConsultDefaultBg = 'https://image.zhuchaohui.com/zhucaohui/f1942e62d1b1adc23f37de705570e22d098da319e10c8a448dc49e594d4bee3a.png',
   StudyTourItemBg = 'https://image.zhuchaohui.com/zhucaohui/254b7ea7fdecaba8e318a7f50e292d036cafe49904fc7fc160a5477ce921e261.png',
   DefaultAvatar = 'https://image.zhuchaohui.com/zhucaohui/0b57771c2fbe60157e592a5b0e51a2b2b6c5263300663ad33efd55b235a2402a.png',
+  DefaultPointsHeadBg = 'https://image.zhuchaohui.com/zhucaohui/7442ae6cb5f8ea83269595d4ee621bd21da2c42c23db113f18bd6f25f70572aa.png',
 }

+ 7 - 0
packages/merchant/src/pages.json

@@ -95,6 +95,13 @@
       }
     },
     {
+      "path": "pages/agent/points/index",
+      "type": "page",
+      "style": {
+        "navigationStyle": "custom"
+      }
+    },
+    {
       "path": "pages/agent/report-infos/index",
       "type": "page",
       "style": {

+ 1 - 1
packages/merchant/src/pages/agent/components/task-card.vue

@@ -36,7 +36,7 @@ const acceptingNoOrders = async (item: AgentTask) => {
   //   initData()
 }
 const toDetail = () =>
-  uni.navigateTo({ url: `/pages/home/tasks/detail/index?taskId=${props.options.id}` })
+  uni.navigateTo({ url: `/pages/agent/tasks/detail/index?taskId=${props.options.id}` })
 </script>
 <template>
   <Card

+ 96 - 0
packages/merchant/src/pages/agent/points/index.vue

@@ -0,0 +1,96 @@
+<route lang="json">
+{ "style": { "navigationStyle": "custom" } }
+</route>
+<script setup lang="ts">
+import PageHelper from '@/components/page-helper.vue'
+import Card from '@/components/card.vue'
+
+import { useUserStore } from '../../../store'
+import { storeToRefs } from 'pinia'
+import dayjs from 'dayjs'
+import NavbarEvo from '@/components/navbar-evo.vue'
+import { NetImages } from '../../../core/libs/enums'
+import { getPointsFlow } from '../../../core/libs/agent-requests'
+import PageHelperEvo from '@/components/page-helper-evo.vue'
+import { getBroker } from '../../../core/libs/requests'
+
+const userStore = useUserStore()
+const { userInfo } = storeToRefs(userStore)
+
+const { data, run: setData } = useRequest(() =>
+  getBroker({ brokerId: String(userInfo.value.userId) }),
+)
+onMounted(async () => {
+  await setData()
+})
+</script>
+<template>
+  <div class="flex-grow">
+    <NavbarEvo title="任务积分" transparent dark></NavbarEvo>
+    <div class="relative aspect-[3/1]">
+      <div class="aspect-[1.25/1] absolute top-0 w-full">
+        <div class="relative w-full h-full">
+          <div class="absolute top-0 left-0 right-0">
+            <wd-img
+              width="100%"
+              :src="NetImages.DefaultPointsHeadBg"
+              mode="widthFix"
+              custom-class=""
+            ></wd-img>
+          </div>
+        </div>
+      </div>
+    </div>
+    <div class="relative px-3.5">
+      <div class="flex items-end px-3.5 mb-5">
+        <div class="text-white text-sm font-normal font-['PingFang_SC'] leading-relaxed">
+          当前积分
+        </div>
+        <div>
+          <span class="text-white text-4xl font-normal font-['D-DIN_Exp'] leading-9">
+            {{ data.points }}
+          </span>
+        </div>
+        <div class="flex-1"></div>
+        <div></div>
+        <div class="text-[white] text-sm font-normal font-['PingFang_SC'] leading-relaxed">
+          2024
+        </div>
+      </div>
+      <Card custom-class="relative">
+        <PageHelperEvo :request="getPointsFlow" :query="{ brokerId: userInfo.userId, year: 2024 }">
+          <template #default="{ source }">
+            <div class="flex flex-col gap-4">
+              <template v-for="(it, i) in source?.list" :key="i">
+                <div class="flex items-center py-4">
+                  <div class="flex-1 flex flex-col">
+                    <div
+                      class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-relaxed"
+                    >
+                      {{ it.taskName }}
+                    </div>
+                    <div
+                      class="text-black/40 text-sm font-normal font-['PingFang_SC'] leading-relaxed"
+                    >
+                      {{ dayjs(it.createTime).format('YYYY/MM/DD HH:mm:ss') }}
+                    </div>
+                  </div>
+                  <div>
+                    <div
+                      class="text-lg font-normal font-['D-DIN_Exp'] leading-relaxed"
+                      :class="`${it.bizType === '1' ? 'text-[#ef4343]' : 'text-black'}`"
+                    >
+                      <!-- {{ { '1': '+', '2': '-' }[it.pointsType] }} -->
+                      {{ it.points }}
+                    </div>
+                  </div>
+                </div>
+                <div class="h-0.25 bg-[#dadada]" v-if="i !== (source?.list.length ?? 0) - 1"></div>
+              </template>
+            </div>
+          </template>
+        </PageHelperEvo>
+      </Card>
+    </div>
+  </div>
+</template>

+ 20 - 15
packages/merchant/src/pages/agent/tasks/index.vue

@@ -8,7 +8,7 @@
 </route>
 <script setup lang="ts">
 import Card from '@designer-hub/app/src/components/card.vue'
-import { getTaskList, taskReceive } from '../../../core/libs/requests'
+import { getBroker, getTaskList, taskReceive } from '../../../core/libs/requests'
 import { useUserStore } from '../../../store'
 import { storeToRefs } from 'pinia'
 import dayjs from 'dayjs'
@@ -16,10 +16,11 @@ import PageHelperEvo from '@/components/page-helper-evo.vue'
 import { getTasks } from '../../../core/libs/agent-requests'
 import { useTask } from '../../../composables/task'
 import { AgentTask } from '@designer-hub/app/src/core/libs/models'
+import { ComponentExposed } from 'vue-component-type-helpers'
 const userStore = useUserStore()
 const { userInfo } = storeToRefs(userStore)
 const { types } = useTask()
-const tasksList = ref([])
+const pageHelperRef = ref<ComponentExposed<typeof PageHelperEvo>>()
 const status = ref<any>({
   1: {
     title: '未开始',
@@ -34,42 +35,46 @@ const status = ref<any>({
 })
 const query = computed(() => ({ brokerId: userInfo.value.userId }))
 
+const { data, run: setData } = useRequest(() =>
+  getBroker({ brokerId: String(userInfo.value.userId) }),
+)
+
 // 状态(1-未开始,2-进行中,3-已撤回,4-已完成,5-未完成,6-待确认)
 const toDetail = async (item: AgentTask) => {
-  await uni.navigateTo({ url: `/pages/home/tasks/detail/index?taskId=${item.id}` })
+  await uni.navigateTo({ url: `/pages/agent/tasks/detail/index?taskId=${item.id}` })
 }
 const acceptingOrders = async (item: AgentTask) => {
   uni.showLoading()
-  const res = await taskReceive({ brokerId: userInfo.value.userId, taskId: item.id, orders: true })
+  await taskReceive({ brokerId: userInfo.value.userId, taskId: item.id, orders: true })
   uni.hideLoading()
-  initData()
+  pageHelperRef.value?.refresh()
 }
 const acceptingNoOrders = async (item: AgentTask) => {
   uni.showLoading()
-  const res = await taskReceive({ brokerId: userInfo.value.userId, taskId: item.id, orders: false })
+  await taskReceive({ brokerId: userInfo.value.userId, taskId: item.id, orders: false })
   uni.hideLoading()
-  initData()
+  pageHelperRef.value?.refresh()
 }
-
-const initData = async () => {
-  const res = await getTaskList({ brokerId: userInfo.value.userId })
-  tasksList.value = res.data
+const toPoints = async () => {
+  await uni.navigateTo({ url: '/pages/agent/points/index' })
 }
 onMounted(async () => {
-  initData()
+  await setData()
 })
 </script>
 <template>
-  <div class="bg-white rounded-lg shadow flex m-[18px] p-[11px]">
+  <div class="bg-white rounded-lg shadow flex m-[18px] p-[11px]" @click="toPoints">
     <div class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-relaxed">
       任务积分
     </div>
     <div class="flex-1"></div>
-    <div class="text-[#ff2e2e] text-[22px] font-medium font-['DIN'] leading-none">6153</div>
+    <div class="text-[#ff2e2e] text-[22px] font-medium font-['DIN'] leading-none">
+      {{ data.points }}
+    </div>
     <div class="w-6 h-6 relative"></div>
   </div>
 
-  <PageHelperEvo :request="getTasks" :query="query">
+  <PageHelperEvo ref="pageHelperRef" :request="getTasks" :query="query">
     <template #default="{ source }">
       <div class="flex-grow flex flex-col gap-4 p-4">
         <template v-for="item in source?.list" :key="item.id">

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

@@ -9,6 +9,7 @@ interface NavigateToOptions {
        "/pages/mine/index" |
        "/pages/agent/designer/detail" |
        "/pages/agent/designer/index" |
+       "/pages/agent/points/index" |
        "/pages/agent/report-infos/index" |
        "/pages/agent/tasks/index" |
        "/pages/agent/todo/index" |