Browse Source

优化开通卖家的接口调用

suntg 7 years ago
parent
commit
155385ce31
1 changed files with 27 additions and 24 deletions
  1. 27 24
      components/register-saler/register/StepThird.vue

+ 27 - 24
components/register-saler/register/StepThird.vue

@@ -417,25 +417,26 @@
           }
         }
       },
+      // 个人用户,先注册企业,成功后,提交开店申请
       registerSelf: function () {
         this.showLoading = true
         this.$http.post('/basic/enterprise/register?filePath=' + this.registerData.url, this.registerData.enterprise)
           .then(response => {
             if (response.data.success) {
               this.isSelfRegisterSuccess = true
+              // 删除保存的缓存企业信息
               this.$http.delete('basic/user/userCacheEnterprise')
-              this.$http.get('/user/authentication/reflash')
-                .then(() => {
-                  this.$http.get(`/user/authentication/` + response.data.data.enuu).then(() => {
-                    this.$store.dispatch('loadUserInfo')
-                    this.loginData.isSelf = false
-                    this.loginData.enterprise.uu = response.data.data.enuu
-                    this.storeApply(response.data.data.enuu)
+              // 把当前用户登录企业信息切换为注册的企业
+              this.$http.get(`/user/authentication/` + response.data.data.enuu).then(() => {
+                // 重新获取登录用户信息
+                this.$store.dispatch('loadUserInfo')
+                this.loginData.isSelf = false
+                this.loginData.enterprise.uu = response.data.data.enuu
+                // 提交开店申请
+                this.storeApply(response.data.data.enuu)
 //                    window.location.reload()
-                    this.showLoading = false
-                  })
-                }
-              )
+                this.showLoading = false
+              })
             } else {
               this.isSelfRegisterSuccess = false
               this.showLoading = false
@@ -448,6 +449,7 @@
             this.$message.error('企业注册失败,请重新填写信息')
           })
       },
+      // 提交开店申请
       storeApply: function (enuu) {
         this.showLoading = true
         let validCode = 0
@@ -504,16 +506,16 @@
               }
               this.$http.post('/basic/enterprise/openVendor/' + enuu)
                 .then(() => {
-                  this.$http.get('/user/authentication/reflash')
-                    .then(() => {
-                      this.$http.get(`/user/authentication/` + enuu).then(() => {
-                        this.$store.dispatch('loadUserInfo')
-                      })
-                    })
+//                  this.$http.get('/user/authentication/reflash')
+//                    .then(() => {
+//                      this.$http.get(`/user/authentication/` + enuu).then(() => {
+//                        this.$store.dispatch('loadUserInfo')
+//                      })
+//                    })
+                  window.setTimeout(function () {
+                    window.location.href = '/vendor#/store-apply/wait'
+                  }, 3000)
                 })
-              window.setTimeout(function () {
-                window.location.href = '/vendor#/store-apply/wait'
-              }, 3000)
             }, err => {
               console.log(err)
               this.$http.post('/basic/enterprise/openVendorSetRead/' + enuu)
@@ -553,10 +555,11 @@
           .then(() => {
             this.$http.get('/user/authentication/reflash')
               .then(() => {
-                this.$http.get(`/user/authentication/` + enuu).then(() => {
-                  this.$store.dispatch('loadUserInfo')
-                  window.location.href = url
-                })
+//                this.$http.get(`/user/authentication/` + enuu).then(() => {
+//                  this.$store.dispatch('loadUserInfo')
+//                  window.location.href = url
+//                })
+                window.location.href = url
               })
           })
       },