youyawu 5 years ago
parent
commit
9d5f0cb722

+ 3 - 0
src/lang/en.ts

@@ -34,6 +34,9 @@ export default {
       cancelGz: "Cancel attention?",
       revocation: "Do you want to cancel the requirement?",
       logout: "Log out?"
+    },
+    warning: {
+      login: "Please log in before operation"
     }
   },
   route: {

+ 3 - 0
src/lang/zh.ts

@@ -37,6 +37,9 @@ export default {
     },
     error: {
       imgUpload: "只能上传png或jpg格式"
+    },
+    warning: {
+      login: "请先登陆后操作"
     }
   },
   route: {

+ 1 - 1
src/layout/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="layout">
     <y-header @reload="reload" />
-    <keep-alive exclude="shopEnterAdd,infoList,shopEnter" v-if="showView">
+    <keep-alive exclude="shopEnterAdd,infoList,shopEnter,user" v-if="showView">
       <router-view />
     </keep-alive>
     <y-footer />

+ 1 - 2
src/router/index.ts

@@ -64,9 +64,8 @@ const router = new VueRouter({
           meta: { title: "findPassword", NoHeader: true }
         },
         {
-          path: "/user/:index?",
+          path: "/user",
           component: () => import("../views/account/user/index.vue"),
-          props: true,
           meta: { title: "user", auth: true }
         },
         {

+ 9 - 11
src/views/account/user/index.vue

@@ -16,6 +16,7 @@
       <tab
         class="tab"
         :titles="$t(`page.views.account.user.index.titles`)"
+        v-if="currIndex !== null"
         :currIndex.sync="currIndex"
       />
 
@@ -115,10 +116,9 @@
 </template>
 <script lang="ts">
 import { Component, Vue, Watch, Prop } from "vue-property-decorator";
-@Component
+@Component({ name: "user" })
 export default class extends Vue {
-  @Prop(String) private index!: string;
-  private currIndex: number = 0;
+  private currIndex: number | null = null;
   private arr: Array<{
     url: string;
     params: IAny | null;
@@ -130,21 +130,19 @@ export default class extends Vue {
       params: null,
       items: []
     }));
-  activated() {
-    this.currIndex = Number(this.index) || 0;
-    this.reload();
+  created() {
+    const { index = 0 } = this.$route.query;
+    this.currIndex = Number(index) | 0;
   }
   @Watch("currIndex")
   currIndexChange() {
+    if (this.currIndex === null) return;
     this.arr[this.currIndex].params = this.arr[this.currIndex].params || {};
   }
   setItems(items: any[], index: number) {
     this.$set(this.arr[index], "items", items.length ? items : null);
   }
 
-  reload() {
-    this.arr[this.currIndex].params = {};
-  }
   async cancelGz(companyId: number) {
     if (
       !(await this.$confirm(
@@ -157,7 +155,7 @@ export default class extends Vue {
     });
     if (err) return;
     this.$message.success(`${this.$i18n.t("message.success.cancelGz")}`);
-    this.reload();
+    this.arr[0].params = {};
   }
   async revocation(id: number) {
     if (
@@ -171,7 +169,7 @@ export default class extends Vue {
     });
     if (err) return;
     this.$message.success(`${this.$i18n.t("message.success.revocation")}`);
-    this.reload();
+    this.arr[1].params = {};
   }
 }
 </script>

+ 1 - 1
src/views/info/add.vue

@@ -125,7 +125,7 @@ export default class extends Vue {
     if (err) return;
     this.elForm.resetFields();
     this.$message.success(`${this.$i18n.t("message.success.infoAdd")}`);
-    this.$router.push("/user/1");
+    this.$router.push("/user?index=1");
   }
 }
 </script>

+ 3 - 3
src/views/news/index.vue

@@ -39,9 +39,9 @@ export default class extends Vue {
   @Prop(String) private index!: string;
   private currIndex: number = 0;
   private params: IAny | null = null;
-  @Watch("index", { immediate: true })
-  indexChange(index: string) {
-    this.currIndex = Number(index) || 0;
+
+  activated() {
+    this.currIndex = Number(this.index) || 0;
     this.currIndexChange();
   }
   @Watch("currIndex")

+ 6 - 1
src/views/shops/details/index.vue

@@ -63,6 +63,7 @@
 </template>
 <script lang="ts">
 import { Component, Vue, Watch, Prop } from "vue-property-decorator";
+import user from "@/store/modules/user";
 @Component
 export default class extends Vue {
   private shopInfo: IAny = {};
@@ -80,9 +81,13 @@ export default class extends Vue {
   }
   search() {
     this.keyWord = this.searchVal;
-    this.$router.push(`/shop/${this.shopInfo.id}`);
+    const url = `/shop/${this.shopInfo.id}/products`;
+    if (this.$route.path === url) return;
+    this.$router.push(url);
   }
   async gz() {
+    if (!user.UserInfo)
+      return this.$message.warning(`${this.$i18n.t("message.warning.login")}`);
     const [err, data] = await this.$post("/member/follow/addMemberFollow", {
       companyId: this.sid
     });