zhengyiming
2 天以前 25f0924ac4dcce46cb14856b88ced3b0b6289cab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<template>
  <PageLayoutWithBg class="mineHire-page-wrapper" :title="'服务名'" :need-auth="false">
    <LoadingLayout :loading="isLoading" :error="isError" :loadError="refetch">
      <ContentScrollView style="background-color: transparent"> serciceDetail </ContentScrollView>
      <PageFooter>
        <PageFooterAction
          :icon="detail.isCollection ? IconAttentionActive : IconAttention"
          text="收藏"
          :isFlex="false"
          @click="handleAttention"
        ></PageFooterAction>
        <PageFooterAction
          :icon="IconShare"
          text="分享"
          :isFlex="false"
          :open-type="'contact'"
        ></PageFooterAction>
        <PageFooterBtn type="primary" @click="openSkuDialog()">预约下单</PageFooterBtn>
        <PageFooterBtn type="primary" @click="pay">预约下单</PageFooterBtn>
      </PageFooter>
      <Sku
        v-model:visible="skuState.visible"
        :sku="skuState.sku"
        v-model:goods="skuState.goods"
        @clickBtnOperate="clickBtnOperate"
      >
      </Sku>
    </LoadingLayout>
  </PageLayoutWithBg>
</template>
 
<script setup lang="ts">
import { useStandardServiceDetail } from '@12333/hooks';
import Taro from '@tarojs/taro';
import * as standardOrderServices from '@12333/services/apiV2/standardOrder';
import { toThousand, setOSSLink } from '@12333/utils';
import { Sku, Goods, SkuItem, SkuUtils } from '@12333/components';
import { useAccessLogin } from '@/hooks';
import IconShare from '@/assets/flexJob/icon-share.png';
import IconAttention from '@/assets/flexJob/icon-attention-lg.png';
import IconAttentionActive from '@/assets/flexJob/icon-attention-lg-active.png';
 
defineOptions({
  name: 'serciceDetail',
});
 
const router = Taro.useRouter();
const id = router.params?.id ?? '';
 
const { isLoading, isError, detail, refetch } = useStandardServiceDetail({
  id,
  onSuccess(res) {
    skuState.sku = [
      {
        id: SkuUtils.DefaultSkuSpecId,
        name: '规格',
        list: res.specs.map((item, index) => ({
          id: item.id,
          name: item.name,
          active: index === 0,
          disable: false,
        })),
      },
    ];
    skuState.goods = {
      skuId: SkuUtils.DefaultSkuSpecId,
      price: toThousand(res.specs[0].price),
      imagePath: setOSSLink(res.files[0]),
      name: res.name,
    };
  },
});
 
const skuState = reactive({
  visible: false,
  sku: [] as SkuItem[],
  goods: {} as Goods,
});
 
// 底部操作按钮触发
const clickBtnOperate = (op: { type: string; value: number }) => {
  addStandardOrder(op.value);
};
 
const openSkuDialog = useAccessLogin(() => {
  skuState.visible = true;
});
 
function goAddStandardOrder(specNumber: number) {
  Taro.navigateTo({
    url: `${RouterPath.addStandardOrder}?specNumber=${specNumber}`,
  });
}
 
async function addStandardOrder(specNumber: number) {
  try {
    const spec = SkuUtils.getCurrentActiveSpec(skuState.sku);
    let params: API.AddStandardOrderCommand = {
      serviceId: detail.value.id,
      serviceName: detail.value.name,
      serviceCode: detail.value.code,
      specId: spec.id,
      specName: spec.name,
      specPrice: detail.value.specs.find((x) => x.id === spec.id)?.price ?? 0,
      specNumber: specNumber,
      addressId: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
      name: detail.value.name,
      contactPhoneNumber: 'string',
      provinceCode: 'string',
      provinceContent: 'string',
      cityCode: 'string',
      cityContent: 'string',
      areaCode: 'string',
      areaContent: 'string',
      addressName: 'string',
      addressDetail: 'string',
      longitude: 0,
      latitude: 0,
      beginTime: '2025-12-24T08:25:08.372Z',
      endTime: '2025-12-24T08:25:08.372Z',
      supplierEnterpriseId: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
      enterpriseEmployeeIds: ['3fa85f64-5717-4562-b3fc-2c963f66afa6'],
      remark: 'string',
      payAccess: 1,
    };
    let res = await standardOrderServices.addStandardOrder(params);
  } catch (error) {}
}
 
async function pay() {
  try {
    let params: API.PayStandardOrderCommand = {
      id: '9e919af2-3d33-4eac-f6dc-08de429676b3',
    };
    let res = await standardOrderServices.payStandardOrder(params);
    if (res) {
      Taro.requestPayment({
        timeStamp: res.timestamp,
        nonceStr: res.nonceStr,
        package: res.package,
        signType: res.signType as any,
        paySign: res.paySign,
      });
    }
  } catch (error) {}
}
 
function handleAttention() {}
</script>
 
<style lang="scss">
@import '@/styles/common.scss';
</style>