index.vue
3.8 KB
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
<template>
<u-navbar title="问诊记录" :autoBack="true" bgColor="#ffffff" placeholder safeAreaInsetTop :titleStyle="{ color: Event?.isRecords === 'success' ? '#000' : '#fff' }"></u-navbar>
<u-sticky bgColor="#fff" v-show="Event?.isRecords !== 'success'">
<view class="flexA topmain">
<view class="title" v-for="(_, index) in orderStateList" :key="index" @click="toggleOrderHandler(_, index)" :class="{ activeTitle: orderState === index }">{{ _.title }}</view>
</view>
<u-tabs
:list="orderStateList[orderState].data"
@click="clickOrderStateHandler"
lineColor="#05B8D2"
lineWidt="18"
lineHeight="3"
:current="subOrderState"
:scrollable="false"
:activeStyle="{ fontSize: '26rpx', color: '#323233', fontWeight: 700 }"
:inactiveStyle="{ fontSize: '26rpx', color: '#666666' }"
></u-tabs>
</u-sticky>
<view class="order">
<template v-if="orderList.length">
<template v-for="_ in orderList">
<OrderCard
:isPrescriptionDrug="Boolean(orderState)"
:isRecords="Event?.isRecords"
:bg="Event?.isRecords === 'success' ? 'linear-gradient(188deg, #E0FFF4 5.54%, #FFF 24.89%)' : '#fff'"
:isRecord="false"
:item="_"
@editIsJumpHandler="e => (isJump = e)"
@fetchOrderListHandler="orderStore.getOrderListHandler(true, orderState, subOrderState)"
/>
</template>
</template>
<template v-else>
<Empty :text="Event?.isRecords !== 'success' ? '暂无订单信息' : '暂无问诊记录'" />
</template>
</view>
</template>
<script setup lang="ts">
import { ref, getCurrentInstance, ComponentPublicInstance } from 'vue'
import { onLoad, onReachBottom, onUnload, onShow } from '@dcloudio/uni-app'
import { storeToRefs } from 'pinia'
import { useOrderStore } from '../../store/order'
import type { SubOrderTabsType } from '@/types'
import OrderCard from './com/OrderCard.vue'
import Empty from '@/components/Empty.vue'
import { imlogin } from '../../hooks/imLogin'
interface EventType {
orderState: string
subOrderState?: string
isRecords?: string
isJump?: string
}
const Event = ref<EventType>()
const { proxy } = getCurrentInstance() as { proxy: ComponentPublicInstance }
const orderStore = useOrderStore()
const { orderStateList, orderState, subOrderState, page, orderList } = storeToRefs(orderStore)
const isJump = ref<string | undefined>('err')
const toggleOrderHandler = (item: any, index: number) => {
console.log(item, index)
orderState.value = index
subOrderState.value = 0
orderStore.getOrderListHandler(true, orderState.value, subOrderState.value)
}
const clickOrderStateHandler = (e: SubOrderTabsType) => {
page.value = 1
subOrderState.value = e.index
orderStore.getOrderListHandler(true, orderState.value, e.index)
}
onLoad((e: EventType) => {
console.log(e)
Event.value = e
isJump.value = e.isJump
orderState.value = Number(e.orderState)
subOrderState.value = Number(e.subOrderState) || 0
})
onShow(() => {
console.log(uni.$TIM.EVENT.SDK_READY, '什么数据')
setTimeout(() => {
uni.$TUIKit.getUserStatus({ userIDList: [uni.getStorageSync('ImUserId')] }).catch(err => imlogin())
}, 800)
if (subOrderState.value == 2 && orderState.value == 0 && isJump.value === 'err') return
orderStore.getOrderListHandler(true, orderState.value, subOrderState.value)
})
onReachBottom(() => {
orderStore.getOrderListHandler(false, orderState.value, subOrderState.value)
})
</script>
<style>
page {
background: #f7f8fa !important;
}
</style>
<style lang="scss" scoped>
.topmain {
box-sizing: border-box;
padding: 8rpx 24rpx;
}
.title {
font-weight: 700;
color: #999999;
font-size: 32rpx;
margin-right: 62rpx;
}
.activeTitle {
font-size: 52rpx;
color: #26292c;
}
.order {
box-sizing: border-box;
padding: 20rpx 24rpx;
}
</style>