瀏覽代碼

求购手机

yangc 7 年之前
父節點
當前提交
89c1e78c33

+ 1 - 1
components/mobile/MobileFooter.vue

@@ -74,7 +74,7 @@
       },
       goCollect: function () {
         if (this.user.logged) {
-          this.$router.push('/mobile/user')
+          this.$router.push('/mobile/user?type=buyer')
         } else {
           this.showLoginBox = true
         }

+ 83 - 70
components/mobile/applyPurchase/PublishSeek.vue

@@ -5,11 +5,11 @@
       <div class="publish-seek">
         <div class="content-line">
           <span><i>*</i>型号:</span>
-          <input type="text" v-model="applyObj.code" placeholder="请勿填中文符号">
+          <input type="text" v-model="applyObj.code" @blur="checkCode" @input="onCodeChange" placeholder="请勿填中文符号">
         </div>
         <div class="content-line">
           <span><i>*</i>品牌:</span>
-          <input type="text" v-model="applyObj.brand" placeholder="请勿填中文符号">
+          <input type="text" v-model="applyObj.brand" @blur="checkBrand" @input="onBrandChange" placeholder="请勿填中文符号">
         </div>
         <div class="content-line">
           <span><i>*</i>截止日期:</span>
@@ -28,11 +28,11 @@
         </div>
         <div class="content-line">
           <span>数量:</span>
-          <input type="number" v-model="applyObj.amount">
+          <input type="number" v-model="applyObj.amount" @blur="checkAmount" @input="onAmountInput">
         </div>
         <div class="content-line">
           <span>生产日期:</span>
-          <input type="text" v-model="applyObj.produceDate">
+          <input type="text" v-model="applyObj.produceDate" @input="onProduceDateChange">
         </div>
         <a @click="goPublish">确认发布</a>
       </div>
@@ -74,6 +74,15 @@
     }
     return len
   }
+  let cutOutString = function (str, length) {
+    for (let i = 1; i <= str.length; i++) {
+      if (getRealLen(str.substr(0, i)) > length) {
+        str = str.substr(0, i - 1)
+        break
+      }
+    }
+    return str
+  }
   export default {
     props: ['showSayPriceBox'],
     data () {
@@ -88,6 +97,13 @@
           amount: '',
           deadline: ''
         },
+        validObj: {
+          code: true,
+          brand: true,
+          unitPrice: true,
+          amount: true,
+          deadline: true
+        },
         showCurrencyList: false
       }
     },
@@ -116,11 +132,12 @@
             inquiry.enUU = this.user.data.enterprise.uu
           }
           let date = new Date()
+          let endDate = formatDate(this.applyObj.deadline, 'yyyy-MM-dd hh:mm:ss')
           inquiry.recorderUU = this.user.data.userUU
           inquiry.code = 'MALL' + date.getTime()
           inquiry.date = date
           inquiry.recorder = this.user.data.userName
-          inquiry.endDate = formatDate(this.applyObj.deadline, 'yyyy-MM-dd hh:mm:ss')
+          inquiry.endDate = endDate
           inquiry.sourceapp = 'MALL'
           inquiry.amount = 1
           inquiryItem.prodTitle = this.applyObj.code
@@ -135,7 +152,7 @@
           inquiryItem.unitPrice = this.applyObj.unitPrice
           inquiryItem.produceDate = this.applyObj.produceDate
           inquiryItem.date = date
-          inquiryItem.endDate = this.applyObj.deadline
+          inquiryItem.endDate = endDate
           inquiryItem.encapsulation = this.applyObj.encapsulation
           let inquiryItems = []
           inquiryItems.push(inquiryItem)
@@ -170,89 +187,85 @@
 //          this.$message.error('日期需不小于今天且在90天以内')
           this.setRemindText('日期需不小于今天且在90天以内')
           this.applyObj.deadline = ''
