IosStoreHeatMap.nvue
4.76 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<template>
<view class="ios-heatmap">
<view class="date-picker">
<DatePicker @change="handleDateChange" :has-today="false" @modalChange="handleModalChange">
<template #filter>
<view class="filter" @tap="handleSelectFilterItem">
<uv-text :text="indicatorText" align="center" size="26rpx" color="#202328" :lines="1"></uv-text>
<uv-icon name="arrow-down-fill" class="filter_icon" size="10rpx" color="#202328" />
</view>
</template>
</DatePicker>
</view>
<view class="mall" style="height: 0;overflow: hidden;">
<MallSelectNvue has-store="1" choose-group="0" @change="handlStoreChange" />
</view>
<IndicatorsFilter ref="filterRef" :options="indicatorsList" @change="handleIndicatorChange"
@modalChange="handleModalChange" />
</view>
</template>
<script setup>
import {
ref,
watch
} from 'vue'
import {
getStageObj,
rpx2Px
} from '@/utils'
import DatePicker from '@/components/DatePicker.nvue'
import MallSelectNvue from '@/components/MallSelect.nvue';
import IndicatorsFilter from '@/components/IndicatorsFilter.nvue'
import {
onHide,
onShow
} from '@dcloudio/uni-app'
import {
t
} from '@/plugins/index.js'
const props = defineProps({
index: {
type: Number,
default: 0
}
})
watch(() => props.index, (newVal) => {
if (newVal !== 1) {
if (webview.value) {
webview.value?.hide()
}
}else {
webview.value?.show()
}
})
const params = ref({})
const flag = ref(false) // 是否初始化完成
const indicatorsList = [{
name: t('table.residenceTime'),
key: 'rt'
}, {
name: t('PreMallIndex.CustomerMantime'),
key: 'tc'
}]
const indicatorText = ref(t('table.residenceTime'))
const indicatorKey = ref('rt')
// storeChange
const handlStoreChange = (e) => {
params.value = {
...params.value,
...e
}
if (!params.value.storeId) {
const store = getStageObj('store')
params.value.storeId = store.id
}
}
let showHideFlag = ref(false)
onHide(() => {
if (webview.value && props.index === 1) {
plus.webview.close(webview.value)
webview.value = null
showHideFlag.value = true
}else{
showHideFlag.value = false
}
})
onShow(() => {
if (showHideFlag.value) {
initHeatMapApp()
}
})
// pickerChange
const handleDateChange = (e) => {
const [startDate, endDate] = e.range
params.value = {
...params.value,
startDate,
endDate,
...e
}
// 日期更改时直接加载数据
if (!flag.value) {
initHeatMapApp()
}
}
const filterRef = ref(null)
const handleSelectFilterItem = () => {
filterRef.value?.open()
}
const handleIndicatorChange = (e) => {
indicatorText.value = e.name
indicatorKey.value = e.key
// 指标更改时直接加载数据
if (!flag.value) {
initHeatMapApp()
}
}
// webview信息 仅ios
const webview = ref(null)
const handleModalChange = (val) => {
val ? webview.value?.hide() : webview.value?.show()
}
const initHeatMapApp = () => {
console.log(params.value);
if (webview.value) {
plus.webview.close(webview.value)
webview.value = null
}
const {
startDate,
endDate,
indicatorKey: indicatorKeys
} = params.value
const token = uni.getStorageSync('Authorization')
const store = getStageObj('store')
const storeId = params.value.storeId || store.id
const statusBarHeight = plus.navigator.getStatusbarHeight()
const top = statusBarHeight + 88 + rpx2Px(100)
// const systemInfo = uni.getSystemInfoSync()
// const tabBarHeight = systemInfo.safeArea.bottom + 50
console.log(
`https://store.keliuyun.com/apph5/heatMap?token=${token}&mallId=${storeId}&startDate=${startDate}&endDate=${endDate}&level=${indicatorKeys||'rt'}`
);
webview.value = plus.webview.create(
`https://store.keliuyun.com/apph5/heatMap?token=${token}&mallId=${storeId}&startDate=${startDate}&endDate=${endDate}&level=${indicatorKeys||'rt'}`,
"store-heatmap", {
top: `${top}px`, // 关键:从导航栏下方开始
bottom: "50px",
left: "0px",
right: "0px",
'uni-app': 'none',
popGesture: 'close',
// backButtonAutoControl:'close',
hardwareAccelerated: true,
wkwebview: true,
zindex: 0
}
)
webview.value.show()
}
</script>
<style scoped>
.date-picker {
padding: 20rpx;
}
.filter {
background-color: #fff;
width: 160rpx;
height: 60rpx;
border-radius: 12rpx;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
margin-left: 16rpx;
padding: 0 10rpx;
}
</style>