sen
1 天以前 5abcde36961125cbf436f91b8c17610a6b5f8308
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
<template>
  <view class="redirect-container">
    <u-loading-icon text="加载中..." />
  </view>
</template>
 
<script>
/**
 * 路由分发页面
 * 根据参数自动跳转到 detail(详情页)或 operate(操作页)
 * 保持向后兼容
 */
export default {
  onLoad(options) {
    const { id, name, ...rest } = options
 
    // 构建查询参数
    const query = Object.entries({ id, ...rest })
      .filter(([_, v]) => v !== undefined && v !== null)
      .map(([k, v]) => `${k}=${encodeURIComponent(v)}`)
      .join('&')
 
    // 根据 name 参数判断跳转目标
    let targetPage = '/pages/examine/detail'
 
    if (name === '上传行程') {
      targetPage = '/pages/examine/operate'
    } else if (name === '查看行程历史' || name === '调度详情' || !name) {
      targetPage = '/pages/examine/detail'
    }
 
    // 使用 redirectTo 替换当前页面,避免返回到这个中转页
    const url = query ? `${targetPage}?${query}` : targetPage
    uni.redirectTo({ url })
  }
}
</script>
 
<style scoped>
.redirect-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #f7f7f7;
}
</style>