yangc 7 years ago
parent
commit
216bda166f

+ 63 - 32
components/mobile/Home.vue

@@ -1,47 +1,78 @@
 <template>
-  <div class="home">
-    <div class="header">
-      <div class="search-content">
-        <input type="text" placeholder="请输入您要查找的型号或品牌">
-        <span>
+  <div>
+    <div class="home" v-if="!showMainSearch">
+      <div class="header">
+        <div class="search-content">
+          <input type="text" placeholder="请输入您要查找的型号或品牌" @click="onHomeSearchClick()">
+          <span>
         <i class="iconfont icon-sousuo"></i>
       </span>
-        <img src="/images/mobile/@2x/applyPurchase/home/phone.png" alt="">
+          <img src="/images/mobile/@2x/applyPurchase/home/phone.png" alt="" @click="showStoreInfo = true">
+        </div>
       </div>
+      <ul class="link-list">
+        <li>
+          <nuxt-link to="/mobile/shop">
+            <img src="/images/mobile/@2x/applyPurchase/home/shop.png" alt="">
+            <span>店铺列表</span>
+          </nuxt-link>
+        </li>
+        <li>
+          <nuxt-link to="/mobile/brand/brandCenter/ABCD">
+            <img src="/images/mobile/@2x/applyPurchase/home/brand.png" alt="">
+            <span>品牌列表</span>
+          </nuxt-link>
+        </li>
+        <li>
+          <nuxt-link to="/mobile/applyPurchase/list">
+            <img src="/images/mobile/@2x/applyPurchase/home/seek.png" alt="">
+            <span>求购询价</span>
+          </nuxt-link>
+        </li>
+      </ul>
+      <div class="seek-title">
+        <img src="/images/mobile/@2x/applyPurchase/home/seek-title.png" alt="">
+        <span>最新求购信息</span>
+        <nuxt-link to="/mobile/applyPurchase/list">查看更多 <img src="/images/mobile/@2x/applyPurchase/home/arrow-right.png" alt=""></nuxt-link>
+      </div>
+      <seek-list></seek-list>
     </div>
-    <ul class="link-list">
-      <li>
-        <nuxt-link to="/mobile/shop">
-          <img src="/images/mobile/@2x/applyPurchase/home/shop.png" alt="">
-          <span>店铺列表</span>
-        </nuxt-link>
-      </li>
-      <li>
-        <nuxt-link to="/mobile/brand/brandCenter/ABCD">
-          <img src="/images/mobile/@2x/applyPurchase/home/brand.png" alt="">
-          <span>品牌列表</span>
-        </nuxt-link>
-      </li>
-      <li>
-        <nuxt-link to="/mobile/applyPurchase/list">
-          <img src="/images/mobile/@2x/applyPurchase/home/seek.png" alt="">
-          <span>求购询价</span>
-        </nuxt-link>
-      </li>
-    </ul>
-    <div class="seek-title">
-      <img src="/images/mobile/@2x/applyPurchase/home/seek-title.png" alt="">
-      <span>最新求购信息</span>
-      <nuxt-link to="/mobile/applyPurchase/list">查看更多 <img src="/images/mobile/@2x/applyPurchase/home/arrow-right.png" alt=""></nuxt-link>
+    <div class="mobile-modal" v-if="showStoreInfo">
+      <div class="mobile-modal-box">
+        <div class="mobile-modal-header">联系方式<i @click="showStoreInfo = false" class="icon-guanbi iconfont"></i></div>
+        <div class="mobile-modal-content">
+          <div>商家地址:深圳市南山区英唐大厦6楼</div>
+          <!-- <div class="content-line link-url">在线咨询</div>-->
+          <div>致电:<a href="tel:4008301818" target="_blank" class="content-line link-url">4008301818</a></div>
+          <div>邮件:<a href="mailto:yrsc@usoftchina.com" target="_blank" class="content-line link-url">yrsc@usoftchina.com</a></div>
+        </div>
+      </div>
     </div>
-    <seek-list></seek-list>
+    <main-search v-if="showMainSearch" @cancelSearchAction="onCancelSearch"></main-search>
   </div>
 </template>
 <script>
   import SeekList from './applyPurchase/SeekList.vue'
+  import MainSearch from '~/components/mobile/search/MainSearch.vue'
   export default {
+    data () {
+      return {
+        showStoreInfo: false,
+        showMainSearch: false
+      }
+    },
     components: {
-      SeekList
+      SeekList,
+      MainSearch
+    },
+    methods: {
+      onHomeSearchClick () {
+        this.showMainSearch = true
+        this.$store.dispatch('searchData/getSearchHistory')
+      },
+      onCancelSearch: function () {
+        this.showMainSearch = false
+      }
     }
   }
 </script>

