<template>
  <view>
    <!-- 返回按钮 -->
    <u-button @click="goBack">返回</u-button>
    <!-- 其他内容 -->
  </view>
</template>

<script>
export default {
  data() {
    return {
      deviceId: 0,
      source: '',
    };
  },
  onLoad(options) {
    this.deviceId = options.deviceId;
    this.source = options.source; // 获取来源页面
  },
  methods: {
    goBack() {
      if (this.source === 'alert') {
        uni.switchTab({
          url: '/pages/tabBar/alert/index'
        });
      } else {
        uni.navigateBack({
          delta: 1
        });
      }
    }
  }
};
</script>

<style>
  /* No changes to style section */
</style> 