Browse Source

生成链接异常处理

Karsa 2 years ago
parent
commit
657c3d8cc1
1 changed files with 13 additions and 4 deletions
  1. 13 4
      src/views/hzyb/pricedriven/detail.vue

+ 13 - 4
src/views/hzyb/pricedriven/detail.vue

@@ -1,7 +1,7 @@
 <script setup>
 import { ref, onMounted, onUnmounted, computed } from "vue";
 import { useRoute } from "vue-router";
-import { Sticky, Icon, ImagePreview,Popup } from "vant";
+import { Sticky, Icon, ImagePreview,Popup,Toast } from "vant";
 import moment from "moment";
 import 'moment/dist/locale/zh-cn';
 moment.locale('zh-cn');
@@ -32,13 +32,12 @@ const getClassify = async () => {
       _.isShow = _.list ? _.list.some(sub_item => sub_item.pirce_driven_state) : false
     })
     varietiesList.value = permission_list.filter(_ => _.isShow);
-
     // 分享进入的默认品种
     if (route.query.default_classify_first) {
       let index = varietiesList.value.findIndex(
         (_) => _.id === Number(route.query.default_classify_first)
       );
-      changeClassify(varietiesList.value[index],'share');
+      index === -1 ? errorLinkHandle() : changeClassify(varietiesList.value[index],'share');
     } else {
       changeClassify(varietiesList.value[0]);
     }
@@ -58,7 +57,7 @@ const changeClassify = (item,type='') => {
     let index = classifyList.value.findIndex(
       (_) => _.chart_permission_id === Number(route.query.default_classify_sub)
     );
-    changeSubClassify(classifyList.value[index]);
+    index === -1 ? errorLinkHandle() : changeSubClassify(classifyList.value[index]);
   } else {
     changeSubClassify(classifyList.value[0]);
   }
@@ -72,6 +71,16 @@ const changeSubClassify = ({ chart_permission_id, chart_permission_name }) => {
   getDetail();
 
 };
+/* 过期link处理 */
+const errorLinkHandle = () => {
+  Toast('该价格驱动不存在')
+
+  setTimeout(() => {
+    wx.miniProgram.redirectTo({ 
+      url:"/pages/report/report"
+    });
+  },1000)
+}
 
 //详情信息
 const showData = ref(false);