+ 19 - 2
components/mobile/MobileFooter.vue

@@ -10,7 +10,7 @@
         <i :class="activeType=='shops'?'iconfont icon-dianpu':'iconfont icon-dianpu1'"></i><p>店铺</p>
       </nuxt-link>
     </span>-->
-    <span class="seek" @click="showSayPriceBox = true">
+    <span class="seek" @click="goSayPrice">
       <a>
         <img src="/images/mobile/@2x/applyPurchase/home/seek-footer.png" alt="">
         <p>发布求购</p>
@@ -23,7 +23,7 @@
     </span>
     <a @click="toTop" v-show="!hideToTop"><i class="iconfont icon-arrow-up icon-xlg"></i></a>
     <login-box @onLoginBoxClose="showLoginBox = false" v-if="showLoginBox"></login-box>
-    <publish-seek :showSayPriceBox="showSayPriceBox" @cancelAction="showSayPriceBox = false"></publish-seek>
+    <publish-seek :showSayPriceBox="showSayPriceBox" @cancelAction="showSayPriceBox = false" @reloadAction="onReload()"></publish-seek>
   </div>
 </template>
 <script>
@@ -74,6 +74,23 @@
         } else {
           this.showLoginBox = true
         }
+      },
+      onReload: function () {
+        const path = this.$route.path
+        if (path === '/') {
+          this.$store.dispatch('applyPurchase/loadPurchaseManList', {pageNumber: 1, pageSize: 5, enUU: this.user.data.enterprise ? this.user.data.enterprise.uu : null})
+        } else if (path === '/mobile/applyPurchase/list') {
+          this.$store.dispatch('applyPurchase/loadPurchaseManList', {pageNumber: 1, pageSize: 10, enUU: this.user.data.enterprise ? this.user.data.enterprise.uu : null})
+        } else if (path === '/user') {
+          this.$store.dispatch('applyPurchase/loadBuyerPurchaseManList', {pageNumber: 1, pageSize: 10, enUU: this.user.data.enterprise ? this.user.data.enterprise.uu : this.user.data.userUU})
+        }
+      },
+      goSayPrice: function () {
+        if (this.user.logged) {
+          this.showSayPriceBox = true
+        } else {
+          this.showLoginBox = true
+        }
       }
     }
   }

+ 119 - 12
components/mobile/applyPurchase/PublishSeek.vue

@@ -5,44 +5,146 @@
       <div class="publish-seek">
         <div class="content-line">
           <span><i>*</i>型号:</span>
-          <input type="text" placeholder="请勿填中文符号">
+          <input type="text" v-model="applyObj.code" placeholder="请勿填中文符号">
         </div>
         <div class="content-line">
           <span><i>*</i>品牌:</span>
-          <input type="text" placeholder="请勿填中文符号">
+          <input type="text" v-model="applyObj.brand" placeholder="请勿填中文符号">
         </div>
         <div class="content-line">
           <span><i>*</i>截止日期:</span>
-          <input type="text" placeholder="请勿填中文符号">
+          <input type="text" v-model="applyObj.deadline" @blur="formatDeadLine" placeholder="如2017-02-11">
         </div>
         <div class="content-line">
           <span>币种:</span>
-          <a href="">RMB </a>
-          <ul>
-            <li>不限</li>
-            <li>RMB</li>
-            <li>USD</li>
+          <a v-text="applyObj.currency" @click="showCurrencyList = !showCurrencyList"></a>
+          <img v-if="!showCurrencyList" src="/images/mobile/@2x/applyPurchase/currency-arrow-down.png" alt="">
+          <img v-if="showCurrencyList" src="/images/mobile/@2x/applyPurchase/currency-arrow-up.png" alt="">
+          <ul v-if="showCurrencyList">
+            <li @click="setCurrency('RMB')">RMB</li>
+            <li @click="setCurrency('USD')">USD</li>
           </ul>
         </div>
         <div class="content-line">
           <span>数量:</span>
-          <input type="text">
+          <input type="text" v-model="applyObj.amount">
         </div>
         <div class="content-line">
-          <span>规格:</span>
-          <input type="text">
+          <span>生产日期:</span>
+          <input type="text" v-model="applyObj.produceDate">
         </div>
-        <a>确认发布</a>
+        <a @click="goPublish">确认发布</a>
       </div>
     </div>
   </div>
 </template>
 <script>