+          this.validObj.deadline = false
+        } else {
+          this.validObj.deadline = true
         }
       },
       checkAll: function () {
-        return this.checkCode() && this.checkBrand() && this.checkDeadLine() && this.checkAmount() && this.checkProduceDate()
+        return this.checkCode() && this.checkBrand() && this.checkDeadline() && this.checkAmount()
       },
       checkCode: function () {
-        if (!this.applyObj.code) {
-//          this.$message.error('型号不能为空')
-          this.setRemindText('型号不能为空')
-          return false
-        } else if ((/[^\x00-\xff]/g).test(this.applyObj.code)) {
-//          this.$message.error('型号不能包含中文及中文字符')
-          this.setRemindText('型号不能包含中文及中文字符')
-          return false
-        } else if (getRealLen(this.applyObj.code) > 100) {
-//          this.$message.error('型号不能超过100个字符')
-          this.setRemindText('型号不能超过100个字符')
-          return false
-        } else {
-          return true
+        this.validObj.code = this.applyObj.code && this.applyObj.code !== ''
+        if (!this.validObj.code) {
+          this.$message.error('型号不能为空')
         }
+        return this.validObj.code
       },
       checkBrand: function () {
-        let chineseIndex = -1
+        this.validObj.brand = this.applyObj.brand && this.applyObj.brand !== ''
+        if (!this.validObj.brand) {
+          this.$message.error('品牌不能为空')
+        }
+        return this.validObj.brand
+      },
+      checkAmount: function () {
+        this.validObj.amount = this.applyObj.amount === '' ? true : this.applyObj.amount > 0 && this.applyObj.amount < 1000000000
+        return this.validObj.amount
+      },
+      checkDeadline: function () {
+        this.validObj.deadline = Boolean(this.applyObj.deadline)
+        return this.validObj.deadline
+      },
+      onProduceDateChange: function () {
+        if (this.applyObj.produceDate && getRealLen(this.applyObj.produceDate) > 12) {
+          this.applyObj.produceDate = cutOutString(this.applyObj.produceDate, 12)
+        }
+      },
+      onCodeChange: function () {
+        this.applyObj.code = this.applyObj.code.trim()
+        if ((/[^\x00-\xff]/g).test(this.applyObj.code)) {
+          let chineseIndex = -1
+          for (let i = 0; i < this.applyObj.code.length; i++) {
+            if ((/[^\x00-\xff]/g).test(this.applyObj.code.charAt(i))) {
+              chineseIndex = i
+              break
+            }
+          }
+          this.applyObj.code = cutOutString(this.applyObj.code, chineseIndex)
+        } else if (this.applyObj.code && getRealLen(this.applyObj.code) > 100) {
+          this.applyObj.code = cutOutString(this.applyObj.code, 100)
+        }
+      },
+      onBrandChange: function () {
+        this.applyObj.brand = this.applyObj.brand.trim()
         if ((/[^\x00-\xff]/g).test(this.applyObj.brand)) {
+          let chineseIndex = -1
           for (let i = 0; i < this.applyObj.brand.length; i++) {
             if ((/[^\x00-\xff]/g).test(this.applyObj.brand.charAt(i)) && !(/[\u4e00-\u9fa5]/).test(this.applyObj.brand.charAt(i))) {
               chineseIndex = i
               break
             }
           }
-        }
-        if (!this.applyObj.brand) {
-//          this.$message.error('品牌不能为空')
-          this.setRemindText('品牌不能为空')
-          return false
-        } else if (chineseIndex !== -1) {
-//          this.$message.error('品牌不能包含中文字符')
-          this.setRemindText('品牌不能包含中文字符')
-          return false
-        } else if (getRealLen(this.applyObj.brand) > 50) {
-//          this.$message.error('品牌不能超过50个字符')
-          this.setRemindText('品牌不能超过50个字符')
-          return false
-        } else {
-          return true
-        }
-      },
-      checkDeadLine: function () {
-        if (!this.applyObj.deadline) {
-//          this.$message.error('截止日期不能为空')
-          this.setRemindText('截止日期不能为空')
-        }
-        return this.applyObj.deadline
-      },
-      checkAmount: function () {
-        if (typeof this.applyObj.amount === 'undefined' || this.applyObj.amount === '') {
-          return true
-        } else {
-          if (!(/^[0-9]*$/).test(this.applyObj.amount)) {
-//            this.$message.error('请输入正确的数量')
-            this.setRemindText('请输入正确的数量')
-            return false
-          } else if (this.applyObj.amount.length > 9) {
-//            this.$message.error('数量不能大于999999999')
-            this.setRemindText('数量不能大于999999999')
-            return false
-          } else {
-            return true
+          if (chineseIndex > -1) {
+            this.applyObj.brand = this.applyObj.brand.substring(0, chineseIndex)
           }
+        } else if (this.applyObj.brand && getRealLen(this.applyObj.brand) > 50) {
+          this.applyObj.brand = cutOutString(this.applyObj.brand, 50)
         }
       },
-      checkProduceDate: function () {
-        if (typeof this.applyObj.produceDate === 'undefined' || this.applyObj.produceDate === '') {
-          return true
-        } else {
-          if (getRealLen(this.applyObj.produceDate) > 12) {
-//            this.$message.error('生产日期不能大于12个字符')
-            this.setRemindText('生产日期不能大于12个字符')
-            return false
-          } else {
-            return true
+      onAmountInput: function () {
+        if (!(/^[0-9]*$/).test(this.applyObj.amount)) {
+          let chineseIndex = -1
+          for (let i = 0; i < this.applyObj.amount.length; i++) {
+            if (!(/^[0-9]*$/).test(this.applyObj.amount.charAt(i))) {
+              chineseIndex = i
+              break
+            }
           }
+          this.applyObj.amount = cutOutString(this.applyObj.amount, chineseIndex)
+        } else if (this.applyObj.amount.length > 9) {
+          this.applyObj.amount = cutOutString(this.applyObj.amount, 9)
         }
       }
     }

+ 5 - 5
components/mobile/applyPurchase/SayPriceInfo.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="say-price-info">
-    <div v-if="!isVendor">
+    <div v-if="isBuyer">
       <div class="base-info">
         <div class="content-line">
           型号:<span>{{purchaseDetail.cmpCode || '-'}}</span>
@@ -60,7 +60,7 @@
       </div>
       <a class="say-price-btn" v-if="purchaseDetail.agreed != 1" @click="acceptQutation">采纳报价</a>
     </div>
-    <div v-if="isVendor">
+    <div v-if="!isBuyer">
       <div class="base-info">
         <div class="content-line">
           型号:<span>{{purchaseDetail.cmpCode || '-'}}</span>
@@ -146,13 +146,13 @@
     },
     computed: {
       purchaseDetail () {
-        return this.isVendor ? this.$store.state.applyPurchase.purchaseManList.vendorInquiryDetail.data : this.$store.state.applyPurchase.purchaseManList.buyerInquiryDetail.data
+        return this.isBuyer ? this.$store.state.applyPurchase.purchaseManList.buyerInquiryDetail.data : this.$store.state.applyPurchase.purchaseManList.vendorInquiryDetail.data
       },
       user () {
         return this.$store.state.option.user
       },
-      isVendor () {
-        return this.$route.query.type === 'saler'
+      isBuyer () {
+        return this.$route.query.type === 'buyer'
       }
     },
     methods: {

+ 2 - 2
components/mobile/applyPurchase/SeekList.vue

@@ -31,8 +31,8 @@
             <p v-else>已截止</p>
             <!--<a v-if="!userType && item.quoted == 1">已报价</a>-->
             <!--<a v-if="!userType && item.remainingTime > 0 && (!item.quoted || item.quoted != 1) && (user.logged && ((item.inquiry.enterprise && user.data.enterprise && (item.inquiry.enterprise.uu === user.data.enterprise.uu)) || (!user.data.enterprise.uu && item.userUU == user.data.userUU  && !item.inquiry.enterprise)))">自己发布的</a>-->
-            <a v-if="!(userType == 'saler' && seekType  && seekType != 'wait') && (item.remainingTime > 0 && (!item.quoted || item.quoted != 1) && !(user.logged && ((item.inquiry.enterprise && user.data.enterprise && (item.inquiry.enterprise.uu === user.data.enterprise.uu)) || (!user.data.enterprise.uu && item.userUU == user.data.userUU  && !item.inquiry.enterprise))))"  @click="goSayPrice(item.inquiry.id)">我要报价</a>
-            <nuxt-link v-if="((!userType || userType == 'buyer') && (seekType  && seekType != 'wait')) || (userType == 'saler' && seekType  && seekType != 'wait') || item.quoted == 1" :to="'/mobile/applyPurchase/list/' + (userType ? item.inquiry.id + '?type=' + userType : item.id) + (userType ? '&' : '?') + 'status=' + item.agreed">查看报价</nuxt-link>
+            <a v-if="!(userType == 'saler' && seekType  && seekType != 'wait') && (item.remainingTime > 0 && (!item.quoted || item.quoted != 1) && !(user.logged && ((item.inquiry.enterprise && user.data.enterprise && (item.inquiry.enterprise.uu === user.data.enterprise.uu)) || (!user.data.enterprise.uu && item.userUU == user.data.userUU  && !item.inquiry.enterprise))))"  @click="goSayPrice(item.id)">我要报价</a>
+            <nuxt-link v-if="((!userType || userType == 'buyer') && (seekType  && seekType != 'wait')) || (userType == 'saler' && seekType  && seekType != 'wait') || item.quoted == 1" :to="'/mobile/applyPurchase/list/' + (userType ? (item.quteId || item.id) + '?type=' + userType : (item.quteId || item.id)) + (userType ? '&' : '?') + 'status=' + item.agreed">查看报价</nuxt-link>
           </div>
         </div>
       </li>

+ 1 - 1
pages/mobile/applyPurchase/list/_id.vue

@@ -12,7 +12,7 @@
     },
     fetch ({store, route}) {
       return Promise.all([
-        route.query.type === 'saler' ? store.dispatch('applyPurchase/loadVendorInquiryDetail', {id: route.params.id}) : store.dispatch('applyPurchase/loadBuyerInquiryDetail', {id: route.params.id})
+        route.query.type === 'buyer' ? store.dispatch('applyPurchase/loadBuyerInquiryDetail', {id: route.params.id}) : store.dispatch('applyPurchase/loadVendorInquiryDetail', {id: route.params.id})
       ])
     }
   }

+ 1 - 1
pages/mobile/user/index.vue

@@ -185,7 +185,7 @@
       switchType: function () {
         this.seekType = 'wait'
         this.seekKeyword = ''
-        this.$router.push('/mobile/user' + (this.userType === 'saler' ? '' : '?type=saler'))
+        this.$router.push('/mobile/user' + (this.userType === 'saler' ? '?type=buyer' : '?type=saler'))
       },
       searchSeek: function () {
         this.isChange = true