Browse Source

fix(merchant): 商家订单详情

EvilDragon 5 months ago
parent
commit
c36f2e4223

+ 1 - 1
packages/app/package.json

@@ -115,7 +115,7 @@
     "vue": "^3.4.21",
     "vue-component-type-helpers": "^2.1.8",
     "vue-i18n": "^9.1.9",
-    "wot-design-uni": "^1.3.12",
+    "wot-design-uni": "^1.3.13",
     "z-paging": "^2.7.10"
   },
   "devDependencies": {

+ 1 - 1
packages/app/src/components/page-helper.vue

@@ -1,7 +1,7 @@
 <script setup lang="ts" generic="S extends Object, T extends { list: S[] }">
 import { NetImages } from '../core/libs/net-images'
 import useRequest from '../hooks/useRequest'
-import {ref, Ref, watch, onMounted} from 'vue'
+import { ref, Ref, watch, onMounted } from 'vue'
 
 const props = defineProps<{
   request: (query: any) => Promise<IResData<T>>

+ 1 - 1
packages/app/src/core/libs/requests.ts

@@ -1,4 +1,4 @@
-import { http, httpGet, httpPost, httpPut } from '../../utils/http'
+import { httpGet, httpPost, httpPut } from '../../utils/http'
 import { Schedule } from '../models/schedule'
 import {
   Category,

+ 3 - 2
packages/merchant/env/.env.development

@@ -5,5 +5,6 @@ VITE_DELETE_CONSOLE = false
 # 是否开启sourcemap
 VITE_SHOW_SOURCEMAP = true
 
-# VITE_SERVER_BASEURL = 'https://www.zhuchaohui.com'
-VITE_SERVER_BASEURL = 'http://39.106.91.179:48080'
+VITE_SERVER_BASEURL = 'https://www.zhuchaohui.com'
+# VITE_SERVER_BASEURL = 'http://39.106.91.179:48080'
+# VITE_SERVER_BASEURL = 'http://192.168.2.45:48080'

+ 1 - 1
packages/merchant/package.json

@@ -99,7 +99,7 @@
     "qs": "6.5.3",
     "radash": "^12.1.0",
     "vue": "3.4.21",
-    "wot-design-uni": "^1.2.26",
+    "wot-design-uni": "^1.3.13",
     "z-paging": "^2.7.10"
   },
   "devDependencies": {

+ 42 - 0
packages/merchant/src/components/page-helper.vue

@@ -0,0 +1,42 @@
+<script setup lang="ts" generic="S extends Object, T extends { list: S[] }">
+import useRequest from '../hooks/useRequest'
+import { ref, Ref, watch, onMounted } from 'vue'
+import { NetImages } from '@designer-hub/app/src/core/libs/net-images'
+
+const props = defineProps<{
+  request: (query: any) => Promise<IResData<T>>
+  query: Partial<T['list'][0]>
+  customClass?: string
+}>()
+const slot = defineSlots<{
+  default(props: { data: Ref<S>[]; source: T }): any
+}>()
+const { data, run: setData } = useRequest(() => props.request(props.query), { immediate: false })
+watch(
+  () => props.query,
+  async (e) => {
+    console.log(e)
+    console.log('watch')
+    await setData()
+  },
+)
+onMounted(async () => {
+  await setData()
+})
+// onReachBottom(() => {
+//   console.log(1111)
+// })
+defineExpose({
+  refresh: () => {
+    setData()
+  },
+})
+</script>
+<template>
+  <div class="flex-grow flex flex-col" :class="customClass">
+    <div v-if="!data?.list?.length" class="flex-grow flex items-center justify-center">
+      <wd-status-tip :image="NetImages.NotContent" tip="暂无内容"></wd-status-tip>
+    </div>
+    <slot v-else :source="data as T" :data="data.list as unknown as Ref<S>[]"></slot>
+  </div>
+</template>

+ 59 - 3
packages/merchant/src/core/libs/requests.ts

@@ -236,7 +236,15 @@ export const login = (data: {
   socialCode: string
   socialState: string
   socialCodeValid: boolean
-}) => httpPost('/app-api/member/auth/login', data)
+}) =>
+  httpPost<{
+    userId: number
+    accessToken: string
+    refreshToken: string
+    expiresTime: number
+    appLoginType: number
+    openid: any
+  }>('/app-api/member/auth/login', data)
 export const refreshToken = (refreshToken: string) =>
   httpPost<any>('/app-api/member/auth/refresh-token', {}, { refreshToken })
 /**
@@ -247,12 +255,60 @@ export const scanCodeCheckPaper = (data: { orderNo: string }) =>
 /**
  * 商家端-获取商家信息
  */
-export const getVendorAppInfo = () => httpGet('/app-api/member/vendorApp/getInfo')
+export const getVendorAppInfo = () =>
+  httpGet<{
+    id: number
+    avatar: string
+    vendorName: string
+    contactName: string
+    password: string
+    mobile: string
+    status: number
+    createTime: number
+    orderCount: any
+    totalPoints: any
+    level: number
+  }>('/app-api/member/vendorApp/getInfo')
 /**
  * 商家端-获取商家订单
  */
 export const getOrders = () =>
-  httpPost<ResPageData<any>>('/app-api/member/vendorApp/getPointsOrderByVendorPage')
+  httpPost<
+    ResPageData<{
+      id: number
+      orderType: number
+      item?: number
+      materialsId: any
+      materialsBrand: any
+      stylistId: number
+      orderMoney: any
+      projectName: string
+      pointsRate: any
+      points: string
+      orderImgUrl?: string
+      orderStatus: string
+      verifyTime: any
+      completeTime?: number
+      turnDownTime: any
+      cancelTime?: number
+      cancelReason: any
+      turnDownReason: any
+      remark: any
+      couponId: any
+      orderNo: string
+      createTime: number
+      brokerageRate: any
+      brokerage: any
+      orderQuantity: number
+      payType?: number
+      payPoints?: number
+    }>
+  >('/app-api/member/vendorApp/getPointsOrderByVendorPage')
+/**
+ * 商家端-获取订单详情
+ */
+export const getPointsOrder = (id) =>
+  httpGet<Partial<PointsOrder>>('/app-api/member/points-order/get', { id })
 export const httpGetMock = <T>(data: T) =>
   new Promise<IResData<T>>((resolve) => resolve({ code: 1, msg: '', data } as IResData<T>))
 export interface Circle {

+ 0 - 17
packages/merchant/src/package.json

@@ -1,17 +0,0 @@
-{
-  "id": "avatar-group-casual",
-  "name": "头像组无限轮播",
-  "displayName": "头像组无限轮播",
-  "version": "1.0.0",
-  "description": "用户组头像的轮播循环",
-  "keywords": [
-    "vue3头像组",
-    "轮播图"
-  ],
-  "dcloudext": {
-    "category": [
-      "前端组件",
-      "通用组件"
-    ]
-  }
-}

+ 5 - 5
packages/merchant/src/pages.json

@@ -142,18 +142,18 @@
       }
     },
     {
-      "path": "pages/mine/merchant/order_detail",
+      "path": "pages/home/tasks/detail/index",
       "type": "page",
-      "sstyle": {
-        "navigationBarTitleText": "订单详情",
+      "style": {
+        "navigationBarTitleText": "任务详情",
         "navigationBarBackgroundColor": "#fff"
       }
     },
     {
-      "path": "pages/home/tasks/detail/index",
+      "path": "pages/mine/merchant/orders/detail/index",
       "type": "page",
       "style": {
-        "navigationBarTitleText": "任务详情",
+        "navigationBarTitleText": "订单详情",
         "navigationBarBackgroundColor": "#fff"
       }
     }

+ 4 - 1
packages/merchant/src/pages/login/index.vue

@@ -25,7 +25,10 @@ const handleLogin = async () => {
   if (code !== 0) {
     uni.showToast({ title: msg })
   } else {
-    setUserInfo(data)
+    setUserInfo({
+      ...data,
+      token: data.accessToken,
+    })
     uni.reLaunch({ url: '/pages/home/index' })
   }
 }

+ 42 - 46
packages/merchant/src/pages/mine/index.vue

@@ -4,21 +4,22 @@
 
 <script setup lang="ts">
 import { onMounted, ref } from 'vue'
-import { getMemberUserInfo, getOrders, getVendorAppInfo } from '../../core/libs/requests'
+import { getOrders, getVendorAppInfo } from '../../core/libs/requests'
 import { useUserStore } from '../../store'
 import { storeToRefs } from 'pinia'
 import { isEmpty } from 'radash'
 import Card from '@designer-hub/app/src/components/card.vue'
 import SectionHeading from '@designer-hub/app/src/components/section-heading.vue'
-import { merchantPageHeaderBg, desinTopBg, rightArrowIcon } from '@designer-hub/assets/src/svgs'
+import { merchantPageHeaderBg, desinTopBg } from '@designer-hub/assets/src/svgs'
 import NavBarEvo from '@designer-hub/app/src/components/navbar-evo.vue'
-import PageHelper from '@designer-hub/app/src/components/page-helper.vue'
+import dayjs from 'dayjs'
+import { useRouter } from '@designer-hub/app/src/core/utils/router'
+import PageHelper from '../../components/page-helper.vue'
 
+const router = useRouter()
 const userStore = useUserStore()
 
 const { isLogined, userInfo } = storeToRefs(userStore)
-const { setUserInfo } = userStore
-// const { data, run } = useRequest(getMemberUserInfo)
 const avatar = computed(() =>
   !isEmpty(userInfo.value.avatar) ? userInfo.value.avatar : 'https://via.placeholder.com/72x72',
 )
@@ -37,23 +38,8 @@ onShow(async () => {
   if (isLogined.value) {
     await setData()
     await setOrders()
-    // await run()
-    // setUserInfo({
-    //   ...userInfo.value,
-    //   ...data.value,
-    // })
   }
 })
-const handleToAuthentication = () => {
-  if (!isLogined.value) return
-  uni.navigateTo({ url: '/pages/mine/authentication/index' })
-}
-const handleToHomepage = () => {
-  uni.navigateTo({ url: '/pages/mine/homepage/index' })
-}
-const toorderDetail = async () => {
-  uni.navigateTo({ url: '/pages/mine/merchant/order_detail' })
-}
 onMounted(async () => {
   // await run()
   // console.log(data.value)
@@ -243,16 +229,18 @@ onPageScroll(({ scrollTop }: { scrollTop: number }) => {
           @click="toInfoSeting"
           class="bg-white rounded-2xl shadow relative mt-[28px] py-[29px] px-[14px] flex items-center"
         >
-          <div><img class="w-16 h-16 rounded-full" src="https://via.placeholder.com/64x64" /></div>
+          <div>
+            <wd-img width="64" height="64" round :src="data?.avatar" />
+          </div>
           <div class="ml-[10px]">
             <div class="text-black/90 text-lg font-normal font-['PingFang_SC'] leading-[10.18px]">
-              商家:GELATO
+              商家:{{ data?.vendorName }}
             </div>
             <div
               class="h-6 px-1.5 py-1 bg-[#f5f6fa] rounded justify-center items-center gap-2.5 inline-flex mt-[17px]"
             >
               <div class="text-[#8b8b8b] text-xs font-normal font-['PingFang_SC'] leading-none">
-                ID:1201451200
+                ID:{{ data?.id }}
               </div>
             </div>
           </div>
@@ -266,36 +254,44 @@ onPageScroll(({ scrollTop }: { scrollTop: number }) => {
         <div class="mt-[16px]">
           <PageHelper :request="getOrders" :query="{}">
             <template #default="{ source }">
-              <template v-for="(it, i) in source.list" :key="i">
-                <div class="bg-white rounded-2xl p-[16px] flex flex-col" @click="toorderDetail">
+              <div class="flex flex-col gap-4">
+                <template v-for="(it, i) in source.list" :key="i">
                   <div
-                    class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-normal"
+                    class="bg-white rounded-2xl p-[16px] flex flex-col"
+                    @click="router.push(`/pages/mine/merchant/orders/detail/index?id=${it.id}`)"
                   >
-                    完成时间:2024-10-20 10:00
-                  </div>
+                    <div
+                      class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-normal"
+                    >
+                      完成时间:
+                      {{ dayjs(it.completeTime).format('YYYY-MM-DD hh:mm') }}
+                    </div>
 
-                  <div class="flex mt-[19px] items-center">
-                    <div class="w-[86px] h-[86px] bg-[#f6f6f6] rounded-[10px]"></div>
-                    <div class="ml-[16px]">
-                      <div
-                        class="text-black text-base font-normal font-['PingFang_SC'] leading-normal"
-                      >
-                        阿芙佳朵
-                      </div>
-                      <div
-                        class="text-left text-black/30 text-sm font-normal font-['PingFang_SC'] leading-normal"
-                      >
-                        数量x2
+                    <div class="flex mt-[19px] items-center">
+                      <div class="w-[86px] h-[86px] bg-[#f6f6f6] rounded-[10px]">
+                        <wd-img width="100%" height="100%" :src="it.orderImgUrl"></wd-img>
                       </div>
-                      <div
-                        class="text-left text-black/30 text-sm font-normal font-['PingFang_SC'] leading-normal"
-                      >
-                        600积分
+                      <div class="ml-[16px]">
+                        <div
+                          class="text-black text-base font-normal font-['PingFang_SC'] leading-normal"
+                        >
+                          {{ it.projectName }}
+                        </div>
+                        <div
+                          class="text-left text-black/30 text-sm font-normal font-['PingFang_SC'] leading-normal"
+                        >
+                          数量x{{ it.orderQuantity }}
+                        </div>
+                        <div
+                          class="text-left text-black/30 text-sm font-normal font-['PingFang_SC'] leading-normal"
+                        >
+                          {{ it.points }}积分
+                        </div>
                       </div>
                     </div>
                   </div>
-                </div>
-              </template>
+                </template>
+              </div>
             </template>
           </PageHelper>
         </div>

+ 30 - 17
packages/merchant/src/pages/mine/merchant/order_detail.vue → packages/merchant/src/pages/mine/merchant/orders/detail/index.vue

@@ -1,30 +1,43 @@
-<route lang="yaml">
-sstyle:
-  navigationBarTitleText: 订单详情
-  navigationBarBackgroundColor: '#fff'
+<route lang="json">
+{
+  "style": {
+    "navigationBarTitleText": "订单详情",
+    "navigationBarBackgroundColor": "#fff"
+  }
+}
 </route>
 <script lang="ts" setup>
+import { getPointsOrder } from '../../../../../core/libs/requests'
+import dayjs from 'dayjs'
 const collapseValue = ref<string[]>(['item1'])
+const id = ref()
+const { data, run: setData } = useRequest(() => getPointsOrder(id.value), { initialData: {} })
+onLoad(async (query: { id: string }) => {
+  id.value = query.id
+  await setData()
+})
 </script>
 
 <template>
   <view>
     <div class="bg-white p-[20px]">
       <div class="flex mt-[19px] items-center">
-        <div class="w-[86px] h-[86px] bg-[#f6f6f6] rounded-[10px]"></div>
+        <div class="w-[86px] h-[86px] bg-[#f6f6f6] rounded-[10px]">
+          <wd-img width="100%" height="100%" :src="data?.orderImgUrl"></wd-img>
+        </div>
         <div class="ml-[16px]">
           <div class="text-black text-base font-normal font-['PingFang_SC'] leading-normal">
-            阿芙佳朵
+            {{ data.projectName }}
           </div>
           <div
             class="text-left text-black/30 text-sm font-normal font-['PingFang_SC'] leading-normal"
           >
-            数量x2
+            数量x{{ data.orderQuantity }}
           </div>
           <div
             class="text-left text-black/30 text-sm font-normal font-['PingFang_SC'] leading-normal"
           >
-            600积分
+            {{ data.points }}积分
           </div>
         </div>
       </div>
@@ -34,18 +47,18 @@ const collapseValue = ref<string[]>(['item1'])
           总积分
         </div>
         <div class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-normal">
-          600积分
+          {{ data.points }}积分
         </div>
       </div>
-      <div class="flex mt-[20px] items-center justify-between">
+      <!-- <div class="flex mt-[20px] items-center justify-between">
         <div class="text-black/60 text-sm font-normal font-['PingFang_SC'] leading-normal">
           优惠券
         </div>
         <div class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-normal">
           -600积分
         </div>
-      </div>
-      <div class="bg-[#f8f8f8] rounded-lg flex items-center p-[16px] mt-[12px]">
+      </div> -->
+      <!-- <div class="bg-[#f8f8f8] rounded-lg flex items-center p-[16px] mt-[12px]">
         <img class="w-[43px] h-[34px]" src="https://via.placeholder.com/43x34" />
 
         <div class="ml-[20px]">
@@ -58,13 +71,13 @@ const collapseValue = ref<string[]>(['item1'])
             2024/04/01-2024/05/30
           </div>
         </div>
-      </div>
+      </div> -->
       <div class="flex mt-[20px] items-center justify-between">
         <div class="text-black/60 text-sm font-normal font-['PingFang_SC'] leading-normal">
           实际支付积分
         </div>
         <div class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-normal">
-          0积分
+          {{ data?.payPoints }}积分
         </div>
       </div>
       <div class="flex mt-[20px] items-center justify-between">
@@ -72,7 +85,7 @@ const collapseValue = ref<string[]>(['item1'])
           订单号
         </div>
         <div class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-normal">
-          1245100000012
+          {{ data?.orderNo }}
         </div>
       </div>
       <div class="flex mt-[20px] items-center justify-between">
@@ -80,7 +93,7 @@ const collapseValue = ref<string[]>(['item1'])
           支付时间
         </div>
         <div class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-normal">
-          2024-10-10 10:02
+          {{ dayjs(data?.createTime).format('YYYY-MM-DD HH:mm') }}
         </div>
       </div>
       <div class="flex mt-[20px] items-center justify-between">
@@ -102,7 +115,7 @@ const collapseValue = ref<string[]>(['item1'])
           核销时间
         </div>
         <div class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-normal">
-          2024-10-10 10:02
+          {{ dayjs(data?.completeTime).format('YYYY-MM-DD HH:mm') }}
         </div>
       </div>
       <div class="flex mt-[20px] items-center justify-between">

+ 2 - 2
packages/merchant/src/store/user.ts

@@ -20,8 +20,8 @@ export const useUserStore = defineStore(
       userInfo.value = { ...initState }
     }
     const isLogined = computed(() => !!userInfo.value.accessToken)
-    const isChannel = computed(() => userInfo.value.appLoginType === 1)
-    const isMerchant = computed(() => userInfo.value.appLoginType === 2)
+    const isChannel = computed(() => userInfo.value?.appLoginType === 1)
+    const isMerchant = computed(() => userInfo.value?.appLoginType === 2)
     return {
       userInfo,
       setUserInfo,

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

@@ -15,8 +15,8 @@ interface NavigateToOptions {
        "/pages/home/merchant/settlement" |
        "/pages/home/tasks/index" |
        "/pages/mine/merchant/merchant_settings" |
-       "/pages/mine/merchant/order_detail" |
-       "/pages/home/tasks/detail/index";
+       "/pages/home/tasks/detail/index" |
+       "/pages/mine/merchant/orders/detail/index";
 }
 interface RedirectToOptions extends NavigateToOptions {}
 

+ 3 - 3
packages/merchant/src/utils/http.ts

@@ -3,12 +3,12 @@ import { CustomRequestOptions } from '../interceptors/request'
 import { useUserStore } from '../store'
 import dayjs from 'dayjs'
 
-const userStore = useUserStore()
-const Authorization = userStore.userInfo.token
+// const userStore = useUserStore()
+// const Authorization = userStore.userInfo.token
 
 const header = {
   'tenant-id': 1,
-  Authorization,
+  // Authorization,
 }
 export const http = async <T>(options: CustomRequestOptions) => {
   const userStore = useUserStore()

+ 7 - 17
pnpm-lock.yaml

@@ -104,8 +104,8 @@ importers:
         specifier: ^9.1.9
         version: 9.14.1(vue@3.4.21(typescript@4.9.5))
       wot-design-uni:
-        specifier: ^1.3.12
-        version: 1.3.12(vue@3.4.21(typescript@4.9.5))
+        specifier: ^1.3.13
+        version: 1.3.13(vue@3.4.21(typescript@4.9.5))
       z-paging:
         specifier: ^2.7.10
         version: 2.7.12
@@ -330,8 +330,8 @@ importers:
         specifier: 3.4.21
         version: 3.4.21(typescript@4.9.5)
       wot-design-uni:
-        specifier: ^1.2.26
-        version: 1.3.11(vue@3.4.21(typescript@4.9.5))
+        specifier: ^1.3.13
+        version: 1.3.13(vue@3.4.21(typescript@4.9.5))
       z-paging:
         specifier: ^2.7.10
         version: 2.7.12
@@ -8724,14 +8724,8 @@ packages:
     resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
     engines: {node: '>=0.10.0'}
 
-  wot-design-uni@1.3.11:
-    resolution: {integrity: sha512-/WWGUUcUuMAWLVybxZGrffzE+ov/4IgJSi0Q+OoCtXM+X9y58JfWVnlWEtInChZ5/eFhPi2ws0rL8LBP1eBnDg==}
-    engines: {HBuilderX: ^3.8.7}
-    peerDependencies:
-      vue: '>=3.2.47'
-
-  wot-design-uni@1.3.12:
-    resolution: {integrity: sha512-aF4ReRTqLLQ7/JcQQvBZJBivoprX9xrvI0b+xWakis5xDSF7tfz1ndPSCBgPtPdTzIaEG5RAT18x0ueRSUbixQ==}
+  wot-design-uni@1.3.13:
+    resolution: {integrity: sha512-3LHW480eivYAIDsxQr8KxMHCpeoj45XXpbmslLEvSWdPaRBvkXukaMW8z7wjejrMozxPBkQZT52bktCLBT/kOA==}
     engines: {HBuilderX: ^3.8.7}
     peerDependencies:
       vue: '>=3.2.47'
@@ -19925,11 +19919,7 @@ snapshots:
 
   word-wrap@1.2.5: {}
 
-  wot-design-uni@1.3.11(vue@3.4.21(typescript@4.9.5)):
-    dependencies:
-      vue: 3.4.21(typescript@4.9.5)
-
-  wot-design-uni@1.3.12(vue@3.4.21(typescript@4.9.5)):
+  wot-design-uni@1.3.13(vue@3.4.21(typescript@4.9.5)):
     dependencies:
       vue: 3.4.21(typescript@4.9.5)