shinnosuke
2026-08-31 cb5a42c97fe9ae23b891bdc3231dc8eb100de218
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
const textValue = (value: any, fallback: string = ''): string => {
    if (value == null) return fallback
    return String(value)
}
 
const encoded = (value: any, fallback: string = ''): string => encodeURIComponent(textValue(value, fallback))
 
const inferTargetAction = (merchantType: string): string => {
    if (merchantType == 'cinema') return 'CINEMA'
    if (merchantType == 'fuel') return 'FUEL'
    if (merchantType == 'parking') return 'PARKING'
    if (merchantType == 'carWash') return 'CAR_WASH'
    if (merchantType == 'medical') return 'MEDICAL'
    if (merchantType == 'employment') return 'SPOUSE_EMPLOYMENT'
    if (merchantType == 'finance') return 'FINANCE'
    if (merchantType == 'approval') return 'ADMIN_APPROVAL'
    if (merchantType == 'children') return 'CHILD_ENTRUSTMENT'
    if (merchantType == 'housing' || merchantType == 'car' || merchantType == 'appliance' || merchantType == 'digital' || merchantType == 'culture' || merchantType == 'telecom' || merchantType == 'shopping') return 'SHOPPING'
    return 'MERCHANT'
}
 
export const openMerchantDetail = (item: any) => {
    if (item == null) return
    if (item.available === false) {
        uni.showToast({ title: textValue(item.unavailableReason, '该服务当前不可用'), icon: 'none' })
        return
    }
 
    const merchantId = textValue(item.detailBusinessId, textValue(item.id))
    const merchantType = textValue(item.merchantType, 'food')
    const configuredAction = textValue(item.targetAction, textValue(item.detailType))
    const action = configuredAction == '' || configuredAction == 'MERCHANT' ? inferTargetAction(merchantType) : configuredAction
    const name = encoded(item.name)
    const image = encoded(item.image)
    const address = encoded(item.address)
    const discount = encoded(item.discount)
 
    if (action == 'CINEMA') {
        uni.navigateTo({ url: '/pages/cinema-merchant/cinema-merchant?merchantId=' + encoded(merchantId) + '&name=' + name + '&image=' + image + '&address=' + address + '&discount=' + discount })
        return
    }
    if (action == 'SHOPPING' && merchantType != 'culture') {
        uni.navigateTo({ url: '/pages/shopping-merchant/shopping-merchant?merchantId=' + encoded(merchantId) })
        return
    }
    if (action == 'MEDICAL') {
        uni.navigateTo({ url: '/pages/merchant/merchant?type=medical&merchantType=medical&merchantId=' + encoded(merchantId) + '&name=' + name })
        return
    }
    if (action == 'SPOUSE_EMPLOYMENT') {
        uni.navigateTo({ url: '/pages/spouse-employment/spouse-employment?serviceId=' + encoded(merchantId) })
        return
    }
    if (action == 'FINANCE') {
        uni.navigateTo({ url: '/pages/finance-merchant/finance-merchant?serviceId=' + encoded(merchantId) + '&merchantId=' + encoded(merchantId) + '&name=' + name + '&discount=' + discount + '&address=' + address + '&image=' + image })
        return
    }
    if (action == 'ADMIN_APPROVAL') {
        uni.navigateTo({ url: '/pages/admin-approval/admin-approval?serviceId=' + encoded(merchantId) })
        return
    }
    if (action == 'CHILD_ENTRUSTMENT') {
        uni.navigateTo({ url: '/pages/children-entrustment/children-entrustment?serviceId=' + encoded(merchantId) })
        return
    }
    if (action == 'CAR_WASH') {
        uni.navigateTo({ url: '/pages/car-wash-merchant/car-wash-merchant?merchantId=' + encoded(merchantId) + '&name=' + name })
        return
    }
    if (action == 'FUEL' || action == 'PARKING') {
        const transportAction = action == 'PARKING' && textValue(item.discount).indexOf('人才码') >= 0 ? 'talentCode' : ''
        uni.navigateTo({
            url: '/pages/merchant/merchant?type=transport&merchantType=' + encoded(merchantType)
                + '&merchantId=' + encoded(merchantId)
                + '&name=' + name
                + '&image=' + image
                + '&address=' + address
                + '&discount=' + discount
                + '&action=' + encoded(transportAction)
        })
        return
    }
 
    uni.navigateTo({
        url: '/pages/merchant/merchant?merchantType=' + encoded(merchantType)
            + '&merchantId=' + encoded(merchantId)
            + '&name=' + name
            + '&image=' + image
            + '&address=' + address
            + '&discount=' + discount
    })
}