+  let formatDate = function (date, fmt) {
+    if (typeof date === 'string') {
+      date = new Date(Date.parse(date.replace(/-/g, '/')))
+    }
+    let o = {
+      'M+': date.getMonth() + 1, // 月份
+      'd+': date.getDate(), // 日
+      'h+': 23, // 小时
+      'm+': 59, // 分
+      's+': 59, // 秒
+      'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
+      'S': date.getMilliseconds() // 毫秒
+    }
+    if (/(y+)/.test(fmt)) {
+      fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
+    }
+    for (let k in o) {
+      if (new RegExp('(' + k + ')').test(fmt)) {
+        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
+      }
+    }
+    return fmt
+  }
   export default {
     props: ['showSayPriceBox'],
+    data () {
+      return {
+        applyObj: {
+          code: '',
+          brand: '',
+          unitPrice: '',
+          currency: 'RMB',
+          encapsulation: '',
+          produceDate: '',
+          amount: '',
+          deadline: ''
+        },
+        showCurrencyList: false
+      }
+    },
+    computed: {
+      user () {
+        return this.$store.state.option.user
+      }
+    },
     methods: {
       cancel: function () {
         this.$emit('cancelAction')
+      },
+      emptyForm: function () {
+        for (let attr in this.applyObj) {
+          this.applyObj[attr] = attr === 'currency' ? 'RMB' : ''
+        }
+      },
+      goPublish: function () {
+        let inquiry = {}
+        let inquiryItem = {}
+        if (this.user.data.enterprise) {
+          inquiry.enUU = this.user.data.enterprise.uu
+        }
+        let date = new Date()
+        inquiry.recorderUU = this.user.data.userUU
+        inquiry.code = 'MALL' + date.getTime()
+        inquiry.date = date
+        inquiry.recorder = this.user.data.userName
+        inquiry.endDate = this.applyObj.deadline
+        inquiry.sourceapp = 'MALL'
+        inquiry.amount = 1
+        inquiryItem.prodTitle = this.applyObj.code
+        inquiryItem.userUU = this.user.data.userUU
+        inquiryItem.source = 'MALL'
+        inquiryItem.userName = this.user.data.userName
+        inquiryItem.userTel = this.user.data.userTel
+        inquiryItem.needquantity = this.applyObj.amount
+        inquiryItem.inbrand = this.applyObj.brand
+        inquiryItem.currency = this.applyObj.unitPrice ? this.applyObj.currency : null
+        inquiryItem.cmpCode = (this.applyObj.code).toUpperCase()
+        inquiryItem.unitPrice = this.applyObj.unitPrice
+        inquiryItem.produceDate = this.applyObj.produceDate
+        inquiryItem.date = date
+        inquiryItem.endDate = this.applyObj.deadline
+        inquiryItem.encapsulation = this.applyObj.encapsulation
+        let inquiryItems = []
+        inquiryItems.push(inquiryItem)
+        inquiry.inquiryItems = inquiryItems
+        this.$http.post('/inquiry/buyer/save', inquiry)
+          .then(response => {
+            this.$message.success('发布成功')
+//                this.showRemindBox = true
+            this.emptyForm()
+//                this.validObj.deadline = true
+            this.$emit('reloadAction')
+            this.cancel()
+          }, error => {
+            console.log(error)
+            this.$message.error('发布失败')
+          })
+      },
+      formatDeadLine: function () {
+        if (this.applyObj.deadline) {
+          this.applyObj.deadline = formatDate(this.applyObj.deadline, 'yyyy-MM-dd hh:mm:ss')
+        }
+      },
+      setCurrency: function (type) {
+        this.applyObj.currency = type
+        this.showCurrencyList = false
       }
     }
   }
@@ -81,6 +183,11 @@
             font-size: .26rem;
             color: #666;
           }
+          > img {
+            width: .12rem;
+            height: .06rem;
+            margin-left: .04rem;
+          }
           > ul {
             position: absolute;
             top: .6rem;

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

@@ -28,9 +28,9 @@
             <i v-if="getDay(item.remainingTime) <= 0" >&nbsp;小时</i>
           </p>
           <p v-else>已截止</p>
-          <a v-if="item.remainingTime > 0 && item.quoted == 1">已报价</a>
+          <!--<a v-if="item.remainingTime > 0 && item.quoted == 1">已报价</a>-->
           <!--<a v-if="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="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="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>-->
           <!--<nuxt-link to="/mobile/applyPurchase/list/1">查看报价</nuxt-link>-->
           </div>
       </div>
@@ -49,10 +49,10 @@
         return year + '-' + month + '-' + day
       },
       enterpriseFilter (str) {
-        return str.length > 4 ? str.substring(0, 2) + '**' + str.substring(str.length - 2, str.length) : str
+        return str && str.length > 4 ? str.substring(0, 2) + '**' + str.substring(str.length - 2, str.length) : str || '-'
       },
       userNameFilter (str) {
-        return str.substring(0, 1) + '**'
+        return str ? str.substring(0, 1) + '**' : '-'
       }
     },
     computed: {