Browse Source

求购频道-未登录跳转

liusw 8 years ago
parent
commit
48f28e740e
2 changed files with 41 additions and 27 deletions
  1. 22 15
      components/applyPurchase/ApplyInfo.vue
  2. 19 12
      components/applyPurchase/PublishApply.vue

+ 22 - 15
components/applyPurchase/ApplyInfo.vue

@@ -132,6 +132,9 @@
       },
       totalCount () {
         return this.purchaseManList.totalElements
+      },
+      user () {
+        return this.$store.state.option.user
       }
     },
     methods: {
@@ -152,25 +155,29 @@
         purchaseMan.active = false
       },
       commitSayPrice: function (purchaseMan) {
-        let valid = this.sayPriceObj.currency && this.sayPriceObj.unitPrice && this.sayPriceObj.minDay && this.sayPriceObj.maxDay
-        if (valid) {
-          this.sayPriceObj.spId = purchaseMan.id
-          this.sayPriceObj.currency = purchaseMan.currency
-          this.$http.post('/seek/offer/saveOffer', this.sayPriceObj).then(response => {
-            this.$message.success('发布成功')
-            this.nowPage = 1
-            this.resetSayPrice()
-            this.resetList()
-          }, error => {
-            console.log(error)
-            this.$message.error('系统错误')
-          })
+        if (this.user.logged) {
+          let valid = this.sayPriceObj.currency && this.sayPriceObj.unitPrice && this.sayPriceObj.minDay && this.sayPriceObj.maxDay
+          if (valid) {
+            this.sayPriceObj.spId = purchaseMan.id
+            this.sayPriceObj.currency = purchaseMan.currency
+            this.$http.post('/seek/offer/saveOffer', this.sayPriceObj).then(response => {
+              this.$message.success('发布成功')
+              this.nowPage = 1
+              this.resetSayPrice()
+              this.resetList()
+            }, error => {
+              console.log(error)
+              this.$message.error('系统错误')
+            })
+          } else {
+            this.$message.error('请填写正确的信息')
+          }
         } else {
-          this.$message.error('请填写正确的信息')
+          this.$router.push('/auth/login')
         }
       },
       resetList: function () {
-        this.$store.dispatch('applyPurchase/loadPurchaseManList', {page: this.nowPage, count: this.pageSize, keyWord: this.keyWord, sorting: this.sorting})
+        this.$store.dispatch('applyPurchase/loadPurchaseManList', {page: this.nowPage, count: this.pageSize, keyWord: this.keyWord, sorting: !this.sorting || JSON.stringify(this.sorting) === '{}' ? {releaseDate: 'DESC'} : this.sorting})
       },
       resetSayPrice: function () {
         this.sayPriceObj = {

+ 19 - 12
components/applyPurchase/PublishApply.vue

@@ -156,6 +156,9 @@
       },
       purchaseRank () {
         return this.$store.state.applyPurchase.purchaseApplyRank.purchaseApplyRank.data
+      },
+      user () {
+        return this.$store.state.option.user
       }
     },
     methods: {
@@ -168,19 +171,23 @@
         return index === 0 ? 1 : index < 3 ? 2 : 3
       },
       goPublish: function () {
-        if (this.checkAll()) {
-          this.$http.post('/seek/saveOneSeekPurchase', this.applyObj)
-            .then(response => {
-              this.$message.success('发布成功')
-//              this.showRemindBox = true
-              this.emptyForm()
-              this.$store.dispatch('applyPurchase/loadPurchaseManList', {page: 1, count: 10})
-            }, error => {
-              console.log(error)
-              this.$message.error('发布失败')
-            })
+        if (this.user.logged) {
+          if (this.checkAll()) {
+            this.$http.post('/seek/saveOneSeekPurchase', this.applyObj)
+              .then(response => {
+                this.$message.success('发布成功')
+  //              this.showRemindBox = true
+                this.emptyForm()
+                this.$store.dispatch('applyPurchase/loadPurchaseManList', {page: 1, count: 10})
+              }, error => {
+                console.log(error)
+                this.$message.error('发布失败')
+              })
+          } else {
+            this.$message.error('请填写正确的信息')
+          }
         } else {
-          this.$message.error('请填写正确的信息')
+          this.$router.push('/auth/login')
         }
       },
       checkCode: function () {