Ver Fonte

店铺首页

panhui há 5 anos atrás
pai
commit
0c2f7b65a6
1 ficheiros alterados com 47 adições e 26 exclusões
  1. 47 26
      src/pages/store/homePage.vue

+ 47 - 26
src/pages/store/homePage.vue

@@ -178,23 +178,35 @@ export default {
         loginMethods() {
             this.showLoading();
             this.loading = true;
-            this.getStore().then(res => {
-                console.log(res);
-                this.storeInfo = res;
-                this.getData();
-                setTimeout(() => {
-                    this.offsetTop = this.systemInfo.statusBarHeight + 44;
-                    if (!this.fixedTop) {
-                        wx.createSelectorQuery()
-                            .select('#top')
-                            .boundingClientRect(rect => {
-                                this.fixedTop = rect.height - 44 + 5;
-                                console.log(this.fixedTop);
-                            })
-                            .exec();
-                    }
-                }, 1000);
-            });
+            this.getStore()
+                .then(res => {
+                    console.log(res);
+                    this.storeInfo = res;
+                    this.getData();
+                    setTimeout(() => {
+                        this.offsetTop = this.systemInfo.statusBarHeight + 44;
+                        if (!this.fixedTop) {
+                            wx.createSelectorQuery()
+                                .select('#top')
+                                .boundingClientRect(rect => {
+                                    this.fixedTop = rect.height - 44 + 5;
+                                    console.log(this.fixedTop);
+                                })
+                                .exec();
+                        }
+                    }, 1000);
+                })
+                .catch(e => {
+                    this.hideLoading();
+                    wx.showModal({
+                        content: '无店铺信息',
+                        showCancel: false,
+                        confirmColor: this.$colors.prim,
+                        success: res => {
+                            this.navigateBack();
+                        }
+                    });
+                });
         },
         getStore() {
             // console.log(this.userStoreInfo);
@@ -207,15 +219,24 @@ export default {
                     return this.getStoreById(this.$mp.options.id);
                 }
             } else {
-                return this.$store.dispatch('getUserStore').then(res => {
-                    if (res.id.toString() === this.$mp.options.id || !this.$mp.options.id) {
-                        this.isMineShop = true;
-                        return Promise.resolve(res);
-                    } else {
-                        this.isMineShop = false;
-                        return this.getStoreById(this.$mp.options.id);
-                    }
-                });
+                return this.$store
+                    .dispatch('getUserStore')
+                    .then(res => {
+                        if (res.id.toString() === this.$mp.options.id || !this.$mp.options.id) {
+                            this.isMineShop = true;
+                            return Promise.resolve(res);
+                        } else {
+                            return Promise.reject();
+                        }
+                    })
+                    .catch(e => {
+                        if (!this.$mp.options.id) {
+                            return Promise.reject();
+                        } else {
+                            this.isMineShop = false;
+                            return this.getStoreById(this.$mp.options.id);
+                        }
+                    });
             }
         },
         getStoreById(id) {