Browse Source

Merge remote-tracking branch 'origin/feature-201819-wangcz' into feature-201819-wangcz

# Conflicts:
#	components/common/buyOrCar/buyComponent.vue
shenjj 7 years ago
parent
commit
2cbf9958ae
2 changed files with 93 additions and 83 deletions
  1. 91 81
      components/common/buyOrCar/buyComponent.vue
  2. 2 2
      components/search/GoodList.vue

+ 91 - 81
components/common/buyOrCar/buyComponent.vue

@@ -27,88 +27,98 @@
     props: ['item', 'disabledFlag', 'btnColor'],
     methods: {
       buyNow: function (isBuy, event) {
-        this.$root.$emit('add_cart', event.target)
+        // let $el = this.$refs.ballCard
+        // let transform = whichTransitionEvent()
+        // let _shopCar = document.getElementById('shopCar')
+        // let _eltop = event.currentTarget.getBoundingClientRect().top - 22
+        // let _elleft = event.currentTarget.getBoundingClientRect().left - 278
+        // // $el.style = `left: ${_elleft}px;top:${_eltop}px`
+        // $el.style[transform] = `translate3d(${_elleft}px,${_eltop}px,0)`
+        // $el.style.transition = 'all 0.5s'
+        // let _shopCarTop = _shopCar.getBoundingClientRect().top
+        // let _shopCarLeft = _shopCar.getBoundingClientRect().left
+        // $el.style[transform] = `translate3d(${_shopCarLeft}px,${_shopCarTop}px,0)`
         event.stopPropagation()
-        // if (!this.$store.state.option.user.logged) {
-        //   this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
-        //     if (response.data) {
-        //       window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
-        //     }
-        //   })
-        // } else {
-        //   if (this.item && !this.disabledFlag) {
-        //     if (isBuy) {
-        //       this.$http.post('/trade/order/buyNow', [{
-        //         uuid: this.item.uuid,
-        //         batchCode: this.item.batchCode,
-        //         number: this.item.minBuyQty,
-        //         storeid: this.item.storeid ? this.item.storeid : this.item.storeId,
-        //         storeUuid: this.item.storeid ? this.item.storeid : this.item.storeId,
-        //         currencyName: this.item.currencyName,
-        //         minPackQty: this.item.minPackQty
-        //       }])
-        //         .then(response => {
-        //           if (response.data.success) {
-        //             if (response.data.message) {
-        //               this.$message({
-        //                 message: response.data.message,
-        //                 type: 'success'
-        //               })
-        //               window.setTimeout(function () {
-        //                 window.location.href = '/user#/order/pay/' + this.baseUtils.enidfilter(response.data.data.orderid)
-        //               }, 1000)
-        //             } else {
-        //               window.location.href = '/user#/order/pay/' + this.baseUtils.enidfilter(response.data.data.orderid)
-        //             }
-        //           } else {
-        //             if (response.data.data && response.data.data.unvailable === 1) {
-        //               this.$message.error('产品信息已失效,请刷新页面')
-        //             } else {
-        //               this.$message.error(response.data.message)
-        //             }
-        //           }
-        //         }, err => {
-        //           console.log(err)
-        //           if (this.item.minBuyQty > this.item.reserve) {
-        //             this.$message.error('商品' + this.item.code + '的库存已经不满足最小起订量')
-        //           }
-        //         })
-        //     } else {
-        //       this.$http.post('/trade/cart/add', {
-        //         uuid: this.item.uuid,
-        //         batchCode: this.item.batchCode,
-        //         number: this.item.minBuyQty,
-        //         storeid: this.item.storeid ? this.item.storeid : this.item.storeId,
-        //         storeUuid: this.item.storeid ? this.item.storeid : this.item.storeId,
-        //         currencyName: this.item.currencyName,
-        //         minPackQty: this.item.minPackQty
-        //       })
-        //         .then(response => {
-        //           if (response.data.success) {
-        //             if (response.data.message) {
-        //               this.$message({
-        //                 message: '添加购物车成功,但商品信息有更新',
-        //                 type: 'success'
-        //               })
-        //             } else {
-        //               this.$message({
-        //                 message: '添加购物车成功',
-        //                 type: 'success'
-        //               })
-        //             }
-        //           } else {
-        //             if (response.data.code === 2) {
-        //               this.$message.error('库存已不满足最小起订量')
-        //             } else if (response.data.message === '该产品已失效') {
-        //               this.$message.error(response.data.message + ',请刷新页面')
-        //             } else {
-        //               this.$message.error(response.data.message)
-        //             }
-        //           }
-        //         })
-        //     }
-        //   }
-        // }
+        if (!this.$store.state.option.user.logged) {
+          this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
+            if (response.data) {
+              window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
+            }
+          })
+        } else {
+          if (this.item && !this.disabledFlag) {
+            if (isBuy) {
+              this.$http.post('/trade/order/buyNow', [{
+                uuid: this.item.uuid,
+                batchCode: this.item.batchCode,
+                number: this.item.minBuyQty,
+                storeid: this.item.storeid ? this.item.storeid : this.item.storeId,
+                storeUuid: this.item.storeid ? this.item.storeid : this.item.storeId,
+                currencyName: this.item.currencyName,
+                minPackQty: this.item.minPackQty
+              }])
+                .then(response => {
+                  if (response.data.success) {
+                    if (response.data.message) {
+                      this.$message({
+                        message: response.data.message,
+                        type: 'success'
+                      })
+                      window.setTimeout(function () {
+                        window.location.href = '/user#/order/pay/' + this.baseUtils.enidfilter(response.data.data.orderid)
+                      }, 1000)
+                    } else {
+                      window.location.href = '/user#/order/pay/' + this.baseUtils.enidfilter(response.data.data.orderid)
+                    }
+                  } else {
+                    if (response.data.data && response.data.data.unvailable === 1) {
+                      this.$message.error('产品信息已失效,请刷新页面')
+                    } else {
+                      this.$message.error(response.data.message)
+                    }
+                  }
+                }, err => {
+                  console.log(err)
+                  if (this.item.minBuyQty > this.item.reserve) {
+                    this.$message.error('商品' + this.item.code + '的库存已经不满足最小起订量')
+                  }
+                })
+            } else {
+              this.$http.post('/trade/cart/add', {
+                uuid: this.item.uuid,
+                batchCode: this.item.batchCode,
+                number: this.item.minBuyQty,
+                storeid: this.item.storeid ? this.item.storeid : this.item.storeId,
+                storeUuid: this.item.storeid ? this.item.storeid : this.item.storeId,
+                currencyName: this.item.currencyName,
+                minPackQty: this.item.minPackQty
+              })
+                .then(response => {
+                  if (response.data.success) {
+                    if (response.data.message) {
+                      this.$message({
+                        message: '添加购物车成功,但商品信息有更新',
+                        type: 'success'
+                      })
+                    } else {
+                      this.$message({
+                        message: '添加购物车成功',
+                        type: 'success'
+                      })
+                    }
+                  } else {
+                    if (response.data.code === 2) {
+                      this.$message.error('库存已不满足最小起订量')
+                    } else if (response.data.message === '该产品已失效') {
+                      this.$message.error(response.data.message + ',请刷新页面')
+                    } else {
+                      this.$message.error(response.data.message)
+                    }
+                  }
+                })
+            }
+          }
+        }
       },
       setHoverStyle: function (isShow) {
         if (this.btnColor) {

+ 2 - 2
components/search/GoodList.vue

@@ -147,7 +147,7 @@
               </div>
             </td>
           </tr>
-          <tr v-if="!good_list.content || !good_list.content.length">
+          <!--<tr v-if="!good_list.content || !good_list.content.length">
             <td colspan="12">
               <div class="empty">
                 <p class="empty-img">
@@ -159,7 +159,7 @@
                 </div>
               </div>
             </td>
-          </tr>
+          </tr>-->
           </tbody>
         </table>
       </div>