Browse Source

查看报价框bug

yangc 7 years ago
parent
commit
9375715910

+ 1 - 1
assets/scss/mobileCommon.scss

@@ -139,7 +139,7 @@ html {
       border-radius: .14rem;
       margin: 0 0 0 .11rem;
       font-size: .26rem;
-      padding: 0 0 0 .21rem;
+      padding: 0 .71rem 0 .21rem;
     }
     span {
       display: inline-block;

+ 5 - 5
components/applyPurchase/ApplyInfo.vue

@@ -43,19 +43,19 @@
             <div class="il-box-large il-box">
               <div :title="purchaseMan.inbrand" class="fl item size-middle">
                 <span>品牌</span>
-                <div class="content">{{purchaseMan.inbrand || '-'}}</div>
+                <div class="content">{{baseUtils.filterStringEllipsis(purchaseMan.inbrand, 48) || '-'}}</div>
               </div>
               <div :title="purchaseMan.cmpCode | nullFilter" class="fl item item-right">
                 <span>型号</span>
-                <div class="content">{{purchaseMan.cmpCode || '-'}}</div>
+                <div class="content">{{baseUtils.filterStringEllipsis(purchaseMan.cmpCode, 54) || '-'}}</div>
               </div>
               <div :title="purchaseMan.prodTitle" class="fl item bottom size-middle">
                 <span>类目(产品名称)</span>
-                <div class="content">{{(purchaseMan.prodTitle || '-') | nullFilter}}</div>
+                <div class="content">{{(baseUtils.filterStringEllipsis(purchaseMan.prodTitle, 48) || '-') | nullFilter}}</div>
               </div>
               <div :title="purchaseMan.spec" class="fl item bottom item-right">
                 <span>规格</span>
-                <div class="content">{{purchaseMan.spec || '-'}}</div>
+                <div class="content">{{baseUtils.filterStringEllipsis(purchaseMan.spec, 54) || '-'}}</div>
               </div>
             </div>
             <div class="il-box-small il-box">
@@ -592,7 +592,7 @@ export default {
                   }
                   .content {
                     display: inline-block;
-                    width: 213px;
+                    width: 251px;
                     overflow: hidden;
                     vertical-align: middle;
                     height: 38px;

+ 1 - 1
components/mobile/applyPurchase/SayPrice.vue

@@ -97,7 +97,7 @@
          if (val) {
            this.$nextTick(() => {
              this._initscroll()
-             this.initSctoll.scrollTo(0, 0, 0)
+             this.initScroll.scrollTo(0, 0, 0)
            })
          }
         this.resetSayPrice()

+ 9 - 6
components/mobile/applyPurchase/SayPriceInfo.vue

@@ -280,7 +280,7 @@
 // //          this.$message.success('请选择报价信息')
 //          this.onRemind('请选择报价信息')
 //        }
-        this.$http.post('/inquiry/buyer/decide?id=' + item.id + '&status=1')
+        this.$http.post('/inquiry/buyer/adopt?id=' + item.id + '&status=1')
           .then(response => {
 //              this.$message.success('采纳成功')
               this.onRemind('采纳成功')
@@ -303,6 +303,7 @@
           .then(res => {
             item.agreed = 0
             this.onRemind('拒绝报价成功')
+            item.refusereason = reason
           }, err => {
             this.onRemind(err.response.data.message || '拒绝报价失败,系统错误')
             console.log(err)
@@ -315,9 +316,8 @@
     },
     mounted() {
       this.$nextTick(() => {
+//        console.log('start')
         this._initscroll()
-//        console.log(this.$refs.modalBody.scrollHeight)
-//        this.$refs.modalBody.style.marginTop = (0 - (this.$refs.modalBody.scrollHeight / 2)) / 100 - 2.5 + 'rem'
       })
     }
   }
@@ -342,11 +342,12 @@
       }
       .say-price-info {
         /*background: #f3f3f3;*/
-        padding: 0;
+        /*padding: .18rem 0 0 0;*/
         width: 100%;
         overflow: hidden;
         max-height: 90%;
         position: relative;
+        margin-top: .1rem;
         .refused-txt {
           span{
             color: #ef5042;
@@ -445,10 +446,11 @@
           }
         }
         .is-buyer {
+          height: 100%;
           .base {
             background: #3f84f6;
             color: #fff;
-            margin: .1rem;
+            margin: 0 .1rem .1rem .1rem;
             border-radius: .1rem;
             .content-line {
               span {
@@ -546,6 +548,7 @@
           }
         }
         .is-vendor {
+          height: 100%;
           .base-info {
             .content-title {
               color: #3f84f6;
@@ -575,7 +578,7 @@
           }
         }
         .say-price-btn {
-          margin: .37rem auto 0;
+          margin: .37rem auto .7rem;
         }
       }
     }

+ 13 - 6
components/mobile/applyPurchase/SeekList.vue

@@ -222,21 +222,28 @@ export default {
       return false
     },
     goSayPriceInfo: function(id, agreed, index) {
+      this.requestSayPrice(id).then(() => {
+        this.agreed = agreed
+        this.showSayPriceInfoBox = true
+        this.activeIndex = index
+      }, err => {
+        console.log(err)
+        this.onRemind('获取报价信息失败')
+      })
+      //        '/mobile/applyPurchase/list/' + (userType ? (item.quteId || item.id) + '?type=' + userType : (item.quteId || item.id)) + (userType ? '&' : '?') + 'status=' + item.agreed
+    },
+    requestSayPrice: function (id) {
       if (this.userType === 'buyer') {
-        this.$store.dispatch('applyPurchase/loadBuyerInquiryDetail', {
+        return this.$store.dispatch('applyPurchase/loadBuyerInquiryDetail', {
           id: id
         })
       } else {
-        this.$store.dispatch('applyPurchase/loadVendorInquiryDetail', {
+        return this.$store.dispatch('applyPurchase/loadVendorInquiryDetail', {
           id: id,
           enuu: this.user.data.enterprise.uu,
           useruu: this.user.data.userUU
         })
       }
-      this.agreed = agreed
-      this.showSayPriceInfoBox = true
-      this.activeIndex = index
-      //        '/mobile/applyPurchase/list/' + (userType ? (item.quteId || item.id) + '?type=' + userType : (item.quteId || item.id)) + (userType ? '&' : '?') + 'status=' + item.agreed
     },
     onSayPriceCancel: function(flag, quteId) {
       if (flag) {

+ 2 - 2
components/mobile/brand/BrandCenter.vue

@@ -27,7 +27,7 @@
               <span v-if="!isSearch">
               {{activeIndex}}开头共<span>{{brandList.totalElements || 0}}</span>个品牌
             </span>
-              <span v-if="isSearch">搜索<span>{{showKeyword}}</span>,共有<span>{{brandList.totalElements || 0}}</span>个品牌</span>
+              <span v-if="isSearch">搜索<span>{{baseUtils.filterStringEllipsis(pageParams.keyword, 25)}}</span>,共有<span>{{brandList.totalElements || 0}}</span>个品牌</span>
             </div>
             <div class="brand-items" v-if="brandListTemplate.length">
               <nuxt-link :to="`/mobile/brand/${brand.uuid}/`" :key="brand.uuid" v-for="brand in brandListTemplate">
@@ -36,7 +36,7 @@
               </nuxt-link>
             </div>
             <empty-status :type="'search'"
-                          :text="`抱歉,暂无与“${pageParams.keyword}”匹配的品牌信息`"
+                          :text="`抱歉,暂无与“${baseUtils.filterStringEllipsis(pageParams.keyword, 25)}”匹配的品牌信息`"
                           :showLink="false"
                           v-else
             ></empty-status>

+ 1 - 1
components/mobile/search/MainSearch.vue

@@ -17,7 +17,7 @@
         <i class="icon-sousuo iconfont"></i>
         <span>{{similar}}</span>
       </li>
-      <li @click="onAssociateClick(keyword)">查找“{{keyword}}”</li>
+      <li @click="onAssociateClick(keyword)">查找“{{baseUtils.filterStringEllipsis(keyword, 30)}}”</li>
     </ul>
     <div class="hot-history" v-show="!associate.show">
       <div class="search-history" v-if="searchHistory && searchHistory.length > 0">

+ 14 - 5
plugins/mixin.js

@@ -4,10 +4,15 @@
 */
 import BScroll from 'better-scroll'
 import Vue from 'vue'
-import {deepCopy, goLinkUser} from '~utils/baseUtils'
+import {deepCopy, goLinkUser, filterStringEllipsis} from '~utils/baseUtils'
 // import { mapState } from 'vuex'
 
 Vue.mixin({
+  data () {
+    return {
+      initScroll: null
+    }
+  },
   computed: {
     user() {
       return this.$store.state.option.user
@@ -53,7 +58,8 @@ Vue.mixin({
     baseUtils () {
       return {
         deepCopy: deepCopy,
-        goLinkUser: goLinkUser
+        goLinkUser: goLinkUser,
+        filterStringEllipsis: filterStringEllipsis
       }
     }
   },
@@ -70,12 +76,15 @@ Vue.mixin({
       }
     },
     _initscroll() {
-      if (!this.initSctoll) {
-        this.initSctoll = new BScroll(this.$refs.mobileModalBox, {
+      if (!this.initScroll) {
+        this.initScroll = new BScroll(this.$refs.mobileModalBox, {
           click: true
         })
       } else {
-        this.initSctoll.refresh()
+        this.initScroll.destroy()
+        this.initScroll = new BScroll(this.$refs.mobileModalBox, {
+          click: true
+        })
       }
     },
     login: function (url) {

+ 119 - 110
utils/baseUtils.js

@@ -1,21 +1,103 @@
 
 const NULL_ARR = ['空', '没', '无', '-', '—', 'null', '#N/A']
 
-// 获取字符串字符长度
-const getRealLength = function (str) {
-  let len = 0
-  for (let i = 0; i < str.length; i++) {
-    if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
-      len += 2
-    } else {
-      len++
+// 立即购买或加入购物车
+/*
+ *  isBuy: 是否是立即购买
+ *  event: 触发事件
+ *  $this: 当前对象
+ *  item: 操作对象
+ * */
+const _buyNow = function (isBuy, event, $this, item) {
+  if (event) 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 (item && !$this.disabledFlag) {
+      if (isBuy) {
+        $this.$http.post('/trade/order/buyNow', [{
+          uuid: item.uuid,
+          batchCode: item.batchCode,
+          number: item.minBuyQty,
+          storeid: item.storeid ? item.storeid : item.storeId,
+          storeUuid: item.storeid ? item.storeid : item.storeId,
+          currencyName: item.currencyName,
+          minPackQty: item.minPackQty
+        }])
+          .then(response => {
+            //        window.location.href = '/user#/order/pay/' + $this.enidfilter(response.data.orderid)
+            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/' + _enidfilter(response.data.data.orderid)
+                }, 1000)
+              } else {
+                window.location.href = '/user#/order/pay/' + _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 (item.minBuyQty > item.reserve) {
+              $this.$message.error('商品' + item.code + '的库存已经不满足起订量')
+            }
+          })
+      } else {
+        // $this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
+        $this.$http.post('/trade/cart/add', {
+          uuid: item.uuid,
+          batchCode: item.batchCode,
+          number: item.minBuyQty,
+          storeid: item.storeid ? item.storeid : item.storeId,
+          storeUuid: item.storeid ? item.storeid : item.storeId,
+          currencyName: item.currencyName,
+          minPackQty: 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)
+              }
+            }
+          })
+      }
     }
   }
-  return len
+  // window.location.href = 'user#/order/pay/' + $this.enidfilter($this.buy_info.orderid)
 }
 
 // 订单号转换
-export const enidfilter = (str) => {
+const _enidfilter = (str) => {
   if (str) {
     let encryptStr = '' // 最终返回的加密后的字符串
     // 产生三位随机数
@@ -84,12 +166,23 @@ export const enidfilter = (str) => {
 }
 
 // 获取字符串字符长度
-export const getRealLen = getRealLength
+const _getRealLen = function (str) {
+  let len = 0
+  for (let i = 0; i < str.length; i++) {
+    if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
+      len += 2
+    } else {
+      len++
+    }
+  }
+  return len
+}
 
-// 根据字符长度剪切字符
-export const cutOutString = (str, length) => {
+export const enidfilter = _enidfilter
+
+const _cutOutString = (str, length) => {
   for (let i = 1; i <= str.length; i++) {
-    if (getRealLength(str.substr(0, i)) > length) {
+    if (_getRealLen(str.substr(0, i)) > length) {
       str = str.substr(0, i - 1)
       break
     }
@@ -97,10 +190,16 @@ export const cutOutString = (str, length) => {
   return str
 }
 
+// 获取字符串字符长度
+export const getRealLen = _getRealLen
+
+// 根据字符长度剪切字符
+export const cutOutString = _cutOutString
+
 // 根据字符长度剪切字符
 export const spliceStr = (str, length) => {
   for (let i = 1; i <= str.length; i++) {
-    if (getRealLength(str.substr(0, i)) > length) {
+    if (_getRealLen(str.substr(0, i)) > length) {
       str = str.substr(0, i - 1) + '...'
       break
     }
@@ -227,99 +326,9 @@ export function whichTransitionEvent() {
     }
   }
 }
-// 立即购买或加入购物车
-/*
- *  isBuy: 是否是立即购买
- *  event: 触发事件
- *  $this: 当前对象
- *  item: 操作对象
- * */
-const buyNow = function (isBuy, event, $this, item) {
-  if (event) 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 (item && !$this.disabledFlag) {
-      if (isBuy) {
-        $this.$http.post('/trade/order/buyNow', [{
-          uuid: item.uuid,
-          batchCode: item.batchCode,
-          number: item.minBuyQty,
-          storeid: item.storeid ? item.storeid : item.storeId,
-          storeUuid: item.storeid ? item.storeid : item.storeId,
-          currencyName: item.currencyName,
-          minPackQty: item.minPackQty
-        }])
-          .then(response => {
-            //        window.location.href = '/user#/order/pay/' + $this.enidfilter(response.data.orderid)
-            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/' + enidfilter(response.data.data.orderid)
-                }, 1000)
-              } else {
-                window.location.href = '/user#/order/pay/' + 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 (item.minBuyQty > item.reserve) {
-              $this.$message.error('商品' + item.code + '的库存已经不满足起订量')
-            }
-          })
-      } else {
-        // $this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
-        $this.$http.post('/trade/cart/add', {
-          uuid: item.uuid,
-          batchCode: item.batchCode,
-          number: item.minBuyQty,
-          storeid: item.storeid ? item.storeid : item.storeId,
-          storeUuid: item.storeid ? item.storeid : item.storeId,
-          currencyName: item.currencyName,
-          minPackQty: 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)
-              }
-            }
-          })
-      }
-    }
-  }
-  // window.location.href = 'user#/order/pay/' + $this.enidfilter($this.buy_info.orderid)
-}
 
-export const buyOrCar = buyNow
+export const buyOrCar = _buyNow
+
+export const filterStringEllipsis = (str, len) => {
+  return str ? _getRealLen(str) > len ? _cutOutString(str, len) + '...' : str : null
+}